nixos/workflows: restructure enable option

The type is probably not apprioriate since I want to be able to install
multiple of them at a given time but we'll see.
This commit is contained in:
Gabriel Arazas 2024-05-16 18:34:23 +08:00
parent 3bc011a3ed
commit 580e0ebe93
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
3 changed files with 22 additions and 30 deletions

View File

@ -1,12 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
cfg = config.workflows.workflows.a-happy-gnome; workflowName = "a-happy-gnome";
cfg = config.workflows.workflows.${workflowName};
in in
{ {
options.workflows.workflows.a-happy-gnome = { options.workflows.enable = lib.mkOption {
enable = lib.mkEnableOption "'A happy GNOME', foo-dogsquared's configuration of GNOME desktop environment"; type = with lib.types; listOf (enum [ workflowName ]);
};
options.workflows.workflows.${workflowName} = {
shellExtensions = lib.mkOption { shellExtensions = lib.mkOption {
type = with lib.types; listOf package; type = with lib.types; listOf package;
description = '' description = ''
@ -81,7 +84,7 @@ in
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf (lib.elem workflowName config.workflows.enable) {
# Enable GNOME and GDM. # Enable GNOME and GDM.
services.xserver = { services.xserver = {
enable = true; enable = true;

View File

@ -1,17 +1,14 @@
# Themes are your graphical sessions. # Themes are your graphical sessions. It also contains your aesthetics even
# It also contains your aesthetics even specific workflow and whatnots. # specific workflow and whatnots. You can also show your desktop being
# You can also show your desktop being modularized like this. # modularized like this.
{ config, lib, pkgs, foodogsquaredLib, ... }: { lib, ... }:
let cfg = config.workflows; {
in { options.workflows.enable = lib.mkOption {
options.workflows.disableLimit = lib.mkOption { type = with lib.types; listOf (enum [ ]);
type = lib.types.bool; default = [ ];
default = false;
description = '' description = ''
Whether to unlock the limit for workflows. Since workflows may overlap A list of workflows to be enabled.
with packages and configurations, this should be enabled at your own
risk.
''; '';
}; };
@ -19,15 +16,4 @@ in {
./a-happy-gnome ./a-happy-gnome
./knome ./knome
]; ];
config = {
assertions = [{
assertion =
let
enabledThemes = foodogsquaredLib.countAttrs (_: theme: theme.enable) cfg.workflows;
in
cfg.disableLimit || (enabledThemes <= 1);
message = "Can't have more than one theme enabled at any given time.";
}];
};
} }

View File

@ -1,12 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
cfg = config.workflows.workflows.knome; workflowName = "knome";
cfg = config.workflows.workflows.${workflowName};
in in
{ {
options.workflows.workflows.knome.enable = lib.mkEnableOption "KNOME, an attempt to bring as much GNOME to KDE Plasma"; options.workflows.enable = lib.mkOption {
type = with lib.types; listOf (enum [ workflowName ]);
};
config = lib.mkIf cfg.enable { config = lib.mkIf (lib.elem workflowName config.workflows.enable) {
services.xserver = { services.xserver = {
enable = true; enable = true;
desktopManager.plasma5 = { desktopManager.plasma5 = {