]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - libs.nix
Improve iota cli app build
[perso/Immae/Config/Nix.git] / libs.nix
CommitLineData
596e62a6
IB
1{ nixpkgs }:
2with nixpkgs;
7636abc6 3rec {
dc101440
IB
4 fetchedGithub = path:
5 let
6 json = lib.importJSON path;
7 in rec {
8 version = json.tag;
9 name = "${json.meta.name}-${version}";
10 src = fetchFromGitHub json.github;
11 };
12
13 fetchedGit = path:
14 let
15 json = lib.importJSON path;
16 in rec {
17 version = json.tag;
18 name = "${json.meta.name}-${version}";
19 src = fetchgit json.git;
20 };
6cd8d6ce 21
65fe7543
IB
22 fetchedGitPrivate = path:
23 let
24 json = lib.importJSON path;
25 in rec {
26 version = json.tag;
27 name = "${json.meta.name}-${version}";
28 src = fetchgitPrivate json.git;
29 };
30
5566d26d
IB
31 wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
32 assert file != null || script != null ||
33 abort "wrap needs 'file' or 'script' argument";
34 with rec {
35 set = n: v: "--set ${pkgs.lib.escapeShellArg n} " +
36 "${pkgs.lib.escapeShellArg v}";
37 args = (map (p: "--prefix PATH : ${p}/bin") paths) ++
38 (builtins.attrValues (pkgs.lib.mapAttrs set vars));
39 };
40 runCommand name
41 {
42 f = if file == null then writeScript name script else file;
43 buildInputs = [ makeWrapper ];
44 }
45 ''
46 makeWrapper "$f" "$out" ${toString args}
47 '';
7636abc6
IB
48
49 yarn2nixPackage = callPackage (fetchedGithub ./fetched/yarn2nix.json).src {};
dc101440 50}