Skip to content

Commit

Permalink
nix: improve package versioning, fix metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Sep 7, 2024
1 parent f6b6300 commit 44ad60b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 65 deletions.
63 changes: 0 additions & 63 deletions nix/derivation.nix

This file was deleted.

15 changes: 13 additions & 2 deletions nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
enableLTO ? true,
enableOptimizeSize ? false,
}:
let
year = builtins.substring 0 4 self.lastModifiedDate;
month = builtins.substring 4 2 self.lastModifiedDate;
day = builtins.substring 6 2 self.lastModifiedDate;

formattedDate = "${year}-${month}-${day}";
in
rustPlatform.buildRustPackage rec {
pname = passthru.cargoToml.package.name;
inherit (passthru.cargoToml.package) version;
version = passthru.cargoToml.package.version + "-unstable-" + formattedDate;

strictDeps = true;

Expand Down Expand Up @@ -40,7 +47,11 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = lib.optionals stdenv.isDarwin [ pkg-config ];

env =
lib.optionalAttrs enableLTO {
{
METADATA_LAST_MODIFIED = self.lastModified;
METADATA_GIT_REV = self.dirtyRev or self.rev;
}
// lib.optionalAttrs enableLTO {
CARGO_PROFILE_RELEASE_LTO = "fat";
CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1";
}
Expand Down

0 comments on commit 44ad60b

Please sign in to comment.