Merge branch 'nixpkgs-git-revision-fix'
Addresses #17218 in a better way in that it doesn't create a ".git-revision" file on every nixos-rebuild, because we already have ".git" available. Even if we don't nixos-rebuild can't create the "git-revision" file. Tested via: nix-build -E '(import ./nixos/tests/make-test.nix { name = "foo"; machine = {}; testScript = "startAll; $machine->execute(\"nixos-version >&2\");"; })' Closes: #17610 Acked-by: @bennofs
This commit is contained in:
commit
f8fad62c8e
@ -17,6 +17,6 @@ getVersion() {
|
||||
if nixpkgs=$(nix-instantiate --find-file nixpkgs "$@"); then
|
||||
getVersion $nixpkgs
|
||||
if [ -n "$rev" ]; then
|
||||
echo "$rev"
|
||||
echo ".git.$rev"
|
||||
fi
|
||||
fi
|
@ -311,10 +311,9 @@ fi
|
||||
# nixos-version shows something useful).
|
||||
if [ -n "$canRun" ]; then
|
||||
if nixpkgs=$(nix-instantiate --find-file nixpkgs "${extraBuildFlags[@]}"); then
|
||||
revision=$($SHELL $nixpkgs/nixos/modules/installer/tools/get-git-revision "${extraBuildFlags[@]}" || true)
|
||||
if [ -n "$revision" ]; then
|
||||
echo -n ".git.$revision" > "$nixpkgs/.version-suffix" || true
|
||||
echo -n "$revision" > "$nixpkgs/.git-revision" || true
|
||||
suffix=$($SHELL $nixpkgs/nixos/modules/installer/tools/get-version-suffix "${extraBuildFlags[@]}" || true)
|
||||
if [ -n "$suffix" ]; then
|
||||
echo -n "$suffix" > "$nixpkgs/.version-suffix" || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -63,7 +63,9 @@ in
|
||||
nixosRevision = mkOption {
|
||||
internal = true;
|
||||
type = types.str;
|
||||
default = if pathExists revisionFile then fileContents revisionFile else "master";
|
||||
default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo
|
||||
else if pathExists revisionFile then fileContents revisionFile
|
||||
else "master";
|
||||
description = "The Git revision from which this NixOS configuration was built.";
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user