Skip to content

Commit

Permalink
🚸 Pass git infos in nix derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
phlmn committed Dec 17, 2023
1 parent 42e2b4a commit 651f145
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions nix/pkgs/frontend.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ pkgs, stdenv }:
{ pkgs
, stdenv
, versionInfo ? { }
}:
let
common = import ../common.nix;
package = builtins.fromJSON (builtins.readFile ../../frontend/package.json);
Expand All @@ -16,11 +19,22 @@ stdenv.mkDerivation {
cd frontend/
'';

installPhase = ''
pnpm install --frozen-lockfile
pnpm build

mkdir -p $out
cp -r dist/* dist/.* $out/
'';
installPhase =
let
versionExports = ([ ]
++ (lib.optional versionInfo.commitHash "export COMMIT_HASH=\"${versionInfo.commitHash}\"")
++ (lib.optional versionInfo.commitDate "export COMMIT_DATE=\"${versionInfo.commitDate}\"")
++ (lib.optional versionInfo.commitUrl "export COMMIT_URL=\"${versionInfo.commitUrl}\"")
);
in
''
pnpm install --frozen-lockfile
${lib.concatStringsSep "\n" versionExports}
pnpm build
mkdir -p $out
cp -r dist/* dist/.* $out/
'';
}
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pkgs.mkShell {

nodePackages.pnpm

# nix tooling
nixpkgs-fmt

# required by whispercppy
cmake

Expand Down

0 comments on commit 651f145

Please sign in to comment.