forked from RCMast3r/data_acq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.nix
45 lines (41 loc) · 1.38 KB
/
frontend.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
{ pkgs, stdenv, system, callPackage, nodejs, nodePackages, writeShellScriptBin }:
let
# Import & invoke the generated files from node2nix
generated = callPackage ./frontend/nix { inherit pkgs system nodejs; };
# node2nix wrapper to update nix files on npm changes
node2nix = writeShellScriptBin "node2nix" ''
${nodePackages.node2nix}/bin/node2nix \
--development \
-l package-lock.json \
-c ./frontend/nix/default.nix \
-o ./frontend/nix/node-packages.nix \
-e ./frontend/nix/node-env.nix
'';
in
{
inherit (generated) nodeDependencies;
frontend = pkgs.stdenv.mkDerivation
{
name = "frontend";
version = "0.1.0";
src = ./frontend; #gitignore.lib.gitignoreSource ./.; # uses the gitignore in the repo to only copy files git would see
buildInputs = [ pkgs.nodejs ];
buildPhase = ''
export HOME=$TMP
ln -s ${generated.nodeDependencies}/lib/node_modules ./node_modules
export PATH="${generated.nodeDependencies}/bin:$PATH"
npm run build
'';
installPhase = ''
ls
mkdir -p $out/build
cp tailwind.config.js $out/
cp tsconfig.json $out/
cp -r public $out/
cp -r src $out/
cp -r build $out/
cp package.json $out/
ln -sf ${generated.nodeDependencies}/lib/node_modules $out/node_modules
'';
};
}