Coarse versions for constituent packages

As discussed in our meeting, we should use a simplified version for the
libraries without the date or commit hash. This will make rebuilding a
lot faster in many cases.

Progress on #10379

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
This commit is contained in:
John Ericson 2024-08-13 16:15:56 -04:00
parent 4956e7c44c
commit 93f58150c9
5 changed files with 47 additions and 22 deletions

View file

@ -26,12 +26,6 @@
officialRelease = false; officialRelease = false;
version = lib.fileContents ./.version + versionSuffix;
versionSuffix =
if officialRelease
then ""
else "pre${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}_${self.shortRev or "dirty"}";
linux32BitSystems = [ "i686-linux" ]; linux32BitSystems = [ "i686-linux" ];
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ]; linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ];
linuxSystems = linux32BitSystems ++ linux64BitSystems; linuxSystems = linux32BitSystems ++ linux64BitSystems;
@ -130,12 +124,16 @@
# without "polluting" the top level "`pkgs`" attrset. # without "polluting" the top level "`pkgs`" attrset.
# This also has the benefit of providing us with a distinct set of packages # This also has the benefit of providing us with a distinct set of packages
# we can iterate over. # we can iterate over.
nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix); nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix {
inherit (final) lib;
inherit officialRelease;
src = self;
});
# The dependencies are in their own scope, so that they don't have to be # The dependencies are in their own scope, so that they don't have to be
# in Nixpkgs top level `pkgs` or `nixComponents`. # in Nixpkgs top level `pkgs` or `nixComponents`.
nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix { nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix {
inherit inputs stdenv versionSuffix; inherit inputs stdenv;
pkgs = final; pkgs = final;
}); });
@ -170,6 +168,7 @@
linux64BitSystems linux64BitSystems
nixpkgsFor nixpkgsFor
self self
officialRelease
; ;
}; };
@ -253,10 +252,10 @@
dockerImage = dockerImage =
let let
pkgs = nixpkgsFor.${system}.native; pkgs = nixpkgsFor.${system}.native;
image = import ./docker.nix { inherit pkgs; tag = version; }; image = import ./docker.nix { inherit pkgs; tag = pkgs.nix.version; };
in in
pkgs.runCommand pkgs.runCommand
"docker-image-tarball-${version}" "docker-image-tarball-${pkgs.nix.version}"
{ meta.description = "Docker image with Nix for ${system}"; } { meta.description = "Docker image with Nix for ${system}"; }
'' ''
mkdir -p $out/nix-support mkdir -p $out/nix-support

View file

@ -47,7 +47,8 @@
, pname ? "nix" , pname ? "nix"
, versionSuffix ? "" , version
, versionSuffix
# Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix # Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix
, doBuild ? true , doBuild ? true
@ -112,8 +113,6 @@
let let
inherit (lib) fileset; inherit (lib) fileset;
version = lib.fileContents ./.version + versionSuffix;
# selected attributes with defaults, will be used to define some # selected attributes with defaults, will be used to define some
# things which should instead be gotten via `finalAttrs` in order to # things which should instead be gotten via `finalAttrs` in order to
# work with overriding. # work with overriding.

View file

@ -1,11 +1,34 @@
{
lib,
src,
officialRelease,
}:
scope: scope:
let let
inherit (scope) callPackage; inherit (scope) callPackage;
baseVersion = lib.fileContents ../.version;
versionSuffix = lib.optionalString (!officialRelease) "pre";
fineVersionSuffix = lib.optionalString
(!officialRelease)
"pre${builtins.substring 0 8 (src.lastModifiedDate or src.lastModified or "19700101")}_${src.shortRev or "dirty"}";
fineVersion = baseVersion + fineVersionSuffix;
in in
# This becomes the pkgs.nixComponents attribute set # This becomes the pkgs.nixComponents attribute set
{ {
nix = callPackage ../package.nix { }; version = baseVersion + versionSuffix;
inherit versionSuffix;
nix = callPackage ../package.nix {
version = fineVersion;
versionSuffix = fineVersionSuffix;
};
nix-util = callPackage ../src/libutil/package.nix { }; nix-util = callPackage ../src/libutil/package.nix { };
nix-util-c = callPackage ../src/libutil-c/package.nix { }; nix-util-c = callPackage ../src/libutil-c/package.nix { };
@ -34,10 +57,10 @@ in
nix-cmd = callPackage ../src/libcmd/package.nix { }; nix-cmd = callPackage ../src/libcmd/package.nix { };
# Will replace `nix` once the old build system is gone. # Will replace `nix` once the old build system is gone.
nix-ng = callPackage ../src/nix/package.nix { }; nix-ng = callPackage ../src/nix/package.nix { version = fineVersion; };
nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { }; nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { version = fineVersion; };
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { }; nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { version = fineVersion; };
nix-perl-bindings = callPackage ../src/perl/package.nix { }; nix-perl-bindings = callPackage ../src/perl/package.nix { };
} }

View file

@ -8,7 +8,6 @@
pkgs, pkgs,
stdenv, stdenv,
versionSuffix,
}: }:
let let
@ -73,11 +72,9 @@ let
strictDeps = prevAttrs.strictDeps or true; strictDeps = prevAttrs.strictDeps or true;
enableParallelBuilding = true; enableParallelBuilding = true;
}; };
in in
scope: { scope: {
inherit stdenv versionSuffix; inherit stdenv;
version = lib.fileContents ../.version + versionSuffix;
aws-sdk-cpp = (pkgs.aws-sdk-cpp.override { aws-sdk-cpp = (pkgs.aws-sdk-cpp.override {
apis = [ "s3" "transfer" ]; apis = [ "s3" "transfer" ];

View file

@ -6,6 +6,7 @@
, linux64BitSystems , linux64BitSystems
, nixpkgsFor , nixpkgsFor
, self , self
, officialRelease
}: }:
let let
inherit (inputs) nixpkgs nixpkgs-regression; inherit (inputs) nixpkgs nixpkgs-regression;
@ -16,7 +17,7 @@ let
}; };
testNixVersions = pkgs: client: daemon: testNixVersions = pkgs: client: daemon:
pkgs.callPackage ../package.nix { pkgs.nixComponents.callPackage ../package.nix {
pname = pname =
"nix-tests" "nix-tests"
+ lib.optionalString + lib.optionalString
@ -28,6 +29,12 @@ let
test-daemon = daemon; test-daemon = daemon;
doBuild = false; doBuild = false;
# This could be more accurate, but a shorter version will match the
# fine version with rev. This functionality is already covered in
# the normal test, so it's fine.
version = pkgs.nixComponents.version;
versionSuffix = pkgs.nixComponents.versionSuffix;
}; };
# Technically we could just return `pkgs.nixComponents`, but for Hydra it's # Technically we could just return `pkgs.nixComponents`, but for Hydra it's