feat(nix): set VERGEN_* build env vars (#1375)

This commit is contained in:
uncenter 2024-07-31 14:39:47 -04:00 committed by GitHub
parent 4257b95e8d
commit bb29e238b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View file

@ -27,15 +27,13 @@
(system:
let
pkgs = import nixpkgs { inherit system overlays; };
versionSuffix = "pre${
builtins.substring 0 8
(self.lastModifiedDate or self.lastModified or "19700101")
}_${self.shortRev or "dirty"}";
rev = self.shortRev or "dirty";
date = (self.lastModifiedDate or self.lastModified or "19700101");
version = (builtins.fromTOML
(builtins.readFile ./yazi-fm/Cargo.toml)).package.version
+ versionSuffix;
+ "pre${builtins.substring 0 8 date}_${rev}";
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version; };
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
in
{

View file

@ -1,6 +1,8 @@
{ makeRustPlatform
, rustToolchain
, version ? "git"
, rev
, date
, lib
, installShellFiles
@ -12,7 +14,7 @@
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec {
pname = "yazi";
inherit version;
inherit version rev;
src = ../.;
@ -24,6 +26,8 @@
};
env.YAZI_GEN_COMPLETIONS = true;
env.VERGEN_GIT_SHA = rev;
env.VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
nativeBuildInputs = [ installShellFiles imagemagick ];
buildInputs = lib.optionals stdenv.isDarwin (