nidus-sync/default.nix
Eli Ribble 496b9b34bc
Use commit time not build time
Can't use build time in pure evaluation mode.
2026-05-19 15:03:09 +00:00

77 lines
1.9 KiB
Nix

{ pkgs ? import <nixpkgs> { }, proj ? pkgs.proj }:
let
# Get commit timestamp at eval time (pure)
getCommitTime =
if builtins.pathExists ./.git
then builtins.replaceStrings ["\n"] [""] (builtins.readFile (
pkgs.runCommand "git-commit-time" {} ''
${pkgs.git}/bin/git -C ${./.} log -1 --format=%ct > $out
''
))
else "0";
in
pkgs.buildGoModule rec {
pname = "nidus-sync";
version = "0.0.12";
src = ./.;
gitRevision =
if builtins.pathExists ./.git
then pkgs.lib.commitIdFromGitRepo ./.git
else "unknown";
buildTime = getCommitTime;
ldflags = [
"-s"
"-w"
"-X main.Version=${version}"
"-X main.Commit=${gitRevision}"
"-X main.BuildTime=${buildTime}"
];
meta = {
description = "Nidus Sync";
homepage = "https://github.com/Gleipnir-Technology/nidus-sync";
};
subPackages = [];
vendorHash = "sha256-jlPS8lWdNPj60BMUcCrxteLuc7RXEXDtzlwjsFBJg0Y=";
buildInputs = [ pkgs.proj ];
nativeBuildInputs = [
pkgs.pkg-config
pkgs.nodejs
pkgs.pnpm.configHook
];
# Fix: Filter out pnpm.configHook instead of replacing the whole list
overrideModAttrs = old: {
nativeBuildInputs = builtins.filter
(pkg: pkg != pkgs.pnpm.configHook && pkg != pkgs.nodejs)
old.nativeBuildInputs;
preBuild = "";
};
pnpmDeps = pkgs.pnpm.fetchDeps {
inherit pname src version;
fetcherVersion = 2;
hash = "sha256-4XPkwVKSuDlErKfD59iBPHLuf44iRkjEcS6tIityCjo=";
};
preBuild = ''
pnpm install --offline --frozen-lockfile --ignore-scripts
mkdir -p "./ts/gen"
pnpm generate-icons
pnpm build-rmo
pnpm build-sync
'';
postInstall = ''
# Copy frontend build output to artifacts so we can upload them to sentry
mkdir -p $out/share/frontend/
cp -r vite/rmo/static/gen/rmo $out/share/frontend/
cp -r vite/rmo/static/gen/sync $out/share/frontend/
'';
}