summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2020-10-18 12:57:15 +0200
committerDaiderd Jordan <daiderd@gmail.com>2020-10-21 18:30:56 +0200
commit4a31cba84c50e01c3281053b5f2bcaa2a942f796 (patch)
treeea4f6ba9d1980dcec7cb4e63c4c872f95b2e8b1e
parentc4bc63d2b9c92cda312e72a6b9131d43c4201d02 (diff)
add flake versions
-rw-r--r--flake.nix18
-rw-r--r--modules/system/version.nix20
2 files changed, 32 insertions, 6 deletions
diff --git a/flake.nix b/flake.nix
index 204898c..191c5fb 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,7 +2,20 @@
# WARNING this is very much still experimental.
description = "A collection of darwin modules";
- outputs = { self, nixpkgs }: {
+ outputs = { self, nixpkgs }:
+ let
+ versionsModule = { lib, ... }: {
+ _file = ./flake.nix;
+ config = {
+ system.darwinVersionSuffix = ".${nixpkgs.shortRev or "dirty"}";
+ system.darwinRevision = lib.mkIf (self ? rev) self.rev;
+
+ system.nixpkgsVersionSuffix = ".${lib.substring 0 8 (nixpkgs.lastModifiedDate or nixpkgs.lastModified or "19700101")}.${nixpkgs.shortRev or "dirty"}";
+ system.nixpkgsRevision = lib.mkIf (nixpkgs ? rev) nixpkgs.rev;
+ };
+ };
+ in
+ {
lib = {
# TODO handle multiple architectures.
@@ -10,8 +23,7 @@
darwinSystem = { modules, inputs ? {}, ... }@args: self.lib.evalConfig (args // {
inputs = { inherit nixpkgs; darwin = self; } // inputs;
- modules = modules ++ [
- ];
+ modules = modules ++ [ versionsModule ];
});
};
diff --git a/modules/system/version.nix b/modules/system/version.nix
index 46291d6..7b9236d 100644
--- a/modules/system/version.nix
+++ b/modules/system/version.nix
@@ -59,6 +59,12 @@ in
description = "The full darwin version (e.g. <literal>darwin4.master</literal>).";
};
+ system.darwinVersionSuffix = mkOption {
+ internal = true;
+ type = types.str;
+ description = "The short darwin version suffix (e.g. <literal>.2abdb5a</literal>).";
+ };
+
system.darwinRevision = mkOption {
internal = true;
type = types.str;
@@ -78,6 +84,12 @@ in
description = "The full nixpkgs version (e.g. <literal>16.03.1160.f2d4ee1</literal>).";
};
+ system.nixpkgsVersionSuffix = mkOption {
+ internal = true;
+ type = types.str;
+ description = "The short nixpkgs version suffix (e.g. <literal>.1160.f2d4ee1</literal>).";
+ };
+
system.nixpkgsRevision = mkOption {
internal = true;
type = types.str;
@@ -89,12 +101,14 @@ in
# These defaults are set here rather than up there so that
# changing them would not rebuild the manual
- system.darwinLabel = "${cfg.nixpkgsVersion}+${cfg.darwinVersion}";
- system.darwinVersion = "darwin" + toString cfg.stateVersion + "." + darwin.shortRev;
+ system.darwinLabel = mkDefault "${cfg.nixpkgsVersion}+${cfg.darwinVersion}";
+ system.darwinVersion = mkDefault "darwin${toString cfg.stateVersion}${cfg.darwinVersionSuffix}";
+ system.darwinVersionSuffix = mkDefault ".${darwin.shortRev}";
system.darwinRevision = mkIf (darwin ? rev) (mkDefault darwin.rev);
- system.nixpkgsVersion = mkDefault (cfg.nixpkgsRelease + nixpkgsSuffix);
+ system.nixpkgsVersion = mkDefault "${cfg.nixpkgsRelease}${cfg.nixpkgsVersionSuffix}";
system.nixpkgsRelease = mkDefault (fileContents releaseFile);
+ system.nixpkgsVersionSuffix = mkDefault nixpkgsSuffix;
system.nixpkgsRevision = mkIf (nixpkgs ? rev) (mkDefault nixpkgs.rev);
assertions = [ { assertion = cfg.stateVersion <= defaultStateVersion; message = "system.stateVersion = ${toString cfg.stateVersion}; is not a valid value"; } ];