-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
70 lines (54 loc) · 1.83 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
{
description = "SAST Link Frontend Nix Dev Env";
inputs = {
nixpkgs.url = "nixpkgs";
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = import ./shell.nix { inherit pkgs; };
packages.default = pkgs.buildNpmPackage rec {
pname = "sast-link"; # <same as package.json name>
version = "0.1.0";
buildInputs = with pkgs; [
nodePackages.node-gyp-build
];
npmDepsHash = "sha256-8x/IcpOSgrZG4fXX+o/wtXx7tr7EBIfOVg/O2TM3Jxo="; # <prefetch-npm-deps package-lock.json>
# see ./next.config.mjs
env.OUTPUT_STANDALONE = true;
src = ./.;
postBuild = ''
# Add a shebang to the server js file, then patch the shebang.
sed -i '1s|^|#!/usr/bin/env node\n|' .next/standalone/server.js
patchShebangs .next/standalone/server.js
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{share,bin}
cp -r .next/standalone $out/share/${pname}/
cp -r public $out/share/${pname}/public
mkdir -p $out/share/${pname}/.next
cp -r .next/static $out/share/${pname}/.next/static
chmod +x $out/share/${pname}/server.js
makeWrapper $out/share/${pname}/server.js $out/bin/${pname} \
--set-default PORT 3000
runHook postInstall
'';
};
packages.sast-link-docker = pkgs.dockerTools.buildImage {
name = "sast-link-frontend";
config = {
Entrypoint = [ "${self.packages.${system}.default}/bin/sast-link" ];
};
};
});
}