From b89a42ef13c094b5a16aa5c59c027f1b57c412a2 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 14 Jan 2025 11:59:59 +0100 Subject: [PATCH] modules/options: add profiles The next step in the refactoring is to add different profiles, so that we may toggle them easily in our hosts. Here's the profiles I went for: - desktop: enables everything a desktop computer needs (graphics, productivity apps, base apps such as browsers...) - gaming: enables gaming configurations (steam, gamescope...) - server: enables server configurations (website hosting, git forge...) I made sure the server profile can not be enabled if desktop/gaming are enabled, as it would not make sense to have desktop applications and configurations on a server. --- modules/options/default.nix | 2 ++ modules/options/profiles/default.nix | 7 +++++++ modules/options/profiles/desktop.nix | 18 ++++++++++++++++++ modules/options/profiles/gaming.nix | 18 ++++++++++++++++++ modules/options/profiles/server.nix | 23 +++++++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 modules/options/profiles/default.nix create mode 100644 modules/options/profiles/desktop.nix create mode 100644 modules/options/profiles/gaming.nix create mode 100644 modules/options/profiles/server.nix diff --git a/modules/options/default.nix b/modules/options/default.nix index 816a12e..c532f81 100644 --- a/modules/options/default.nix +++ b/modules/options/default.nix @@ -1,5 +1,7 @@ { imports = [ + ./profiles + ./homeVars.nix ./style.nix ./systemVars.nix diff --git a/modules/options/profiles/default.nix b/modules/options/profiles/default.nix new file mode 100644 index 0000000..40469cf --- /dev/null +++ b/modules/options/profiles/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ./desktop.nix + ./gaming.nix + ./server.nix + ]; +} diff --git a/modules/options/profiles/desktop.nix b/modules/options/profiles/desktop.nix new file mode 100644 index 0000000..62e8742 --- /dev/null +++ b/modules/options/profiles/desktop.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption; +in { + options = { + local.profiles.desktop.enable = mkEnableOption "the desktop profile"; + }; + + config.assertions = [ + { + assertion = !config.local.profiles.server.enable; + message = "The desktop profile cannot be enabled if `local.profiles.server.enable` is set to true."; + } + ]; +} diff --git a/modules/options/profiles/gaming.nix b/modules/options/profiles/gaming.nix new file mode 100644 index 0000000..9e4d1c9 --- /dev/null +++ b/modules/options/profiles/gaming.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption; +in { + options = { + local.profiles.gaming.enable = mkEnableOption "the gaming profile"; + }; + + config.assertions = [ + { + assertion = !config.local.profiles.server.enable; + message = "The gaming profile cannot be enabled if `local.profiles.server.enable` is set to true."; + } + ]; +} diff --git a/modules/options/profiles/server.nix b/modules/options/profiles/server.nix new file mode 100644 index 0000000..46c4ea2 --- /dev/null +++ b/modules/options/profiles/server.nix @@ -0,0 +1,23 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption; +in { + options = { + local.profiles.server.enable = mkEnableOption "the server profile"; + }; + + config.assertions = [ + { + assertion = !config.local.profiles.desktop.enable; + message = "The server profile cannot be enabled if `local.profiles.desktop.enable` is set to true."; + } + + { + assertion = !config.local.profiles.gaming.enable; + message = "The server profile cannot be enabled if `local.profiles.gaming.enable` is set to true."; + } + ]; +}