m2 0.0.0

Set of Unix tools to work with m2dirs
Documentation
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    crane = {
      url = "github:ipetkov/crane";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    fenix = {
      url = "github:nix-community/fenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    crane,
    fenix,
    ...
  }: let
    systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
    eachSystem = systems: f: let
      op = attrs: system: let
        ret = f system;
        op = attrs: key:
          attrs
          // {
            ${key} =
              (attrs.${key} or {})
              // {${system} = ret.${key};};
          };
      in
        builtins.foldl' op attrs (builtins.attrNames ret);
    in
      builtins.foldl' op {} systems;
    forAllSystems = eachSystem systems;
  in
    forAllSystems (system: let
      pkgs = import nixpkgs {
        inherit system;
        overlays = [fenix.overlays.default];
      };

      toolchain = pkgs.fenix.complete.withComponents [
        "cargo"
        "clippy"
        "rust-src"
        "rustc"
        "rustfmt"
      ];

      craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
      buildInputs = with pkgs; [pandoc iconv];
      version = (craneLib.crateNameFromCargoToml {cargoToml = ./Cargo.toml;}).version;
    in rec {
      packages.default = craneLib.buildPackage {
        inherit buildInputs version;
        src = pkgs.lib.cleanSourceWith {src = craneLib.path ./.;};
      };

      apps.default = {
        drv = packages.default;
      };

      devShells.default = pkgs.mkShell {
        inherit buildInputs;
        nativeBuildInputs = with pkgs;
          [
            toolchain
            rust-analyzer-nightly
          ]
          ++ lib.optionals stdenv.isDarwin [darwin.apple_sdk.frameworks.Security];
      };
    });
}