-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
93 lines (80 loc) · 3.06 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
{
inputs.parts.url = "github:hercules-ci/flake-parts";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.systems.url = "github:nix-systems/x86_64-linux";
inputs.naked-shell.url = "github:yusdacra/mk-naked-shell";
outputs = inp:
inp.parts.lib.mkFlake {inputs = inp;} {
systems = import inp.systems;
imports = [
inp.naked-shell.flakeModule
];
perSystem = {
config,
system,
...
}: let
pkgs = inp.nixpkgs.legacyPackages.${system};
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
in {
devShells.default = config.mk-naked-shell.lib.mkNakedShell {
name = "gazesys-devshell";
packages = with pkgs; [
nodejs-slim_latest bun
nodePackages.svelte-language-server
nodePackages.typescript-language-server
];
shellHook = ''
export PATH="$PATH:$PWD/node_modules/.bin"
'';
};
packages.gazesys-modules = pkgs.stdenv.mkDerivation {
pname = "${packageJson.name}-modules";
version = packageJson.version;
src = ./.;
outputHash = "sha256-kP4m6ztiTcs0rMV2EjhjHjCbv3uVLbQg6SSYpU+yzIA=";
outputHashAlgo = "sha256";
outputHashMode = "recursive";
nativeBuildInputs = with pkgs; [bun];
dontConfigure = true;
impureEnvVars = pkgs.lib.fetchers.proxyImpureEnvVars
++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ];
buildPhase = "bun install --no-progress --frozen-lockfile";
installPhase = "mv node_modules $out";
};
packages.gazesys = pkgs.stdenv.mkDerivation {
pname = packageJson.name;
version = packageJson.version;
src = ./.;
nativeBuildInputs = [pkgs.makeBinaryWrapper pkgs.rsync];
buildInputs = [pkgs.bun];
PUBLIC_BASE_URL="http://localhost:5173";
GUESTBOOK_BASE_URL="http://localhost:8080";
configurePhase = ''
runHook preConfigure
cp -R --no-preserve=ownership ${config.packages.gazesys-modules} node_modules
find node_modules -type d -exec chmod 755 {} \;
substituteInPlace node_modules/.bin/vite \
--replace-fail "/usr/bin/env node" "${pkgs.nodejs-slim_latest}/bin/node"
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
bun --prefer-offline run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
ln -s ${config.packages.gazesys-modules} $out
cp -R ./build/* $out
makeBinaryWrapper ${pkgs.bun}/bin/bun $out/bin/${packageJson.name} \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.bun ]} \
--add-flags "run --bun --prefer-offline --no-install --cwd $out start"
runHook postInstall
'';
};
packages.default = config.packages.gazesys;
};
};
}