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); + }; +}