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