Add flake.nix

This commit is contained in:
Matthew Bauer 2020-07-30 10:44:57 -05:00
parent 5caec2e85a
commit 1bffaa07f3

27
flake.nix Normal file
View File

@ -0,0 +1,27 @@
{
description = "The purely functional package manager";
inputs.nixpkgs.url = "nixpkgs/nixos-20.03-small";
outputs = { self, nixpkgs }: let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in {
exporters = forAllSystems (system: let
nixpkgs' = nixpkgs.legacyPackages.${system};
nix-bundle = import self { nixpkgs = nixpkgs'; };
in {
nix-bundle = { program }: let
script = nixpkgs'.writeScript "startup" ''
#!/bin/sh
.${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -- ${program} $@
'';
in nix-bundle.makebootstrap {
targets = [ script ];
startup = ".${builtins.unsafeDiscardStringContext script} '\"$@\"'";
};
});
defaultExporter = forAllSystems (system: self.exporters.${system}.nix-bundle);
};
}