From 651f145c190e9cd1991677404c6485f94f91570b Mon Sep 17 00:00:00 2001 From: Philipp Mandler Date: Sat, 16 Dec 2023 15:51:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Pass=20git=20infos=20in=20nix=20?= =?UTF-8?q?derivation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nix/pkgs/frontend.nix | 28 +++++++++++++++++++++------- shell.nix | 3 +++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/nix/pkgs/frontend.nix b/nix/pkgs/frontend.nix index 3a1590c0..204e2bb7 100644 --- a/nix/pkgs/frontend.nix +++ b/nix/pkgs/frontend.nix @@ -1,4 +1,7 @@ -{ pkgs, stdenv }: +{ pkgs +, stdenv +, versionInfo ? { } +}: let common = import ../common.nix; package = builtins.fromJSON (builtins.readFile ../../frontend/package.json); @@ -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/ + ''; } diff --git a/shell.nix b/shell.nix index 23af98df..fd11cefe 100644 --- a/shell.nix +++ b/shell.nix @@ -36,6 +36,9 @@ pkgs.mkShell { nodePackages.pnpm + # nix tooling + nixpkgs-fmt + # required by whispercppy cmake