diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-08-09 17:34:35 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-08-09 17:34:35 +0200 |
commit | f8fad62c8e8ea4ec80a5836318fc5c87f0f9fee5 (patch) | |
tree | a1daa726b27dd9f856c7bd9e527effb67b53a583 | |
parent | 19f398870a0fa022548b047e50cd443e85b5622d (diff) | |
parent | 0b9d9eded15e13079b1f0fef059ecb25bfb308c4 (diff) |
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
-rw-r--r-- | nixos/modules/installer/tools/get-version-suffix (renamed from nixos/modules/installer/tools/get-git-revision) | 2 | ||||
-rw-r--r-- | nixos/modules/installer/tools/nixos-rebuild.sh | 7 | ||||
-rw-r--r-- | nixos/modules/misc/version.nix | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/nixos/modules/installer/tools/get-git-revision b/nixos/modules/installer/tools/get-version-suffix index b57d9cf9fa089..b8972cd57d22b 100644 --- a/nixos/modules/installer/tools/get-git-revision +++ b/nixos/modules/installer/tools/get-version-suffix @@ -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 diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 80a4537375c4f..5ecdcdb3cdb52 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -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 diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 6af310a9d8770..2ecdbdbf39251 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -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."; }; |