diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2020-10-18 12:57:15 +0200 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2020-10-21 18:30:56 +0200 |
| commit | 4a31cba84c50e01c3281053b5f2bcaa2a942f796 (patch) | |
| tree | ea4f6ba9d1980dcec7cb4e63c4c872f95b2e8b1e | |
| parent | c4bc63d2b9c92cda312e72a6b9131d43c4201d02 (diff) | |
add flake versions
| -rw-r--r-- | flake.nix | 18 | ||||
| -rw-r--r-- | modules/system/version.nix | 20 |
2 files changed, 32 insertions, 6 deletions
@@ -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"; } ]; |
