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

View File

@ -1,17 +1,14 @@
# Themes are your graphical sessions.
# It also contains your aesthetics even specific workflow and whatnots.
# You can also show your desktop being modularized like this.
{ config, lib, pkgs, foodogsquaredLib, ... }:
# Themes are your graphical sessions. It also contains your aesthetics even
# specific workflow and whatnots. You can also show your desktop being
# modularized like this.
{ lib, ... }:
let cfg = config.workflows;
in {
options.workflows.disableLimit = lib.mkOption {
type = lib.types.bool;
default = false;
{
options.workflows.enable = lib.mkOption {
type = with lib.types; listOf (enum [ ]);
default = [ ];
description = ''
Whether to unlock the limit for workflows. Since workflows may overlap
with packages and configurations, this should be enabled at your own
risk.
A list of workflows to be enabled.
'';
};
@ -19,15 +16,4 @@ in {
./a-happy-gnome
./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, ... }:
let
cfg = config.workflows.workflows.knome;
workflowName = "knome";
cfg = config.workflows.workflows.${workflowName};
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 = {
enable = true;
desktopManager.plasma5 = {