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: (system:
let let
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs { inherit system overlays; };
versionSuffix = "pre${ rev = self.shortRev or "dirty";
builtins.substring 0 8 date = (self.lastModifiedDate or self.lastModified or "19700101");
(self.lastModifiedDate or self.lastModified or "19700101")
}_${self.shortRev or "dirty"}";
version = (builtins.fromTOML version = (builtins.fromTOML
(builtins.readFile ./yazi-fm/Cargo.toml)).package.version (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; }; yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
in in
{ {

View file

@ -1,6 +1,8 @@
{ makeRustPlatform { makeRustPlatform
, rustToolchain , rustToolchain
, version ? "git" , version ? "git"
, rev
, date
, lib , lib
, installShellFiles , installShellFiles
@ -12,7 +14,7 @@
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec { (makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec {
pname = "yazi"; pname = "yazi";
inherit version; inherit version rev;
src = ../.; src = ../.;
@ -24,6 +26,8 @@
}; };
env.YAZI_GEN_COMPLETIONS = true; 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 ]; nativeBuildInputs = [ installShellFiles imagemagick ];
buildInputs = lib.optionals stdenv.isDarwin ( buildInputs = lib.optionals stdenv.isDarwin (