From 1bffaa07f337c7329ca13cfe4ec00c4829f1d5d7 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 30 Jul 2020 10:44:57 -0500 Subject: [PATCH] Add flake.nix --- flake.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8e0a799 --- /dev/null +++ b/flake.nix @@ -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); + }; +}