]>
Commit | Line | Data |
---|---|---|
1 | { pkgs }: | |
2 | with pkgs; | |
3 | rec { | |
4 | yarn2nixPackage = let | |
5 | src = fetchFromGitHub { | |
6 | owner = "moretea"; | |
7 | repo = "yarn2nix"; | |
8 | rev = "780e33a07fd821e09ab5b05223ddb4ca15ac663f"; | |
9 | sha256 = "1f83cr9qgk95g3571ps644rvgfzv2i4i7532q8pg405s4q5ada3h"; | |
10 | fetchSubmodules = true; | |
11 | }; | |
12 | in | |
13 | (callPackage src {}) // { inherit src; }; | |
14 | ||
15 | fetchedGithub = path: | |
16 | let | |
17 | json = lib.importJSON path; | |
18 | in rec { | |
19 | version = json.tag; | |
20 | name = "${json.meta.name}-${version}"; | |
21 | src = fetchFromGitHub json.github; | |
22 | }; | |
23 | ||
24 | fetchedGit = path: | |
25 | let | |
26 | json = lib.importJSON path; | |
27 | in rec { | |
28 | version = json.tag; | |
29 | name = "${json.meta.name}-${version}"; | |
30 | src = fetchgit json.git; | |
31 | }; | |
32 | ||
33 | fetchedGitPrivate = path: | |
34 | let | |
35 | json = lib.importJSON path; | |
36 | in rec { | |
37 | version = json.tag; | |
38 | name = "${json.meta.name}-${version}"; | |
39 | src = fetchgitPrivate json.git; | |
40 | }; | |
41 | ||
42 | wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }: | |
43 | assert file != null || script != null || | |
44 | abort "wrap needs 'file' or 'script' argument"; | |
45 | with rec { | |
46 | set = n: v: "--set ${pkgs.lib.escapeShellArg n} " + | |
47 | "${pkgs.lib.escapeShellArg v}"; | |
48 | args = (map (p: "--prefix PATH : ${p}/bin") paths) ++ | |
49 | (builtins.attrValues (pkgs.lib.mapAttrs set vars)); | |
50 | }; | |
51 | runCommand name | |
52 | { | |
53 | f = if file == null then writeScript name script else file; | |
54 | buildInputs = [ makeWrapper ]; | |
55 | } | |
56 | '' | |
57 | makeWrapper "$f" "$out" ${toString args} | |
58 | ''; | |
59 | ||
60 | # This adds header colors to the builds, but it rebuilds the whole | |
61 | # world from scratch, so only use it to debug! | |
62 | # add it as postHook in derivations | |
63 | immaePostHook = '' | |
64 | header() { | |
65 | echo -ne "\033[1;36m" | |
66 | echo -n "$1" | |
67 | echo -e "\033[0m" | |
68 | } | |
69 | ||
70 | echoCmd() { | |
71 | printf "\033[1;34m%s:\033[0m" "$1" | |
72 | shift | |
73 | printf ' %q' "$@" | |
74 | echo | |
75 | } | |
76 | ''; | |
77 | ||
78 | } |