forked from Panfactum/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
63 lines (47 loc) · 1.25 KB
/
Copy pathdefault.nix
File metadata and controls
63 lines (47 loc) · 1.25 KB
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
{ pkgs, bun2nix, ... }:
let
bunDeps = pkgs.callPackage ./bun.nix { };
packageJson = (builtins.fromJSON (builtins.readFile ./package.json));
in
pkgs.stdenv.mkDerivation {
name = packageJson.name;
version = packageJson.version;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = with pkgs; [
rsync
bun
jq
];
phases = [
"unpackPhase"
"loadModulesPhase"
"buildPhase"
"installPhase"
];
# Load node_modules based on the expression generated from the lockfile
loadModulesPhase = ''
runHook preLoadModules
# Preserve symlinks in .bin
rsync -a --copy-links --chmod=ugo+w --exclude=".bin" ${bunDeps.nodeModules}/node_modules/ ./node_modules/
if [ -d "${bunDeps.nodeModules}/node_modules/.bin" ]; then
rsync -a --links ${bunDeps.nodeModules}/node_modules/.bin/ ./node_modules/.bin/
fi
mkdir tmp
export HOME=$TMPDIR
runHook postLoadModules
'';
buildPhase = ''
runHook preBuild
bun build:binary
runHook postBuild
'';
# Install the binary to the output folder
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp ./bin/pf $out/bin/pf
runHook postInstall
'';
# Bun binaries are broken by fixup phase
dontFixup = true;
}