-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
140 lines (127 loc) · 5.28 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
description = "";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = builtins.substring 0 8 lastModifiedDate;
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
pname = "fw-processing";
in {
overlay = final: prev: with final; let
version = (lib.importJSON ./package.json).version;
meta_ = {
license = lib.licenses.mit;
homepage = "";
maintainers = with lib.maintainers; [ j03 ];
platforms = lib.platforms.linux;
};
scope = "react-redux-yjs";
in rec {
"${pname}-${scope}-turbo" = stdenv.mkDerivation rec {
inherit version;
name = "${pname}-${scope}-turbo-${version}";
src = ./.;
buildInputs = [turbo];
buildPhase = ''
turbo prune --scope "${scope}"
'';
installPhase = ''
cp -r out $out
'';
meta = meta_ // {description = "Pruned turbo-repo (containing pnpm package)";};
};
"${pname}-${scope}-yarn" = stdenv.mkDerivation rec {
inherit version;
name = "${pname}-${scope}-yarn-${version}";
src = fw-processing-react-redux-yjs-turbo;
buildInputs = [pnpm-lock-export gnused];
buildPhase = ''
pnpm-lock-export --schema yarn.lock@v1
#sed -i 's/"workspace:\*"/"*"/g' package.json
#sed -i 's/"workspace:\*"/"*"/g' packages/${scope}/package.json
'';
installPhase = ''
cp -r . $out
'';
meta = meta_ // {description = "Yarn-repo (with workspaces)";};
};
fw-processing-react-redux-yjs-nodeModules = stdenv.mkDerivation rec {
inherit version;
name = "${pname}-${scope}-nodeModules-${version}";
src = #fw-processing-react-redux-yjs-turbo;
fw-processing-react-redux-yjs-yarn;
buildInputs = [nodePackages.pnpm yarn nodejs];
buildPhase = ''
export HOME=$(mktemp -d)
pnpm install
#yarn --ignore-scripts
#( cd packages/${scope}
# yarn
#)
'';
installPhase = ''
cp -r . $out
'';
meta = meta_ // {description = "";};
outputHashMode = "recursive";
#outputHash = lib.fakeHash;
outputHash = "sha256-y4B0+4W6Ng8Nb/SqdiihByojBvLDqfgs/Cvi7oU5ERM=";
#outputHash = (lib.importJSON ./flake.hashes.json).react-redux-yjs;
allowedReferences = [bash nodejs];
__structuredAttrs = true;
unsafeDiscardReferences.out = true;
#__contentAddressed = true;
};
"${pname}-${scope}-nodePackage" = stdenv.mkDerivation rec {
inherit version;
name = "${pname}-${scope}-nodePackage-${version}";
src = fw-processing-react-redux-yjs-yarn;
buildInputs = [yarn] ++ [fw-processing-react-redux-yjs-nodeModules] ++ [nodejs];
buildPhase = ''
ln -s ${fw-processing-react-redux-yjs-nodeModules}/node_modules .
cp ${fw-processing-react-redux-yjs-nodeModules}/yarn.lock . || true
ln -s ${fw-processing-react-redux-yjs-nodeModules}/packages/${scope}/node_modules packages/${scope}
cp ${fw-processing-react-redux-yjs-nodeModules}/packages/${scope}/yarn.lock packages/${scope} || true
'';
installPhase = ''
cp -r . $out
'';
meta = meta_ // {description = "";};
};
"${pname}" = fw-processing-react-redux-yjs-nodePackage;
"${pname}-dev" = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ yarn nodejs ];
shellHook = ''
export HOME=$(mktemp -d)
ls -l ${fw-processing-react-redux-yjs-nodeModules} ~/nodePackage
#cp -rL ${fw-processing-react-redux-yjs-nodePackage} ~/nodePackage
chmod -R +w ~/
cd ~/nodePackage
( cd packages/react-redux-yjs/node_modules
#rm -r eslint-config-custom style tsconfig
#ln -s ../../eslint-config-custom .
#ln -s ../../react-redux-yjs .
#ln -s ../../style .
#ln -s ../../tsconfig .
)
#rm -r node_modules/turbo
yes | pnpm install ## TODO
pnpm --offline --frozen-lockfile install
pnpm --offline build
#yarn --offline install
#rm -r node_modules/turbo
#pnpm install
##yarn --offline build
'';
};
};
packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) 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;
});
defaultPackage = forAllSystems (system: self.packages.${system}."${pname}");
devShell = forAllSystems (system: self.packages.${system}."${pname}-dev");
};
}