diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-11 20:53:31 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-11 20:53:31 +0200 |
commit | 0b3f9cb9fde5929f361e91f6ed5b43958665f3d5 (patch) | |
tree | 053739b02f2c94150e6eeecd9a8403a72265dad2 /lib | |
parent | 22ba294f88a3d58db170d96324be41acd70b46f5 (diff) | |
download | Nix-0b3f9cb9fde5929f361e91f6ed5b43958665f3d5.tar.gz Nix-0b3f9cb9fde5929f361e91f6ed5b43958665f3d5.tar.zst Nix-0b3f9cb9fde5929f361e91f6ed5b43958665f3d5.zip |
Adjust some library functions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/lib/default.nix b/lib/default.nix index 6b3dfdf..86832d4 100644 --- a/lib/default.nix +++ b/lib/default.nix | |||
@@ -17,7 +17,8 @@ rec { | |||
17 | json = lib.importJSON path; | 17 | json = lib.importJSON path; |
18 | in rec { | 18 | in rec { |
19 | version = json.tag; | 19 | version = json.tag; |
20 | name = "${json.meta.name}-${version}"; | 20 | pname = json.meta.name; |
21 | name = "${pname}-${version}"; | ||
21 | src = fetchFromGitHub json.github; | 22 | src = fetchFromGitHub json.github; |
22 | }; | 23 | }; |
23 | 24 | ||
@@ -26,7 +27,8 @@ rec { | |||
26 | json = lib.importJSON path; | 27 | json = lib.importJSON path; |
27 | in rec { | 28 | in rec { |
28 | version = json.tag; | 29 | version = json.tag; |
29 | name = "${json.meta.name}-${version}"; | 30 | pname = json.meta.name; |
31 | name = "${pname}-${version}"; | ||
30 | src = fetchgit json.git; | 32 | src = fetchgit json.git; |
31 | }; | 33 | }; |
32 | 34 | ||
@@ -35,30 +37,12 @@ rec { | |||
35 | json = lib.importJSON path; | 37 | json = lib.importJSON path; |
36 | in rec { | 38 | in rec { |
37 | version = json.tag; | 39 | version = json.tag; |
38 | name = "${json.meta.name}-${version}"; | 40 | pname = json.meta.name; |
41 | name = "${pname}-${version}"; | ||
39 | src = builtins.fetchGit { | 42 | src = builtins.fetchGit { |
40 | url = json.git.url; | 43 | url = json.git.url; |
41 | ref = "master"; | 44 | ref = "master"; |
42 | rev = json.git.rev; | 45 | rev = json.git.rev; |
43 | }; | 46 | }; |
44 | }; | 47 | }; |
45 | |||
46 | wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }: | ||
47 | assert file != null || script != null || | ||
48 | abort "wrap needs 'file' or 'script' argument"; | ||
49 | with rec { | ||
50 | set = n: v: "--set ${pkgs.lib.escapeShellArg n} " + | ||
51 | "${pkgs.lib.escapeShellArg v}"; | ||
52 | args = (map (p: "--prefix PATH : ${p}/bin") paths) ++ | ||
53 | (builtins.attrValues (pkgs.lib.mapAttrs set vars)); | ||
54 | }; | ||
55 | runCommand name | ||
56 | { | ||
57 | f = if file == null then writeScript name script else file; | ||
58 | buildInputs = [ makeWrapper ]; | ||
59 | } | ||
60 | '' | ||
61 | makeWrapper "$f" "$out" ${toString args} | ||
62 | ''; | ||
63 | |||
64 | } // (if builtins.pathExists ./private then callPackage ./private {} else {}) | 48 | } // (if builtins.pathExists ./private then callPackage ./private {} else {}) |