moongen 0.0.2

moonsharp bytecode types, assembler, disassembler, and static analyzer
Documentation
{
	description = "moonsharp bytecode types, assembler, disassembler, and static analyzer";

	inputs = {
		nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

		systems.url = "github:nix-systems/default";

		crane.url = "github:ipetkov/crane";

		rust-overlay = {
			url = "github:oxalica/rust-overlay";
			inputs.nixpkgs.follows = "nixpkgs";
		};
	};

	outputs = inputs: let
		lib = inputs.nixpkgs.lib;
		rust-overlay = import inputs.rust-overlay;
		forAllSystems = fn: lib.genAttrs (import inputs.systems) (system: fn {
			inherit system;
			pkgs = import inputs.nixpkgs {
				inherit system;
				overlays = [ rust-overlay ];
			};
		});

		craneLib = forAllSystems ({ system, pkgs }: (inputs.crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.nightly.latest.default));
	in {
		checks = forAllSystems ({ system, ... }: {
			moongen = inputs.self.packages.${system}.default;
		});

		packages = forAllSystems ({ system, pkgs }: let
			# Common arguments can be set here to avoid repeating them later
			# Note: changes here will rebuild all dependency crates
			commonArgs = {
				src = lib.cleanSourceWith {
					src = ./.;
					filter = path: type: (
						craneLib.${system}.filterCargoSources path type
						|| (builtins.match ".*md$" path != null)
						|| (builtins.match ".*pest$" path != null)
					);
					name = "source";
				};
				
				strictDeps = true;

				buildInputs = [
					# add additional build inputs here
				] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
					# additional darwin specific inputs can be set here
					pkgs.libiconv
				];
			};
		in {
			default = craneLib.${system}.buildPackage (commonArgs // {
				cargoArtifacts = craneLib.${system}.buildDepsOnly commonArgs;
			});
		});

		apps = forAllSystems ({ system, pkgs }: {
			default = {
				type = "app";
				program = "${inputs.self.packages.${system}.default}/bin/moongen";
			};
		});

		devShells = forAllSystems ({ system, ... }: {
			default = craneLib.${system}.devShell {
				# Inherit inputs from checks.
				checks = inputs.self.checks.${system};
			};
		});
	};
}