Skip to content

Commit

Permalink
feat: add initial nix build and develop support (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
aimixsaka authored Jul 24, 2024
1 parent 7d478e9 commit 57fb73c
Show file tree
Hide file tree
Showing 3 changed files with 12,007 additions and 0 deletions.
62 changes: 62 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
description = "SAST Link Frontend Nix Dev Env";

inputs = {
nixpkgs.url = "nixpkgs";
flake-utils = {
url = "github:numtide/flake-utils";
};
};

outputs = {
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-IlUPLmW18JPyGcY6EWnX2tdLlHTEi4aTk5iipw4H7Gs="; # <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
'';
};
});
}
Loading

0 comments on commit 57fb73c

Please sign in to comment.