treewide: update options API

The options API has been updated, in order for a more flexible setup
with `local.modules.desktop.enable` being replaced with an enum of
desktops at `local.systemVars.desktop`, which allows for switching
desktop environments by changing a single option. This is so that we can
switch to cosmic and only enable the programs we need (i.e. disable
greetd because we use cosmic-greeter and enable terminals since that is
desktop related). This is simpler than having a different module per
desktop.
This commit is contained in:
Anthony Rodriguez 2025-02-06 18:40:30 +01:00
parent 51e295caf2
commit fc876b2ea5
Signed by: nezia
SSH key fingerprint: SHA256:Ihfpl0rUpqDevYqnzSR34OYfVLbDNkBiUjs3CpX4ykA
57 changed files with 83 additions and 96 deletions

View file

@ -5,6 +5,7 @@ _: {
systemVars = {
hostName = "solaire";
username = "nezia";
desktop = "Hyprland";
};
homeVars = {
fullName = "Anthony Rodriguez";
@ -13,12 +14,10 @@ _: {
};
profiles = {
desktop.enable = true;
gaming.enable = true;
};
modules = {
hyprland.enable = true;
nvidia.enable = true;
};
};

View file

@ -8,6 +8,7 @@ _: {
systemVars = {
hostName = "vamos";
username = "nezia";
desktop = "Hyprland";
};
homeVars = {
@ -17,12 +18,7 @@ _: {
};
profiles = {
desktop.enable = true;
laptop.enable = true;
};
modules = {
hyprland.enable = true;
};
};
}

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
fonts = {
enableDefaultPackages = false;
packages = [

View file

@ -3,7 +3,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services.fwupd.enable = true;
};
}

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services = {
# setup printing service
printing.enable = true;

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
security = {
polkit.enable = true;
polkit = {

View file

@ -4,14 +4,13 @@
...
}: let
inherit (lib) mkIf;
inherit (config.local.systemVars) username;
inherit (config.local.systemVars) desktop username;
inherit (config.local.homeVars) fullName;
inherit (config.local.profiles) desktop;
in {
users.users.${username} = {
isNormalUser = true;
description = fullName;
extraGroups = mkIf desktop.enable [
extraGroups = mkIf (desktop != "none") [
"networkmanager"
"audio"
"video"
@ -20,7 +19,7 @@ in {
];
};
hjem = mkIf desktop.enable {
hjem = mkIf (desktop != "none") {
clobberByDefault = true;
users.${username} = {
enable = true;

View file

@ -4,23 +4,30 @@
options,
...
}: let
inherit (lib) mkIf mkOption;
inherit (lib) mkOption;
inherit (lib.modules) mkIf;
inherit (lib.types) str;
in {
options.local.homeVars = {
fullName = mkOption {
type = str;
description = "your full name (used for git commits and user description)";
description = ''
your full name (used for git commits and user description)
'';
default = "User";
};
email = mkOption {
type = str;
description = "your email (used for git commits)";
description = ''
your email (used for git commits)
'';
default = null;
};
signingKey = mkOption {
type = str;
description = "your ssh public key (used for signing git commits)";
description = ''
your ssh public key (used for signing git commits)"
'';
};
};

View file

@ -1,6 +1,5 @@
{
imports = [
./hyprland.nix
./nvidia.nix
];
}

View file

@ -1,7 +0,0 @@
{lib, ...}: let
inherit (lib) mkEnableOption;
in {
options.local.modules.hyprland = {
enable = mkEnableOption "Hyprland modules";
};
}

View file

@ -1,6 +1,5 @@
{
imports = [
./desktop.nix
./gaming.nix
./laptop.nix
./server.nix

View file

@ -1,18 +0,0 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption;
in {
options = {
local.profiles.desktop.enable = mkEnableOption "the desktop profile";
};
config.assertions = lib.mkIf config.local.profiles.desktop.enable [
{
assertion = !config.local.profiles.server.enable;
message = "The desktop profile cannot be enabled if `local.profiles.server.enable` is set to true.";
}
];
}

View file

@ -11,7 +11,7 @@ in {
config.assertions = lib.mkIf config.local.profiles.server.enable [
{
assertion = !config.local.profiles.desktop.enable;
assertion = !(config.local.systemVars.desktop != "none");
message = "The server profile cannot be enabled if `local.profiles.desktop.enable` is set to true.";
}

View file

@ -4,19 +4,30 @@
...
}: let
inherit (lib) mkOption;
inherit (lib.types) str;
inherit (lib.types) enum str;
in {
options.local.systemVars = {
hostName = mkOption {
type = str;
description = "hostname for the current host";
description = ''
hostname for the current host
'';
default = null;
};
username = mkOption {
type = str;
description = "username for the home directory";
description = ''
username for the home directory
'';
default = "user";
};
desktop = mkOption {
type = enum ["none" "Hyprland" "cosmic"];
default = "none";
description = ''
the desktop environment to be used
'';
};
};
config.assertions = [
@ -26,5 +37,8 @@ in {
{
assertion = options.local.systemVars.username.isDefined;
}
{
assertion = options.local.systemVars.desktop.isDefined;
}
];
}

View file

@ -8,7 +8,7 @@
inherit (lib) mkIf;
inherit (config.local.systemVars) username;
in {
config = mkIf config.local.modules.hyprland.enable {
config = mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [inputs.anyrun.packages.${pkgs.system}.anyrun-with-all-plugins];
files = {

View file

@ -22,7 +22,7 @@
];
} (builtins.readFile ./krisp-patcher.py);
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [discord krisp-patcher];
files.".config/Vencord/themes/midnight-base16.css".text = with styleCfg.scheme.palette;

View file

@ -10,7 +10,7 @@ in {
./neovim.nix
];
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
/*
we don't want the default NixOS EDITOR value, which is nano and will override the `environment.d` setting.
we have to unset it like this so that our systemd user variable will take precedence:

View file

@ -239,7 +239,7 @@
};
};
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [customNeovim.neovim];
};

View file

@ -10,7 +10,7 @@
sha256 = "137k3i7z4va68v4rvrazy26szc7p2w59h7bc2h8japzjyj6xjs71";
};
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.fastfetch];
files = {

View file

@ -144,7 +144,7 @@
};
};
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [firefox];
files = {

View file

@ -12,7 +12,7 @@
hyprlock = "${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock";
in {
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [hypridle];
files = {

View file

@ -29,7 +29,7 @@
'';
});
in {
config = mkIf config.local.modules.hyprland.enable {
config = mkIf (config.local.systemVars.desktop == "Hyprland") {
programs.hyprland = {
enable = true;
package = inputs.hyprland.packages.${pkgs.system}.hyprland;

View file

@ -14,7 +14,7 @@
styleCfg = config.local.style;
rgbaPalette = builtins.mapAttrs (_: c: (lib'.rgba c 1)) styleCfg.scheme.palette;
in {
config = mkIf config.local.modules.hyprland.enable {
config = mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [hyprlock];
files = {

View file

@ -11,7 +11,7 @@
inherit (config.local.style) wallpaper;
inherit (inputs.hyprpaper.packages.${pkgs.system}) hyprpaper;
in {
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [hyprpaper];
files = {

View file

@ -11,7 +11,7 @@ in {
./zathura.nix
];
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username}.packages = [
pkgs.gnome-calculator
pkgs.gthumb

View file

@ -7,7 +7,7 @@
inherit (config.local.systemVars) username;
styleCfg = config.local.style;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.tidal-hifi];
files = {

View file

@ -9,7 +9,7 @@
builtins.concatStringsSep "\n"
(lib.mapAttrsToList (option: value: "set ${option} \"${toString value}\"") attrs);
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.zathura];
files = {

View file

@ -8,7 +8,7 @@
inherit (lib) mkIf;
inherit (config.local.systemVars) username;
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = with pkgs; [
entr

View file

@ -4,10 +4,9 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (config.local.profiles) desktop;
inherit (config.local.systemVars) username;
inherit (config.local.systemVars) desktop username;
in {
config = mkIf desktop.enable {
config = mkIf (desktop != "none") {
programs.nh = {
enable = true;
clean = {

View file

@ -5,6 +5,7 @@
...
}: let
inherit (lib) optionalAttrs;
inherit (lib.modules) mkIf;
inherit (config.local.systemVars) username;
styleCfg = config.local.style;
@ -38,7 +39,7 @@
"21" = palette.base06;
};
in {
config = lib.mkIf config.local.modules.hyprland.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.foot];
files = {

View file

@ -45,7 +45,7 @@
selection-foreground = colors.base05;
};
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
files = mkMerge [
{

View file

@ -9,7 +9,7 @@
builtins.concatStringsSep "\n"
(lib.mapAttrsToList (option: value: "--${option}=\"${value}\"") attrs);
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [
pkgs.bat

View file

@ -3,7 +3,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
programs.direnv.enable = true;
};
}

View file

@ -8,7 +8,7 @@
inherit (config.local.homeVars) signingKey;
toINI = lib.generators.toINI {};
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = with pkgs; [git lazygit];
files = {

View file

@ -6,7 +6,7 @@
}: let
inherit (config.local.systemVars) username;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = with pkgs; [
# archives

View file

@ -4,7 +4,7 @@
osConfig,
...
}: {
config = lib.mkIf osConfig.local.profiles.desktop.enable {
config = lib.mkIf (osConfig.local.systemVars.desktop != "none") {
programs.tmux = {
enable = true;
prefix = "C-space";

View file

@ -14,7 +14,7 @@ in {
./zsh.nix
];
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
users.users.${username}.shell = pkgs.zsh;
};
}

View file

@ -12,7 +12,7 @@
starshipCache = "${config.hjem.users.${username}.directory}/.cache/starship";
zoxideCache = "${config.hjem.users.${username}.directory}/.cache/zoxide";
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = with pkgs; [carapace nushell];
files = {

View file

@ -7,7 +7,7 @@
inherit (config.local.systemVars) username;
toTOML = (pkgs.formats.toml {}).generate;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.starship];
files = {

View file

@ -6,7 +6,7 @@
}: let
inherit (config.local.systemVars) username;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.zoxide];
};

View file

@ -7,7 +7,7 @@
inherit (lib) mkIf;
inherit (config.local.systemVars) username;
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
programs.zsh.enable = true;
hjem.users.${username} = {
packages = [pkgs.zsh];

View file

@ -6,7 +6,7 @@
}: let
inherit (lib) mkIf;
in {
config = mkIf config.local.profiles.desktop.enable {
config = mkIf (config.local.systemVars.desktop != "none") {
programs = {
thunar = {
enable = true;

View file

@ -10,7 +10,7 @@
styleCfg = config.local.style;
betterTransition = "all 0.3s cubic-bezier(.55,-0.68,.48,1.682)";
in {
config = mkIf config.local.modules.hyprland.enable {
config = mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [
pkgs.waybar

View file

@ -17,7 +17,7 @@
in
builtins.concatStringsSep "\n" (map formatItem items);
in {
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [pkgs.wlogout];
files = {

View file

@ -6,7 +6,7 @@
}: let
inherit (config.local.systemVars) username;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
files = {
".config/mimeapps.list".text = ''

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
virtualisation.podman = {
enable = true;
dockerCompat = true;

View file

@ -3,7 +3,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
documentation = {
enable = true;

View file

@ -3,7 +3,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services.flatpak.enable = true;
};
}

View file

@ -7,7 +7,7 @@
inherit (config.local.systemVars) username;
toINI = lib.generators.toINI {};
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
hjem.users.${username} = {
packages = [pkgs.gammastep];
files = {

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services = {
# needed for GNOME services outside of GNOME Desktop
dbus.packages = with pkgs; [

View file

@ -49,8 +49,7 @@ let
};
});
in {
# TODO: perhaps turn this into a more generic module if we wanna use other wayland compositors
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
services.greetd = {
enable = true;
settings = {

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services.keyd = {
enable = true;
keyboards.default = {

View file

@ -4,7 +4,7 @@
config,
...
}: {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services.kmscon = {
enable = true;
fonts = [

View file

@ -3,7 +3,7 @@
config,
...
}: {
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
location.provider = "geoclue2";
services.geoclue2 = {

View file

@ -8,7 +8,7 @@
inputs.nix-gaming.nixosModules.pipewireLowLatency
];
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
services = {
pulseaudio.enable = false;
pipewire = {

View file

@ -5,7 +5,7 @@
}: let
inherit (config.local.systemVars) username;
in {
config = lib.mkIf config.local.profiles.desktop.enable {
config = lib.mkIf (config.local.systemVars.desktop != "none") {
programs.ssh = {
startAgent = true;
};

View file

@ -9,7 +9,7 @@
inherit (config.local.systemVars) username;
inherit (lib') generateGtkColors;
in {
config = lib.mkIf config.local.modules.hyprland.enable {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
files = {
".config/swaync/config.json".text = toJSON {