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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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