Use lib.mkEnableOption where possible

This commit is contained in:
Vili Sinervä 2025-07-25 13:12:41 +03:00
parent e7dddd56f9
commit 99b84bd224
Signed by: Vili Sinervä
SSH key fingerprint: SHA256:FladqYjaE4scJY3Hi+gnShZ6ygnTJgixy0I6BAoHyos
36 changed files with 48 additions and 158 deletions

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.hardware.amdLaptop; cfg = config.custom.hardware.amdLaptop;
in in
{ {
options.custom.hardware.amdLaptop.enable = lib.mkOption { options.custom.hardware.amdLaptop.enable = lib.mkEnableOption "AMD laptop hardware configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ zenmonitor ]; environment.systemPackages = with pkgs; [ zenmonitor ];
@ -45,8 +42,6 @@ in
}; };
}; };
logind.lidSwitch = if config.boot.resumeDevice != "" then "hibernate" else "suspend";
}; };
boot = { boot = {

View file

@ -8,10 +8,8 @@ let
cfg = config.custom.hardware.intelLaptop; cfg = config.custom.hardware.intelLaptop;
in in
{ {
options.custom.hardware.intelLaptop.enable = lib.mkOption { options.custom.hardware.intelLaptop.enable =
type = lib.types.bool; lib.mkEnableOption "Intel laptop hardware configuration";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {
@ -35,8 +33,6 @@ in
}; };
}; };
logind.lidSwitch = if config.boot.resumeDevice != "" then "hibernate" else "suspend";
}; };
boot = { boot = {

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.hardware.keychron; cfg = config.custom.hardware.keychron;
in in
{ {
options.custom.hardware.keychron.enable = lib.mkOption { options.custom.hardware.keychron.enable = lib.mkEnableOption "Keychron Q11 hardware configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; if config.services.xserver.enable then [ via ] else [ ]; environment.systemPackages = with pkgs; if config.services.xserver.enable then [ via ] else [ ];

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.hardware.nvidia; cfg = config.custom.hardware.nvidia;
in in
{ {
options.custom.hardware.nvidia.enable = lib.mkOption { options.custom.hardware.nvidia.enable = lib.mkEnableOption "NVIDIA dGPU hardware configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware = { hardware = {

View file

@ -8,10 +8,8 @@ let
cfg = config.custom.hardware.onlykey; cfg = config.custom.hardware.onlykey;
in in
{ {
options.custom.hardware.onlykey.enable = lib.mkOption { options.custom.hardware.onlykey.enable =
type = lib.types.bool; lib.mkEnableOption "OnlyKey USB security key hardware configuration";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -3,10 +3,8 @@ let
cfg = config.custom.hardware.trackball; cfg = config.custom.hardware.trackball;
in in
{ {
options.custom.hardware.trackball.enable = lib.mkOption { options.custom.hardware.trackball.enable =
type = lib.types.bool; lib.mkEnableOption "Logitech MX Ergo trackball hardware configuration";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nixpkgs.overlays = [ nixpkgs.overlays = [

View file

@ -6,10 +6,7 @@ in
{ {
options.custom.networking = { options.custom.networking = {
homeWg = { homeWg = {
enable = lib.mkOption { enable = lib.mkEnableOption "Home WireGuard";
type = lib.types.bool;
default = false;
};
guaSuffix = lib.mkOption { guaSuffix = lib.mkOption {
type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$"); type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$");
default = null; default = null;

View file

@ -3,14 +3,7 @@ let
cfg = config.custom.networking.idacloudWg; cfg = config.custom.networking.idacloudWg;
in in
{ {
options.custom.networking = { options.custom.networking.idacloudWg.enable = lib.mkEnableOption "Idacloud WireGuard";
idacloudWg = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
};
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
sops = { sops = {

View file

@ -6,10 +6,7 @@ in
{ {
options.custom.networking = { options.custom.networking = {
netflixWg = { netflixWg = {
enable = lib.mkOption { enable = lib.mkEnableOption "Netflix WireGuard";
type = lib.types.bool;
default = false;
};
suffix = lib.mkOption { suffix = lib.mkOption {
type = with lib.types; nullOr (strMatching "^[0-9.]+$"); type = with lib.types; nullOr (strMatching "^[0-9.]+$");
default = null; default = null;

View file

@ -4,10 +4,7 @@ let
in in
{ {
options.custom.platform.hetzner = { options.custom.platform.hetzner = {
enable = lib.mkOption { enable = lib.mkEnableOption "Hetzner cloud configuration";
type = lib.types.bool;
default = false;
};
ipv4Address = lib.mkOption { ipv4Address = lib.mkOption {
type = with lib.types; nullOr (strMatching "^[0-9]+.[0-9]+.[0-9]+.[0-9]+/32$"); type = with lib.types; nullOr (strMatching "^[0-9]+.[0-9]+.[0-9]+.[0-9]+/32$");
default = null; default = null;

View file

@ -7,10 +7,7 @@ let
cfg = config.custom.platform.vm; cfg = config.custom.platform.vm;
in in
{ {
options.custom.platform.vm.enable = lib.mkOption { options.custom.platform.vm.enable = lib.mkEnableOption "KVM virtual machine guest configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.programs.bitwarden; cfg = config.custom.programs.bitwarden;
in in
{ {
options.custom.programs.bitwarden.enable = lib.mkOption { options.custom.programs.bitwarden.enable = lib.mkEnableOption "Bitwarden desktop applications";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -8,10 +8,8 @@ let
cfg = config.custom.programs.communication; cfg = config.custom.programs.communication;
in in
{ {
options.custom.programs.communication.enable = lib.mkOption { options.custom.programs.communication.enable =
type = lib.types.bool; lib.mkEnableOption "messaging/communication programs";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -11,10 +11,7 @@ let
}; };
in in
{ {
options.custom.programs.firefox.enable = lib.mkOption { options.custom.programs.firefox.enable = lib.mkEnableOption "customized Firefox configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.firefox = { programs.firefox = {

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.programs.i3; cfg = config.custom.programs.i3;
in in
{ {
options.custom.programs.i3.enable = lib.mkOption { options.custom.programs.i3.enable = lib.mkEnableOption "i3 window manager";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.programs.moonlight; cfg = config.custom.programs.moonlight;
in in
{ {
options.custom.programs.moonlight.enable = lib.mkOption { options.custom.programs.moonlight.enable = lib.mkEnableOption "Moonlight game streaming client";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.programs.nvim; cfg = config.custom.programs.nvim;
in in
{ {
options.custom.programs.nvim.enable = lib.mkOption { options.custom.programs.nvim.enable = lib.mkEnableOption "customized nVim configuration";
type = lib.types.bool;
default = false;
};
imports = [ nixvim.nixosModules.nixvim ]; imports = [ nixvim.nixosModules.nixvim ];

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.programs.redshift; cfg = config.custom.programs.redshift;
in in
{ {
options.custom.programs.redshift.enable = lib.mkOption { options.custom.programs.redshift.enable = lib.mkEnableOption "redshift blue-light reducer";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.redshift = { services.redshift = {

View file

@ -3,10 +3,8 @@ let
cfg = config.custom.programs.symlinks; cfg = config.custom.programs.symlinks;
in in
{ {
options.custom.programs.symlinks.enable = lib.mkOption { options.custom.programs.symlinks.enable =
type = lib.types.bool; lib.mkEnableOption "automatic symlinks of specific configuration files";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
system.userActivationScripts.mkDesktopSettingsSymlinks.text = system.userActivationScripts.mkDesktopSettingsSymlinks.text =

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.programs.usbAutoMount; cfg = config.custom.programs.usbAutoMount;
in in
{ {
options.custom.programs.usbAutoMount.enable = lib.mkOption { options.custom.programs.usbAutoMount.enable = lib.mkEnableOption "auto-mounting of USB storage";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {

View file

@ -7,10 +7,7 @@
}: }:
{ {
options.custom = { options.custom = {
base.enable = lib.mkOption { base.enable = lib.mkEnableOption "base configuration for my hosts";
type = lib.types.bool;
default = true;
};
networking.guaPref = lib.mkOption { networking.guaPref = lib.mkOption {
type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$"); type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$");
default = "2001:14ba:a090:39"; default = "2001:14ba:a090:39";
@ -19,6 +16,9 @@
}; };
config = { config = {
custom.base.enable = lib.mkDefault true;
}
// (lib.mkIf config.custom.base.enable {
######################################## Packages ############################################### ######################################## Packages ###############################################
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
tmux tmux
@ -196,5 +196,5 @@
efi.canTouchEfiVariables = lib.mkDefault true; efi.canTouchEfiVariables = lib.mkDefault true;
timeout = lib.mkDefault 0; timeout = lib.mkDefault 0;
}; };
}; });
} }

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.roles.desktop; cfg = config.custom.roles.desktop;
in in
{ {
options.custom.roles.desktop.enable = lib.mkOption { options.custom.roles.desktop.enable = lib.mkEnableOption "desktop role";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
custom = { custom = {
@ -20,6 +17,7 @@ in
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
libreoffice
alacritty alacritty
vlc vlc
flameshot flameshot

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.roles.development; cfg = config.custom.roles.development;
in in
{ {
options.custom.roles.development.enable = lib.mkOption { options.custom.roles.development.enable = lib.mkEnableOption "development role";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
custom.programs.nvim.enable = true; custom.programs.nvim.enable = true;

View file

@ -8,14 +8,10 @@ let
cfg = config.custom.roles.study; cfg = config.custom.roles.study;
in in
{ {
options.custom.roles.study.enable = lib.mkOption { options.custom.roles.study.enable = lib.mkEnableOption "study configuration";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
libreoffice
zotero zotero
kile kile
texliveFull texliveFull

View file

@ -44,10 +44,7 @@ let
''; '';
in in
{ {
options.custom.services.certStoreServer.enable = lib.mkOption { options.custom.services.certStoreServer.enable = lib.mkEnableOption "cert-store server";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
sops = { sops = {

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.services.forgejoRunner; cfg = config.custom.services.forgejoRunner;
in in
{ {
options.custom.services.forgejoRunner.enable = lib.mkOption { options.custom.services.forgejoRunner.enable = lib.mkEnableOption "Forgejo actions runner";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
sops.secrets.forgejo-token = { sops.secrets.forgejo-token = {

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.services.forgejo; cfg = config.custom.services.forgejo;
in in
{ {
options.custom.services.forgejo.enable = lib.mkOption { options.custom.services.forgejo.enable = lib.mkEnableOption "self-hosted Forgejo instance";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
custom.services = { custom.services = {

View file

@ -8,10 +8,7 @@ let
cfg = config.custom.services.gamingServer; cfg = config.custom.services.gamingServer;
in in
{ {
options.custom.services.gamingServer.enable = lib.mkOption { options.custom.services.gamingServer.enable = lib.mkEnableOption "Game streaming server";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.tmpfiles.settings."vili-home" = { systemd.tmpfiles.settings."vili-home" = {

View file

@ -4,10 +4,7 @@ let
hydraDomain = "ci.sinerva.eu"; hydraDomain = "ci.sinerva.eu";
in in
{ {
options.custom.services.hydra.enable = lib.mkOption { options.custom.services.hydra.enable = lib.mkEnableOption "Hydra continous integration server";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
custom.services = { custom.services = {

View file

@ -10,19 +10,13 @@ in
{ {
options.custom.services = { options.custom.services = {
nextcloud = { nextcloud = {
enable = lib.mkOption { enable = lib.mkEnableOption "self-hosted Nextcloud instance";
type = lib.types.bool;
default = false;
};
domain = lib.mkOption { domain = lib.mkOption {
type = with lib.types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
}; };
collabora = { collabora = {
enable = lib.mkOption { enable = lib.mkEnableOption "self-hosted Collabora server alongside Nextcloud";
type = lib.types.bool;
default = false;
};
domain = lib.mkOption { domain = lib.mkOption {
type = with lib.types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;

View file

@ -3,10 +3,8 @@ let
cfg = config.custom.services.siit; cfg = config.custom.services.siit;
in in
{ {
options.custom.services.siit.enable = lib.mkOption { options.custom.services.siit.enable =
type = lib.types.bool; lib.mkEnableOption "IPv4 to IPv6 stateless translator (SIIT-DC)";
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
networking = { networking = {

View file

@ -4,10 +4,7 @@ let
in in
{ {
options = { options = {
custom.services.acmeHttpClient.enable = lib.mkOption { custom.services.acmeHttpClient.enable = lib.mkEnableOption "ACME HTTP client";
type = lib.types.bool;
default = false;
};
services.nginx.virtualHosts = lib.mkOption { services.nginx.virtualHosts = lib.mkOption {
type = lib.types.attrsOf ( type = lib.types.attrsOf (

View file

@ -4,10 +4,7 @@ let
in in
{ {
options = { options = {
custom.services.certStoreClient.enable = lib.mkOption { custom.services.certStoreClient.enable = lib.mkEnableOption "cert-store client";
type = lib.types.bool;
default = false;
};
services.nginx.virtualHosts = lib.mkOption { services.nginx.virtualHosts = lib.mkOption {
type = lib.types.attrsOf ( type = lib.types.attrsOf (

View file

@ -4,10 +4,7 @@ let
in in
{ {
options = { options = {
custom.services.nginxHttpsServer.enable = lib.mkOption { custom.services.nginxHttpsServer.enable = lib.mkEnableOption "default nginx HTTPS server configuration";
type = lib.types.bool;
default = false;
};
services.nginx.virtualHosts = lib.mkOption { services.nginx.virtualHosts = lib.mkOption {
type = lib.types.attrsOf ( type = lib.types.attrsOf (

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.services.vaultwarden; cfg = config.custom.services.vaultwarden;
in in
{ {
options.custom.services.vaultwarden.enable = lib.mkOption { options.custom.services.vaultwarden.enable = lib.mkEnableOption "self-hosted Vaultwarden instance";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
custom.services = { custom.services = {

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.users.vili; cfg = config.custom.users.vili;
in in
{ {
options.custom.users.vili.enable = lib.mkOption { options.custom.users.vili.enable = lib.mkEnableOption "user 'vili'";
type = lib.types.bool;
default = false;
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
sops.secrets = sops.secrets =