|
1 | 1 | # This file is generated by running "yarn install" inside your project. |
2 | 2 | # Manual changes might be lost - proceed with caution! |
3 | 3 |
|
4 | | -{ |
5 | | - lib, |
6 | | - stdenv, |
7 | | - nodejs, |
8 | | - git, |
9 | | - cacert, |
10 | | - fetchurl, |
11 | | - writeShellScript, |
12 | | - writeShellScriptBin, |
13 | | -}: |
14 | | -{ |
15 | | - src, |
16 | | - overrideAttrs ? null, |
17 | | - ... |
18 | | -}@args: |
| 4 | +{ lib, stdenv, nodejs, git, cacert, fetchurl, writeShellScript, writeShellScriptBin }: |
| 5 | +{ src, overrideAttrs ? null, ... } @ args: |
19 | 6 |
|
20 | 7 | let |
21 | 8 |
|
|
25 | 12 | lockfile = ./yarn.lock; |
26 | 13 |
|
27 | 14 | # Call overrideAttrs on a derivation if a function is provided. |
28 | | - optionalOverride = fn: drv: if fn == null then drv else drv.overrideAttrs fn; |
| 15 | + optionalOverride = fn: drv: |
| 16 | + if fn == null then drv else drv.overrideAttrs fn; |
29 | 17 |
|
30 | 18 | # Simple stub that provides the global yarn command. |
31 | 19 | yarn = writeShellScriptBin "yarn" '' |
|
35 | 23 | # Common attributes between Yarn derivations. |
36 | 24 | drvCommon = { |
37 | 25 | # Make sure the build uses the right Node.js version everywhere. |
38 | | - buildInputs = [ |
39 | | - nodejs |
40 | | - yarn |
41 | | - ]; |
| 26 | + buildInputs = [ nodejs yarn ]; |
42 | 27 | # All dependencies should already be cached. |
43 | 28 | yarn_enable_network = "0"; |
44 | 29 | # Tell node-gyp to use the provided Node.js headers for native code builds. |
|
55 | 40 | export yarn_enable_nixify=false |
56 | 41 | ''; |
57 | 42 |
|
58 | | - cacheDrv = stdenv.mkDerivation rec { |
| 43 | + cacheDrv = stdenv.mkDerivation { |
59 | 44 | name = "yarn-cache"; |
60 | | - buildInputs = [ |
61 | | - yarn |
62 | | - git |
63 | | - cacert |
64 | | - ]; |
65 | | - |
66 | | - nativeBuildInputs = buildInputs ++ [ nodejs ]; |
67 | | - |
| 45 | + buildInputs = [ yarn git cacert ]; |
68 | 46 | buildCommand = '' |
69 | 47 | cp --reflink=auto --recursive '${src}' ./src |
70 | 48 | cd ./src/ |
|
74 | 52 | rm $out/.gitignore |
75 | 53 | ''; |
76 | 54 | outputHashMode = "recursive"; |
77 | | - outputHash = ( |
78 | | - if stdenv.isAarch64 then |
79 | | - "sha512-+f3z4zwF2YlzskL7uDwVvQ3Fg0EYJ1HGPEqIGNb2VsiQpXoY2tU+EufqX79YRCOW7lXkuDfMQHYI3XcPioAEvg==" |
80 | | - else |
81 | | - "sha512-8spVLTYEciHn5q0N1R4fRB9EBM4gzZ1Zd4EeZdLwQM6ob+wvgP3oMH6JHQXUxKraP8TlpuVg7l2gNsTaAH5NoQ==" |
82 | | - ); |
| 55 | + outputHash = "sha512-vYIsSgRtzeRWe6L5DcVqWRmBSbcjX0aYrr2V4bnAw+S4UnWVzqaTbS9GY02XSEgrBvcs0r5mqDdR8Ha/DOxpoA=="; |
83 | 56 | }; |
84 | 57 |
|
85 | 58 | # Main project derivation. |
86 | | - project = stdenv.mkDerivation ( |
87 | | - drvCommon |
88 | | - // { |
89 | | - inherit src; |
90 | | - name = "codetracer"; |
91 | | - |
92 | | - configurePhase = '' |
93 | | - ${buildVars} |
94 | | -
|
95 | | - # Copy over the Yarn cache. |
96 | | - rm -fr '${cacheFolder}' |
97 | | - mkdir -p '${cacheFolder}' |
98 | | - cp --reflink=auto --recursive ${cacheDrv}/* '${cacheFolder}/' |
99 | | -
|
100 | | - # Yarn may need a writable home directory. |
101 | | - export yarn_global_folder="$TMP" |
102 | | -
|
103 | | - # Ensure global cache is disabled. Cache must be part of our output. |
104 | | - touch .yarnrc.yml |
105 | | - sed -i -e '/^enableGlobalCache/d' .yarnrc.yml |
106 | | - echo 'enableGlobalCache: false' >> .yarnrc.yml |
107 | | -
|
108 | | - # Some node-gyp calls may call out to npm, which could fail due to an |
109 | | - # read-only home dir. |
110 | | - export HOME="$TMP" |
111 | | -
|
112 | | - # running preConfigure after the cache is populated allows for |
113 | | - # preConfigure to contain substituteInPlace for dependencies as well as the |
114 | | - # main project. This is necessary for native bindings that maybe have |
115 | | - # hardcoded values. |
116 | | - runHook preConfigure |
117 | | -
|
118 | | - # Run normal Yarn install to complete dependency installation. |
119 | | - yarn install --immutable --immutable-cache |
120 | | -
|
121 | | - runHook postConfigure |
122 | | - ''; |
| 59 | + project = stdenv.mkDerivation (drvCommon // { |
| 60 | + inherit src; |
| 61 | + name = "codetracer"; |
123 | 62 |
|
124 | | - buildPhase = '' |
125 | | - runHook preBuild |
126 | | - runHook postBuild |
127 | | - ''; |
| 63 | + configurePhase = '' |
| 64 | + ${buildVars} |
128 | 65 |
|
129 | | - installPhase = '' |
130 | | - runHook preInstall |
| 66 | + # Copy over the Yarn cache. |
| 67 | + rm -fr '${cacheFolder}' |
| 68 | + mkdir -p '${cacheFolder}' |
| 69 | + cp --reflink=auto --recursive ${cacheDrv}/* '${cacheFolder}/' |
131 | 70 |
|
132 | | - # Move the package contents to the output directory. |
133 | | - if grep -q '"workspaces"' package.json; then |
134 | | - # We can't use `yarn pack` in a workspace setup, because it only |
135 | | - # packages the outer workspace. |
136 | | - mkdir -p "$out/libexec" |
137 | | - mv $PWD "$out/libexec/$name" |
138 | | - else |
139 | | - # - If the package.json has a `files` field, only files matching those patterns are copied |
140 | | - # - Otherwise all files are copied. |
141 | | - yarn pack --out package.tgz |
142 | | - mkdir -p "$out/libexec/$name" |
143 | | - tar xzf package.tgz --directory "$out/libexec/$name" --strip-components=1 |
| 71 | + # Yarn may need a writable home directory. |
| 72 | + export yarn_global_folder="$TMP" |
144 | 73 |
|
145 | | - cp --reflink=auto .yarnrc* "$out/libexec/$name" |
146 | | - cp --reflink=auto ${lockfile} "$out/libexec/$name/yarn.lock" |
147 | | - cp --reflink=auto --recursive .yarn "$out/libexec/$name" |
| 74 | + # Ensure global cache is disabled. Cache must be part of our output. |
| 75 | + touch .yarnrc.yml |
| 76 | + sed -i -e '/^enableGlobalCache/d' .yarnrc.yml |
| 77 | + echo 'enableGlobalCache: false' >> .yarnrc.yml |
148 | 78 |
|
149 | | - # Copy the Yarn linker output into the package. |
150 | | - cp --reflink=auto --recursive node_modules "$out/libexec/$name" |
151 | | - fi |
| 79 | + # Some node-gyp calls may call out to npm, which could fail due to an |
| 80 | + # read-only home dir. |
| 81 | + export HOME="$TMP" |
152 | 82 |
|
153 | | - cd "$out/libexec/$name" |
| 83 | + # running preConfigure after the cache is populated allows for |
| 84 | + # preConfigure to contain substituteInPlace for dependencies as well as the |
| 85 | + # main project. This is necessary for native bindings that maybe have |
| 86 | + # hardcoded values. |
| 87 | + runHook preConfigure |
154 | 88 |
|
155 | | - # Invoke a plugin internal command to setup binaries. |
156 | | - mkdir -p "$out/bin" |
157 | | - yarn nixify install-bin $out/bin |
| 89 | + # Run normal Yarn install to complete dependency installation. |
| 90 | + yarn install --immutable --immutable-cache |
158 | 91 |
|
159 | | - # A package with node_modules doesn't need the cache |
160 | | - yarn cache clean |
| 92 | + runHook postConfigure |
| 93 | + ''; |
161 | 94 |
|
162 | | - runHook postInstall |
163 | | - ''; |
| 95 | + buildPhase = '' |
| 96 | + runHook preBuild |
| 97 | + runHook postBuild |
| 98 | + ''; |
| 99 | + |
| 100 | + installPhase = '' |
| 101 | + runHook preInstall |
164 | 102 |
|
165 | | - passthru = { |
166 | | - inherit nodejs; |
167 | | - yarn-freestanding = yarn; |
168 | | - yarn = writeShellScriptBin "yarn" '' |
169 | | - exec '${yarn}/bin/yarn' --cwd '${overriddenProject}/libexec/${overriddenProject.name}' "$@" |
170 | | - ''; |
171 | | - }; |
172 | | - } |
173 | | - ); |
| 103 | + # Move the package contents to the output directory. |
| 104 | + if grep -q '"workspaces"' package.json; then |
| 105 | + # We can't use `yarn pack` in a workspace setup, because it only |
| 106 | + # packages the outer workspace. |
| 107 | + mkdir -p "$out/libexec" |
| 108 | + mv $PWD "$out/libexec/$name" |
| 109 | + else |
| 110 | + # - If the package.json has a `files` field, only files matching those patterns are copied |
| 111 | + # - Otherwise all files are copied. |
| 112 | + yarn pack --out package.tgz |
| 113 | + mkdir -p "$out/libexec/$name" |
| 114 | + tar xzf package.tgz --directory "$out/libexec/$name" --strip-components=1 |
| 115 | +
|
| 116 | + cp --reflink=auto .yarnrc* "$out/libexec/$name" |
| 117 | + cp --reflink=auto ${lockfile} "$out/libexec/$name/yarn.lock" |
| 118 | + cp --reflink=auto --recursive .yarn "$out/libexec/$name" |
| 119 | +
|
| 120 | + # Copy the Yarn linker output into the package. |
| 121 | + cp --reflink=auto --recursive node_modules "$out/libexec/$name" |
| 122 | + fi |
| 123 | +
|
| 124 | + cd "$out/libexec/$name" |
| 125 | +
|
| 126 | + # Invoke a plugin internal command to setup binaries. |
| 127 | + mkdir -p "$out/bin" |
| 128 | + yarn nixify install-bin $out/bin |
| 129 | +
|
| 130 | + # A package with node_modules doesn't need the cache |
| 131 | + yarn cache clean |
| 132 | +
|
| 133 | + runHook postInstall |
| 134 | + ''; |
| 135 | + |
| 136 | + passthru = { |
| 137 | + inherit nodejs; |
| 138 | + yarn-freestanding = yarn; |
| 139 | + yarn = writeShellScriptBin "yarn" '' |
| 140 | + exec '${yarn}/bin/yarn' --cwd '${overriddenProject}/libexec/${overriddenProject.name}' "$@" |
| 141 | + ''; |
| 142 | + }; |
| 143 | + }); |
174 | 144 |
|
175 | 145 | overriddenProject = optionalOverride overrideAttrs project; |
176 | 146 |
|
177 | | -in |
178 | | -overriddenProject |
| 147 | +in overriddenProject |
0 commit comments