]>
Commit | Line | Data |
---|---|---|
fdf6f74d IB |
1 | { pkgs }: |
2 | with pkgs; | |
7636abc6 | 3 | rec { |
167b8165 IB |
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 | ||
803d2d9f IB |
15 | nodeEnv = import ./lib/node-env.nix; |
16 | ||
dc101440 IB |
17 | fetchedGithub = path: |
18 | let | |
19 | json = lib.importJSON path; | |
20 | in rec { | |
21 | version = json.tag; | |
22 | name = "${json.meta.name}-${version}"; | |
23 | src = fetchFromGitHub json.github; | |
24 | }; | |
25 | ||
26 | fetchedGit = path: | |
27 | let | |
28 | json = lib.importJSON path; | |
29 | in rec { | |
30 | version = json.tag; | |
31 | name = "${json.meta.name}-${version}"; | |
32 | src = fetchgit json.git; | |
33 | }; | |
6cd8d6ce | 34 | |
65fe7543 IB |
35 | fetchedGitPrivate = path: |
36 | let | |
37 | json = lib.importJSON path; | |
38 | in rec { | |
39 | version = json.tag; | |
40 | name = "${json.meta.name}-${version}"; | |
41 | src = fetchgitPrivate json.git; | |
42 | }; | |
43 | ||
5566d26d IB |
44 | wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }: |
45 | assert file != null || script != null || | |
46 | abort "wrap needs 'file' or 'script' argument"; | |
47 | with rec { | |
48 | set = n: v: "--set ${pkgs.lib.escapeShellArg n} " + | |
49 | "${pkgs.lib.escapeShellArg v}"; | |
50 | args = (map (p: "--prefix PATH : ${p}/bin") paths) ++ | |
51 | (builtins.attrValues (pkgs.lib.mapAttrs set vars)); | |
52 | }; | |
53 | runCommand name | |
54 | { | |
55 | f = if file == null then writeScript name script else file; | |
56 | buildInputs = [ makeWrapper ]; | |
57 | } | |
58 | '' | |
59 | makeWrapper "$f" "$out" ${toString args} | |
60 | ''; | |
7636abc6 | 61 | |
fdf6f74d IB |
62 | # This adds header colors to the builds, but it rebuilds the whole |
63 | # world from scratch, so only use it to debug! | |
64 | # add it as postHook in derivations | |
65 | immaePostHook = '' | |
66 | header() { | |
67 | echo -ne "\033[1;36m" | |
68 | echo -n "$1" | |
69 | echo -e "\033[0m" | |
70 | } | |
71 | ||
72 | echoCmd() { | |
73 | printf "\033[1;34m%s:\033[0m" "$1" | |
74 | shift | |
75 | printf ' %q' "$@" | |
76 | echo | |
77 | } | |
78 | ''; | |
79 | ||
dc101440 | 80 | } |