|
1 | 1 | { |
2 | | - description = ""; |
3 | | - inputs.nixpkgs.url = "nixpkgs/nixos-24.05"; |
| 2 | + description = "fw-processing — pnpm monorepo (Turbo) packaged with fetchPnpmDeps + pnpmConfigHook"; |
4 | 3 |
|
5 | | - outputs = { self, nixpkgs }: |
| 4 | + inputs.nixpkgs.url = "nixpkgs/nixos-25.11"; |
| 5 | + |
| 6 | + outputs = |
| 7 | + { self, nixpkgs }: |
6 | 8 | let |
7 | | - lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; |
8 | | - version = builtins.substring 0 8 lastModifiedDate; |
9 | 9 | supportedSystems = [ "x86_64-linux" ]; |
10 | 10 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; |
11 | | - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }); |
12 | | - pname = "fw-processing"; |
13 | | - in { |
14 | | - overlays.default = final: prev: with final; let |
15 | | - version = (lib.importJSON ./package.json).version; |
16 | | - meta_ = { |
17 | | - license = lib.licenses.mit; |
18 | | - homepage = ""; |
19 | | - maintainers = with lib.maintainers; [ j03 ]; |
20 | | - platforms = lib.platforms.linux; |
21 | | - }; |
22 | | - scope = "react-redux-yjs"; |
23 | | - in rec { |
24 | | - |
25 | | - "${pname}-${scope}-turbo" = stdenv.mkDerivation rec { |
26 | | - inherit version; |
27 | | - name = "${pname}-${scope}-turbo-${version}"; |
28 | | - src = ./.; |
29 | | - buildInputs = [turbo]; |
30 | | - buildPhase = '' |
31 | | - turbo prune --scope "${scope}" |
32 | | - ''; |
33 | | - installPhase = '' |
34 | | - cp -r out $out |
35 | | - ''; |
36 | | - meta = meta_ // {description = "Pruned turbo-repo (containing pnpm package)";}; |
37 | | - }; |
38 | | - |
39 | | - "${pname}-${scope}-yarn" = stdenv.mkDerivation rec { |
40 | | - inherit version; |
41 | | - name = "${pname}-${scope}-yarn-${version}"; |
42 | | - src = fw-processing-react-redux-yjs-turbo; |
43 | | - buildInputs = [pnpm-lock-export gnused]; |
44 | | - buildPhase = '' |
45 | | - pnpm-lock-export --schema yarn.lock@v1 |
46 | | - #sed -i 's/"workspace:\*"/"*"/g' package.json |
47 | | - #sed -i 's/"workspace:\*"/"*"/g' packages/${scope}/package.json |
48 | | - ''; |
49 | | - installPhase = '' |
50 | | - cp -r . $out |
51 | | - ''; |
52 | | - meta = meta_ // {description = "Yarn-repo (with workspaces)";}; |
53 | | - }; |
54 | | - |
55 | | - fw-processing-react-redux-yjs-nodeModules = stdenv.mkDerivation rec { |
56 | | - inherit version; |
57 | | - name = "${pname}-${scope}-nodeModules-${version}"; |
58 | | - src = #fw-processing-react-redux-yjs-turbo; |
59 | | - fw-processing-react-redux-yjs-yarn; |
60 | | - buildInputs = [nodePackages.pnpm yarn nodejs cacert]; |
61 | | - SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; |
62 | | - NODE_EXTRA_CA_CERTS = "${cacert}/etc/ssl/certs/ca-bundle.crt"; |
63 | | - buildPhase = '' |
64 | | - export HOME=$(mktemp -d) |
65 | | -
|
66 | | - pnpm install |
67 | | -
|
68 | | - #yarn --ignore-scripts |
69 | | - #( cd packages/${scope} |
70 | | - # yarn |
71 | | - #) |
72 | | - ''; |
73 | | - installPhase = '' |
74 | | - cp -r . $out |
75 | | - ''; |
76 | | - meta = meta_ // {description = "";}; |
77 | | - outputHashMode = "recursive"; |
78 | | - outputHash = "sha256-0SHp1rV06Yg6WE8MySAMwqWaxRTC0wa6uIHozmVFV1M="; |
79 | | - #outputHash = (lib.importJSON ./flake.hashes.json).react-redux-yjs; |
80 | | - __structuredAttrs = true; |
81 | | - outputChecks.out.allowedReferences = [ bash nodejs ]; |
82 | | - unsafeDiscardReferences.out = true; |
83 | | - #__contentAddressed = true; |
84 | | - }; |
85 | | - |
86 | | - "${pname}-${scope}-nodePackage" = stdenv.mkDerivation rec { |
87 | | - inherit version; |
88 | | - name = "${pname}-${scope}-nodePackage-${version}"; |
89 | | - src = fw-processing-react-redux-yjs-yarn; |
90 | | - buildInputs = [yarn] ++ [fw-processing-react-redux-yjs-nodeModules] ++ [nodejs]; |
91 | | - buildPhase = '' |
92 | | - ln -s ${fw-processing-react-redux-yjs-nodeModules}/node_modules . |
93 | | - cp ${fw-processing-react-redux-yjs-nodeModules}/yarn.lock . || true |
94 | | -
|
95 | | - ln -s ${fw-processing-react-redux-yjs-nodeModules}/packages/${scope}/node_modules packages/${scope} |
96 | | - cp ${fw-processing-react-redux-yjs-nodeModules}/packages/${scope}/yarn.lock packages/${scope} || true |
97 | | - ''; |
98 | | - installPhase = '' |
99 | | - cp -r . $out |
100 | | - ''; |
101 | | - meta = meta_ // {description = "";}; |
102 | | - }; |
103 | | - |
104 | | - "${pname}" = fw-processing-react-redux-yjs-nodePackage; |
105 | | - |
106 | | - "${pname}-dev" = pkgs.mkShell { |
107 | | - nativeBuildInputs = with pkgs; [ yarn nodejs ]; |
108 | | - shellHook = '' |
109 | | - export HOME=$(mktemp -d) |
110 | | - ls -l ${fw-processing-react-redux-yjs-nodeModules} ~/nodePackage |
111 | | - #cp -rL ${fw-processing-react-redux-yjs-nodePackage} ~/nodePackage |
112 | | - chmod -R +w ~/ |
113 | | - cd ~/nodePackage |
114 | | -
|
115 | | - ( cd packages/react-redux-yjs/node_modules |
116 | | - #rm -r eslint-config-custom style tsconfig |
117 | | - #ln -s ../../eslint-config-custom . |
118 | | - #ln -s ../../react-redux-yjs . |
119 | | - #ln -s ../../style . |
120 | | - #ln -s ../../tsconfig . |
121 | | - ) |
122 | | -
|
123 | | - #rm -r node_modules/turbo |
124 | | - yes | pnpm install ## TODO |
125 | | - pnpm --offline --frozen-lockfile install |
126 | | - pnpm --offline build |
127 | | -
|
128 | | - #yarn --offline install |
129 | | - #rm -r node_modules/turbo |
130 | | - #pnpm install |
131 | | - ##yarn --offline build |
132 | | - ''; |
133 | | - }; |
134 | | - }; |
135 | | - packages = forAllSystems (system: let p = nixpkgsFor.${system}; in { |
136 | | - inherit (p) fw-processing-react-redux-yjs-turbo fw-processing-react-redux-yjs-yarn fw-processing-react-redux-yjs-nodeModules fw-processing-react-redux-yjs-nodePackage fw-processing fw-processing-dev; |
137 | | - default = p.${pname}; |
138 | | - }); |
139 | | - devShells = forAllSystems (system: { |
140 | | - default = self.packages.${system}.fw-processing-dev; |
141 | | - }); |
| 11 | + in |
| 12 | + { |
| 13 | + packages = forAllSystems ( |
| 14 | + system: |
| 15 | + let |
| 16 | + pkgs = import nixpkgs { inherit system; }; |
| 17 | + inherit (pkgs) |
| 18 | + lib |
| 19 | + stdenv |
| 20 | + fetchPnpmDeps |
| 21 | + pnpmConfigHook |
| 22 | + pnpm_10 |
| 23 | + nodejs_20 |
| 24 | + turbo |
| 25 | + jq |
| 26 | + ; |
| 27 | + |
| 28 | + pname = "fw-processing"; |
| 29 | + version = (lib.importJSON ./package.json).version; |
| 30 | + src = lib.cleanSource ./.; |
| 31 | + |
| 32 | + meta = { |
| 33 | + description = "Form processing / React–Redux–Yjs workspace"; |
| 34 | + license = lib.licenses.mit; |
| 35 | + maintainers = with lib.maintainers; [ j03 ]; |
| 36 | + platforms = lib.platforms.linux; |
| 37 | + }; |
| 38 | + |
| 39 | + scope = "react-redux-yjs"; |
| 40 | + |
| 41 | + # |
| 42 | + # Pruned subset (Turbo) — same role as the old *-turbo package. |
| 43 | + # |
| 44 | + fw-processing-react-redux-yjs-turbo = stdenv.mkDerivation { |
| 45 | + name = "${pname}-${scope}-turbo-${version}"; |
| 46 | + inherit src version; |
| 47 | + pname = "${pname}-${scope}-turbo"; |
| 48 | + |
| 49 | + nativeBuildInputs = [ turbo ]; |
| 50 | + |
| 51 | + dontConfigure = true; |
| 52 | + |
| 53 | + buildPhase = '' |
| 54 | + runHook preBuild |
| 55 | + turbo prune --scope "${scope}" |
| 56 | + runHook postBuild |
| 57 | + ''; |
| 58 | + |
| 59 | + installPhase = '' |
| 60 | + runHook preInstall |
| 61 | + mv out $out |
| 62 | + runHook postInstall |
| 63 | + ''; |
| 64 | + |
| 65 | + meta = meta // { |
| 66 | + description = "Turbo-pruned workspace subset (pnpm workspace, lockfile inside)"; |
| 67 | + }; |
| 68 | + }; |
| 69 | + |
| 70 | + # |
| 71 | + # Fixed-output pnpm dependency store (replaces the old ad-hoc nodeModules FOD). |
| 72 | + # |
| 73 | + pnpmDeps = |
| 74 | + fetchPnpmDeps { |
| 75 | + inherit pname version src; |
| 76 | + pnpm = pnpm_10; |
| 77 | + fetcherVersion = 3; |
| 78 | + hash = "sha256-KzsmNg2hNKx5ePNrM9SBi0gkA2m+s4IQnJvXNx6rlDg="; |
| 79 | + }; |
| 80 | + |
| 81 | + # |
| 82 | + # Full install + Turbo build for the scoped package (replaces yarn + manual symlinks). |
| 83 | + # |
| 84 | + fw-processing = stdenv.mkDerivation { |
| 85 | + name = "${pname}-${version}"; |
| 86 | + inherit pname version src pnpmDeps; |
| 87 | + |
| 88 | + nativeBuildInputs = [ |
| 89 | + nodejs_20 |
| 90 | + pnpmConfigHook |
| 91 | + pnpm_10 |
| 92 | + jq |
| 93 | + ]; |
| 94 | + |
| 95 | + # Avoid pnpm trying to download the exact `packageManager` pin (no network in sandbox). |
| 96 | + patchPhase = '' |
| 97 | + runHook prePatch |
| 98 | + jq 'del(.packageManager)' package.json > package.json.tmp |
| 99 | + mv package.json.tmp package.json |
| 100 | + runHook postPatch |
| 101 | + ''; |
| 102 | + |
| 103 | + # pnpm expects a writable HOME for its metadata cache. |
| 104 | + preBuild = '' |
| 105 | + export HOME="$TMPDIR" |
| 106 | + ''; |
| 107 | + |
| 108 | + buildPhase = '' |
| 109 | + runHook preBuild |
| 110 | + pnpm --filter "${scope}" run build |
| 111 | + runHook postBuild |
| 112 | + ''; |
| 113 | + |
| 114 | + installPhase = '' |
| 115 | + runHook preInstall |
| 116 | + mkdir -p "$out/lib/${pname}" |
| 117 | + cp -r packages/${scope}/dist "$out/lib/${pname}/" |
| 118 | + cp packages/${scope}/package.json "$out/lib/${pname}/" |
| 119 | + runHook postInstall |
| 120 | + ''; |
| 121 | + |
| 122 | + passthru = { |
| 123 | + inherit pnpmDeps fw-processing-react-redux-yjs-turbo; |
| 124 | + }; |
| 125 | + |
| 126 | + meta = meta // { |
| 127 | + description = "Built ${scope} package (dist + package.json)"; |
| 128 | + }; |
| 129 | + }; |
| 130 | + in |
| 131 | + { |
| 132 | + inherit fw-processing fw-processing-react-redux-yjs-turbo; |
| 133 | + |
| 134 | + # Back-compat names from the old flake (Yarn path removed). |
| 135 | + fw-processing-react-redux-yjs-nodeModules = pnpmDeps; |
| 136 | + fw-processing-react-redux-yjs-nodePackage = fw-processing; |
| 137 | + |
| 138 | + default = fw-processing; |
| 139 | + } |
| 140 | + ); |
| 141 | + |
| 142 | + devShells = forAllSystems ( |
| 143 | + system: |
| 144 | + let |
| 145 | + pkgs = import nixpkgs { inherit system; }; |
| 146 | + in |
| 147 | + { |
| 148 | + default = pkgs.mkShellNoCC { |
| 149 | + packages = with pkgs; [ |
| 150 | + nodejs_20 |
| 151 | + pnpm_10 |
| 152 | + turbo |
| 153 | + ]; |
| 154 | + shellHook = '' |
| 155 | + echo "fw-processing dev: use «pnpm install» then «pnpm run build» / «pnpm run dev»." |
| 156 | + ''; |
| 157 | + }; |
| 158 | + } |
| 159 | + ); |
142 | 160 | }; |
143 | 161 | } |
0 commit comments