From dc9553ef0b3439f31a9ab5772356bf936895df74 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 4 Jun 2024 11:29:28 +0000 Subject: [PATCH] feat(modules)!: bump minimum supported release to 24.05 (#203) * chore(modules)!: bump minimum supported release to 24.05 * feat(modules): assert minimum supported version --- dev/flake.lock | 32 +++++++++++--------- dev/flake.nix | 6 ++-- modules/home-manager/globals.nix | 4 +++ modules/home-manager/tofi.nix | 8 +---- modules/lib/default.nix | 7 +++++ modules/nixos/globals.nix | 4 +++ modules/nixos/sddm.nix | 52 +++++++++++++------------------- 7 files changed, 57 insertions(+), 56 deletions(-) diff --git a/dev/flake.lock b/dev/flake.lock index 3a66c0d..8463d0c 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -27,48 +27,50 @@ ] }, "locked": { - "lastModified": 1715381426, - "narHash": "sha256-wPuqrAQGdv3ISs74nJfGb+Yprm23U/rFpcHFFNWgM94=", + "lastModified": 1716736833, + "narHash": "sha256-rNObca6dm7Qs524O4st8VJH6pZ/Xe1gxl+Rx6mcWYo0=", "owner": "nix-community", "repo": "home-manager", - "rev": "ab5542e9dbd13d0100f8baae2bc2d68af901f4b4", + "rev": "a631666f5ec18271e86a5cde998cba68c33d9ac6", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-23.11", + "ref": "release-24.05", "repo": "home-manager", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1715787315, - "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=", + "lastModified": 1716948383, + "narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5", + "rev": "ad57eef4ef0659193044870c731987a6df5cf56b", "type": "github" }, "original": { - "id": "nixpkgs", + "owner": "NixOS", "ref": "nixos-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs-stable": { "locked": { - "lastModified": 1716239187, - "narHash": "sha256-5oyOV5ZlqXYQ8RB6lvVrKxVBeBPE/ZsLY+qQKqSJLZM=", + "lastModified": 1717144377, + "narHash": "sha256-F/TKWETwB5RaR8owkPPi+SPJh83AQsm6KrQAlJ8v/uA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f88df4bf25b729d78712c441fb0910f7085e9395", + "rev": "805a384895c696f802a9bf5bf4720f37385df547", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "release-23.11", - "type": "indirect" + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/dev/flake.nix b/dev/flake.nix index 688f2c4..8c72f3e 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -2,8 +2,8 @@ description = "Soothing pastel theme for Nix"; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; - nixpkgs-stable.url = "nixpkgs/release-23.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; home-manager = { url = "github:nix-community/home-manager"; @@ -11,7 +11,7 @@ }; home-manager-stable = { - url = "github:nix-community/home-manager/release-23.11"; + url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs-stable"; }; }; diff --git a/modules/home-manager/globals.nix b/modules/home-manager/globals.nix index 5189a93..ddb54c7 100644 --- a/modules/home-manager/globals.nix +++ b/modules/home-manager/globals.nix @@ -1,5 +1,9 @@ { lib, ... }: { + config = { + assertions = [ (lib.ctp.assertMinimumVersion "24.05") ]; + }; + options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; diff --git a/modules/home-manager/tofi.nix b/modules/home-manager/tofi.nix index 461aeec..e26bd65 100644 --- a/modules/home-manager/tofi.nix +++ b/modules/home-manager/tofi.nix @@ -3,15 +3,9 @@ let inherit (config.catppuccin) sources; cfg = config.programs.tofi.catppuccin; enable = cfg.enable && config.programs.tofi.enable; - - # `programs.tofi` was added in 24.05 and not backported - # TODO: remove when 24.05 is stable - minVersion = "24.05"; in { - options.programs.tofi = lib.ctp.mkVersionedOpts minVersion { - catppuccin = lib.ctp.mkCatppuccinOpt "tofi"; - }; + options.programs.tofi.catppuccin = lib.ctp.mkCatppuccinOpt "tofi"; config.programs.tofi = lib.mkIf enable { settings = lib.ctp.fromINI (sources.tofi + "/catppuccin-${cfg.flavor}"); diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 4c316dc..97d816d 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -145,4 +145,11 @@ in option else lib.mkSinkUndeclaredOptions { }; + + # string -> a + # this is to ensure users are running a supported version of nixos/home-manager + assertMinimumVersion = version: { + assertion = lib.versionAtLeast ctp.getModuleRelease version; + message = "`catppuccin/nix` requires at least version ${version} of NixOS/home-manager"; + }; } diff --git a/modules/nixos/globals.nix b/modules/nixos/globals.nix index 5189a93..ddb54c7 100644 --- a/modules/nixos/globals.nix +++ b/modules/nixos/globals.nix @@ -1,5 +1,9 @@ { lib, ... }: { + config = { + assertions = [ (lib.ctp.assertMinimumVersion "24.05") ]; + }; + options.catppuccin = { enable = lib.mkEnableOption "Catppuccin globally"; diff --git a/modules/nixos/sddm.nix b/modules/nixos/sddm.nix index c00c09e..1f36de1 100644 --- a/modules/nixos/sddm.nix +++ b/modules/nixos/sddm.nix @@ -10,45 +10,35 @@ let ctp types mkOption - versionAtLeast ; cfg = config.services.displayManager.sddm.catppuccin; - enable = - versionAtLeast ctp.getModuleRelease minVersion - && cfg.enable - && config.services.displayManager.sddm.enable; - - # versions >= 24.05 renamed `services.xserver.displayManager` to `services.displayManager` - # TODO: remove when 24.05 is stable - minVersion = "24.05"; + enable = cfg.enable && config.services.displayManager.sddm.enable; in { - options.services.displayManager = ctp.mkVersionedOpts minVersion { - sddm.catppuccin = ctp.mkCatppuccinOpt "sddm" // { - font = mkOption { - type = types.str; - default = "Noto Sans"; - description = "Font to use for the login screen"; - }; + options.services.displayManager.sddm.catppuccin = ctp.mkCatppuccinOpt "sddm" // { + font = mkOption { + type = types.str; + default = "Noto Sans"; + description = "Font to use for the login screen"; + }; - fontSize = mkOption { - type = types.str; - default = "9"; - description = "Font size to use for the login screen"; - }; + fontSize = mkOption { + type = types.str; + default = "9"; + description = "Font size to use for the login screen"; + }; - background = mkOption { - type = with types; (either path str); - default = ""; - description = "Background image to use for the login screen"; - }; + background = mkOption { + type = with types; (either path str); + default = ""; + description = "Background image to use for the login screen"; + }; - loginBackground = mkOption { - type = types.bool; - default = true; - description = "Add an additional background layer to the login panel"; - }; + loginBackground = mkOption { + type = types.bool; + default = true; + description = "Add an additional background layer to the login panel"; }; };