From 23ad3d2b5398402967bbc566fae3f15cb1a1be27 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 15 Jul 2023 16:47:19 +0100 Subject: [PATCH] version: add `isReleaseBranch` --- docs/release-notes/rl-2311.adoc | 7 +++++++ modules/home-environment.nix | 4 ++-- modules/misc/version.nix | 17 +++++++++++++++-- release.json | 4 ++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 release.json diff --git a/docs/release-notes/rl-2311.adoc b/docs/release-notes/rl-2311.adoc index 4ac3a647d..c546d37a2 100644 --- a/docs/release-notes/rl-2311.adoc +++ b/docs/release-notes/rl-2311.adoc @@ -16,6 +16,13 @@ but could theoretically break if you have very complex bash expressions in a session variable. Please report any issues you experience. +* The `.release` file in the Home Manager source tree +has been supplanted by `release.json`, +which contains more information about the branch. +If you have any external code reading this file, +please migrate to using `release.json` instead. +The `.release` file will be removed in 24.05. + [[sec-release-23.11-state-version-changes]] === State Version Changes diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 48d08580f..12fd9f39d 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -483,8 +483,8 @@ in warnings = let - hmRelease = fileContents ../.release; - nixpkgsRelease = pkgs.lib.trivial.release; + hmRelease = config.home.version.release; + nixpkgsRelease = lib.trivial.release; releaseMismatch = config.home.enableNixpkgsReleaseCheck && hmRelease != nixpkgsRelease; diff --git a/modules/misc/version.nix b/modules/misc/version.nix index 9720ddf29..548268edd 100644 --- a/modules/misc/version.nix +++ b/modules/misc/version.nix @@ -2,7 +2,9 @@ with lib; -{ +let releaseInfo = lib.importJSON ../../release.json; + +in { options = { home.stateVersion = mkOption { type = types.enum [ @@ -51,11 +53,22 @@ with lib; internal = true; readOnly = true; type = types.str; - default = fileContents ../../.release; + default = releaseInfo.release; example = "22.11"; description = "The Home Manager release."; }; + isReleaseBranch = mkOption { + internal = true; + readOnly = true; + type = types.bool; + default = releaseInfo.isReleaseBranch; + description = '' + Whether the Home Manager version is from a versioned + release branch. + ''; + }; + revision = mkOption { internal = true; type = types.nullOr types.str; diff --git a/release.json b/release.json new file mode 100644 index 000000000..5675c269e --- /dev/null +++ b/release.json @@ -0,0 +1,4 @@ +{ + "release": "23.11", + "isReleaseBranch": false +}