-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
91 lines (73 loc) · 2.17 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
{
description = "Nix development shell for bun";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
nixpkgs,
gitignore,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
version = "1.1.3";
node_modules = pkgs.mkYarnModules {
pname = "bun-image-transform-node_modules";
inherit version;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
};
in {
packages = {
default = pkgs.stdenv.mkDerivation {
pname = "bun-image-transform";
inherit version;
src = gitignore.lib.gitignoreSource ./.;
nativeBuildInputs = [pkgs.makeBinaryWrapper];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
ln -s ${node_modules}/node_modules $out
${pkgs.bun}/bin/bun run ./build.ts
cp -R ./dist/* $out
# bun is referenced naked in the package.json generated script
makeBinaryWrapper ${pkgs.bun}/bin/bun $out/bin/bun-image-transform \
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.bun]} \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath [pkgs.vips pkgs.stdenv.cc.cc]} \
--add-flags "run --prefer-offline --no-install $out/cli.js"
runHook postInstall
'';
};
};
devShell = let
FHSBun =
pkgs.buildFHSEnv
{
name = "bun";
targetPkgs = pkgs: [
pkgs.bun
];
runScript = "${pkgs.bun}/bin/bun";
};
in
pkgs.mkShell {
shellHook = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [pkgs.vips pkgs.stdenv.cc.cc]}
'';
packages = [
FHSBun
];
};
});
}