mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
Set the NixOS version to something useful when building from Git
This commit is contained in:
parent
ea358b4eae
commit
b35fe01f02
3 changed files with 24 additions and 7 deletions
|
@ -140,6 +140,16 @@ if [ -n "$buildNix" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Update the version suffix if we're building from Git (so that
|
||||||
|
# nixos-version shows something useful).
|
||||||
|
if nixos=$(nix-instantiate --find-file nixos "${extraBuildFlags[@]}"); then
|
||||||
|
suffix=$($SHELL $nixos/modules/installer/tools/get-version-suffix "${extraBuildFlags[@]}")
|
||||||
|
if [ -n "$suffix" ]; then
|
||||||
|
echo -n "$suffix" > "$nixos/.version-suffix"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Either upgrade the configuration in the system profile (for "switch"
|
# Either upgrade the configuration in the system profile (for "switch"
|
||||||
# or "boot"), or just build it and create a symlink "result" in the
|
# or "boot"), or just build it and create a symlink "result" in the
|
||||||
# current directory (for "build" and "test").
|
# current directory (for "build" and "test").
|
||||||
|
|
|
@ -7,16 +7,23 @@ with pkgs.lib;
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
system.nixosVersion = mkOption {
|
system.nixosVersion = mkOption {
|
||||||
default =
|
|
||||||
builtins.readFile ../../.version
|
|
||||||
+ (if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix else "pre-git");
|
|
||||||
description = "NixOS version.";
|
description = "NixOS version.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.nixosVersionSuffix = mkOption {
|
||||||
|
description = "NixOS version suffix.";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
|
system.nixosVersion =
|
||||||
|
builtins.readFile ../../.version + config.system.nixosVersionSuffix;
|
||||||
|
|
||||||
|
system.nixosVersionSuffix =
|
||||||
|
if builtins.pathExists ../../.version-suffix then builtins.readFile ../../.version-suffix else "pre-git";
|
||||||
|
|
||||||
# Generate /etc/os-release. See
|
# Generate /etc/os-release. See
|
||||||
# http://0pointer.de/public/systemd-man/os-release.html for the
|
# http://0pointer.de/public/systemd-man/os-release.html for the
|
||||||
# format.
|
# format.
|
||||||
|
|
|
@ -20,7 +20,7 @@ let
|
||||||
let
|
let
|
||||||
|
|
||||||
versionModule =
|
versionModule =
|
||||||
{ system.nixosVersion = version + (lib.optionalString (!officialRelease) versionSuffix);
|
{ system.nixosVersionSuffix = lib.optionalString (!officialRelease) versionSuffix;
|
||||||
isoImage.isoBaseName = "nixos-${type}";
|
isoImage.isoBaseName = "nixos-${type}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ let
|
||||||
|
|
||||||
with import <nixpkgs> {inherit system;};
|
with import <nixpkgs> {inherit system;};
|
||||||
let
|
let
|
||||||
versionModule = { system.nixosVersion = version + (lib.optionalString (!officialRelease) versionSuffix); };
|
versionModule = { system.nixosVersionSuffix = lib.optionalString (!officialRelease) versionSuffix; };
|
||||||
|
|
||||||
config = (import lib/eval-config.nix {
|
config = (import lib/eval-config.nix {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue