|
1 | 1 | {
|
2 | 2 | description = "The purely functional package manager";
|
3 | 3 |
|
4 |
| - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | + utils.url = "github:numtide/flake-utils"; |
| 7 | + }; |
5 | 8 |
|
6 |
| - outputs = { self, nixpkgs }: let |
7 |
| - systems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; |
8 |
| - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); |
9 |
| - in { |
10 |
| - bundlers = { |
11 |
| - nix-bundle = { program, system }: let |
12 |
| - nixpkgs' = nixpkgs.legacyPackages.${system}; |
13 |
| - nix-bundle = import self { nixpkgs = nixpkgs'; }; |
14 |
| - script = nixpkgs'.writeScript "startup" '' |
15 |
| - #!/bin/sh |
16 |
| - .${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -- ${program} "$@" |
17 |
| - ''; |
18 |
| - in nix-bundle.makebootstrap { |
19 |
| - targets = [ script ]; |
20 |
| - startup = ".${builtins.unsafeDiscardStringContext script} '\"$@\"'"; |
21 |
| - }; |
22 |
| - }; |
| 9 | + outputs = |
| 10 | + inputs: |
| 11 | + let |
| 12 | + inherit (inputs.nixpkgs) lib; |
23 | 13 |
|
24 |
| - defaultBundler = self.bundlers.nix-bundle; |
25 |
| - }; |
| 14 | + getExe = |
| 15 | + x: |
| 16 | + lib.getExe' x ( |
| 17 | + x.meta.mainProgram or (lib.warn |
| 18 | + "nix-bundle: Package ${ |
| 19 | + lib.strings.escapeNixIdentifier x.meta.name or x.pname or x.name |
| 20 | + } does not have the meta.mainProgram attribute. Assuming you want '${lib.getName x}'." |
| 21 | + lib.getName |
| 22 | + x |
| 23 | + ) |
| 24 | + ); |
| 25 | + in |
| 26 | + inputs.utils.lib.eachDefaultSystem ( |
| 27 | + system: |
| 28 | + let |
| 29 | + nix-bundle-fun = |
| 30 | + { |
| 31 | + drv, |
| 32 | + programPath ? getExe drv, |
| 33 | + }: |
| 34 | + let |
| 35 | + nixpkgs = inputs.nixpkgs.legacyPackages.${system}; |
| 36 | + nix-bundle = import inputs.self { inherit nixpkgs; }; |
| 37 | + script = nixpkgs.writeScript "startup" '' |
| 38 | + #!/bin/sh |
| 39 | + .${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -- ${programPath} "$@" |
| 40 | + ''; |
| 41 | + in |
| 42 | + nix-bundle.makebootstrap { |
| 43 | + drvToBundle = drv; |
| 44 | + targets = [ script ]; |
| 45 | + startup = ".${builtins.unsafeDiscardStringContext script} '\"$@\"'"; |
| 46 | + }; |
| 47 | + in |
| 48 | + { |
| 49 | + bundlers = { |
| 50 | + default = inputs.self.bundlers.${system}.nix-bundle; |
| 51 | + nix-bundle = drv: nix-bundle-fun { inherit drv; }; |
| 52 | + }; |
| 53 | + } |
| 54 | + ); |
26 | 55 | }
|
0 commit comments