From 0f90bcfd707f2b8a50e65fedcd1cfcb9571695b6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 10 Dec 2024 21:40:33 +0000 Subject: [PATCH] Simplify use of `lib` --- nix/modules/home-manager/features/cli/bluetuith.nix | 8 +++++--- nix/modules/home-manager/features/cli/direnv.nix | 8 +++++--- nix/modules/home-manager/features/cli/neovim.nix | 8 +++++--- .../home-manager/features/cli/tmux-sessionizer.nix | 8 +++++--- nix/modules/home-manager/features/cli/tmux.nix | 6 ++++-- nix/modules/home-manager/features/desktop/alacritty.nix | 8 +++++--- nix/modules/home-manager/features/desktop/copyq.nix | 8 +++++--- nix/modules/home-manager/features/desktop/discord.nix | 8 +++++--- nix/modules/home-manager/features/desktop/espanso.nix | 8 +++++--- nix/modules/home-manager/features/desktop/flameshot.nix | 8 +++++--- nix/modules/home-manager/features/desktop/gtk.nix | 8 +++++--- nix/modules/home-manager/features/desktop/media/gimp.nix | 8 +++++--- .../home-manager/features/desktop/media/handbrake.nix | 8 +++++--- .../home-manager/features/desktop/media/kdenlive.nix | 8 +++++--- nix/modules/home-manager/features/desktop/media/mpv.nix | 8 +++++--- .../home-manager/features/desktop/media/pocket-casts.nix | 8 +++++--- nix/modules/home-manager/features/desktop/slack.nix | 8 +++++--- nix/modules/home-manager/features/desktop/zoom.nix | 8 +++++--- nix/modules/nixos/features/cli/docker.nix | 8 +++++--- nix/modules/nixos/features/desktop/peek.nix | 8 +++++--- nix/modules/nixos/features/desktop/screenkey.nix | 8 +++++--- nix/modules/nixos/features/gaming.nix | 8 +++++--- nix/modules/nixos/features/homelab/gitea.nix | 8 +++++--- nix/modules/nixos/features/homelab/immich.nix | 8 +++++--- nix/modules/nixos/features/homelab/jellyfin.nix | 8 +++++--- 25 files changed, 124 insertions(+), 74 deletions(-) diff --git a/nix/modules/home-manager/features/cli/bluetuith.nix b/nix/modules/home-manager/features/cli/bluetuith.nix index f13fb00..e52812e 100644 --- a/nix/modules/home-manager/features/cli/bluetuith.nix +++ b/nix/modules/home-manager/features/cli/bluetuith.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.cli.bluetuith.enable = lib.mkEnableOption "Enable bluetuith"; +with lib; - config = lib.mkIf config.features.cli.bluetuith.enable { +{ + options.features.cli.bluetuith.enable = mkEnableOption "Enable bluetuith"; + + config = mkIf config.features.cli.bluetuith.enable { home.packages = with pkgs; [ bluetuith ]; diff --git a/nix/modules/home-manager/features/cli/direnv.nix b/nix/modules/home-manager/features/cli/direnv.nix index 59b4b76..0509ce5 100644 --- a/nix/modules/home-manager/features/cli/direnv.nix +++ b/nix/modules/home-manager/features/cli/direnv.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.cli.direnv.enable = lib.mkEnableOption "Enable direnv"; +with lib; - config = lib.mkIf config.features.cli.direnv.enable { +{ + options.features.cli.direnv.enable = mkEnableOption "Enable direnv"; + + config = mkIf config.features.cli.direnv.enable { programs.direnv = { enable = true; enableZshIntegration = true; diff --git a/nix/modules/home-manager/features/cli/neovim.nix b/nix/modules/home-manager/features/cli/neovim.nix index 30bb523..0dc4cea 100644 --- a/nix/modules/home-manager/features/cli/neovim.nix +++ b/nix/modules/home-manager/features/cli/neovim.nix @@ -6,10 +6,12 @@ ... }: -{ - options.features.cli.neovim.enable = lib.mkEnableOption "Enable neovim"; +with lib; - config = lib.mkIf config.features.cli.neovim.enable { +{ + options.features.cli.neovim.enable = mkEnableOption "Enable neovim"; + + config = mkIf config.features.cli.neovim.enable { programs.neovim = { enable = true; diff --git a/nix/modules/home-manager/features/cli/tmux-sessionizer.nix b/nix/modules/home-manager/features/cli/tmux-sessionizer.nix index 4aeba08..b41510e 100644 --- a/nix/modules/home-manager/features/cli/tmux-sessionizer.nix +++ b/nix/modules/home-manager/features/cli/tmux-sessionizer.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.cli.tmux-sessionizer.enable = lib.mkEnableOption "Enable tmux-sessionizer"; +with lib; - config = lib.mkIf config.features.cli.tmux-sessionizer.enable { +{ + options.features.cli.tmux-sessionizer.enable = mkEnableOption "Enable tmux-sessionizer"; + + config = mkIf config.features.cli.tmux-sessionizer.enable { home.packages = with pkgs; [ custom-tmux-sessionizer ]; home.file.".tmux-sessionizer".source = "${ diff --git a/nix/modules/home-manager/features/cli/tmux.nix b/nix/modules/home-manager/features/cli/tmux.nix index 47b7055..49aa00f 100644 --- a/nix/modules/home-manager/features/cli/tmux.nix +++ b/nix/modules/home-manager/features/cli/tmux.nix @@ -5,13 +5,15 @@ ... }: +with lib; + let inherit (pkgs) tmuxPlugins; in { - options.features.cli.tmux.enable = lib.mkEnableOption "Enable tmux"; + options.features.cli.tmux.enable = mkEnableOption "Enable tmux"; - config = lib.mkIf config.features.cli.tmux.enable { + config = mkIf config.features.cli.tmux.enable { programs.tmux = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/alacritty.nix b/nix/modules/home-manager/features/desktop/alacritty.nix index 2b351a6..77cc625 100644 --- a/nix/modules/home-manager/features/desktop/alacritty.nix +++ b/nix/modules/home-manager/features/desktop/alacritty.nix @@ -4,10 +4,12 @@ ... }: -{ - options.features.desktop.alacritty.enable = lib.mkEnableOption "Enable Alacritty"; +with lib; - config = lib.mkIf config.features.desktop.alacritty.enable { +{ + options.features.desktop.alacritty.enable = mkEnableOption "Enable Alacritty"; + + config = mkIf config.features.desktop.alacritty.enable { programs.alacritty = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/copyq.nix b/nix/modules/home-manager/features/desktop/copyq.nix index fba783e..7a4ca6a 100644 --- a/nix/modules/home-manager/features/desktop/copyq.nix +++ b/nix/modules/home-manager/features/desktop/copyq.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.desktop.copyq.enable = lib.mkEnableOption "Enable copyq"; +with lib; - config = lib.mkIf config.features.desktop.copyq.enable { +{ + options.features.desktop.copyq.enable = mkEnableOption "Enable copyq"; + + config = mkIf config.features.desktop.copyq.enable { services.copyq.enable = true; }; } diff --git a/nix/modules/home-manager/features/desktop/discord.nix b/nix/modules/home-manager/features/desktop/discord.nix index 5fed5da..abf8cd8 100644 --- a/nix/modules/home-manager/features/desktop/discord.nix +++ b/nix/modules/home-manager/features/desktop/discord.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.discord.enable = lib.mkEnableOption "Enable Discord"; +with lib; - config = lib.mkIf config.features.desktop.discord.enable { +{ + options.features.desktop.discord.enable = mkEnableOption "Enable Discord"; + + config = mkIf config.features.desktop.discord.enable { home.packages = with pkgs; [ discord ]; }; } diff --git a/nix/modules/home-manager/features/desktop/espanso.nix b/nix/modules/home-manager/features/desktop/espanso.nix index 8619a29..9f3d0be 100644 --- a/nix/modules/home-manager/features/desktop/espanso.nix +++ b/nix/modules/home-manager/features/desktop/espanso.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.desktop.espanso.enable = lib.mkEnableOption "Enable espanso"; +with lib; - config = lib.mkIf config.features.desktop.espanso.enable { +{ + options.features.desktop.espanso.enable = mkEnableOption "Enable espanso"; + + config = mkIf config.features.desktop.espanso.enable { services.espanso = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/flameshot.nix b/nix/modules/home-manager/features/desktop/flameshot.nix index c5540fd..d9a77d8 100644 --- a/nix/modules/home-manager/features/desktop/flameshot.nix +++ b/nix/modules/home-manager/features/desktop/flameshot.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.flameshot.enable = lib.mkEnableOption "Enable flameshot"; +with lib; - config = lib.mkIf config.features.desktop.flameshot.enable { +{ + options.features.desktop.flameshot.enable = mkEnableOption "Enable flameshot"; + + config = mkIf config.features.desktop.flameshot.enable { services.flameshot = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/gtk.nix b/nix/modules/home-manager/features/desktop/gtk.nix index 7644b6c..f68563b 100644 --- a/nix/modules/home-manager/features/desktop/gtk.nix +++ b/nix/modules/home-manager/features/desktop/gtk.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.gtk.enable = lib.mkEnableOption "Enable gtk"; +with lib; - config = lib.mkIf config.features.desktop.gtk.enable { +{ + options.features.desktop.gtk.enable = mkEnableOption "Enable gtk"; + + config = mkIf config.features.desktop.gtk.enable { gtk = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/media/gimp.nix b/nix/modules/home-manager/features/desktop/media/gimp.nix index 8597aeb..db01267 100644 --- a/nix/modules/home-manager/features/desktop/media/gimp.nix +++ b/nix/modules/home-manager/features/desktop/media/gimp.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.media.gimp.enable = lib.mkEnableOption "Enable gimp"; +with lib; - config = lib.mkIf config.features.desktop.media.gimp.enable { +{ + options.features.desktop.media.gimp.enable = mkEnableOption "Enable gimp"; + + config = mkIf config.features.desktop.media.gimp.enable { home.packages = with pkgs; [ gimp ]; }; } diff --git a/nix/modules/home-manager/features/desktop/media/handbrake.nix b/nix/modules/home-manager/features/desktop/media/handbrake.nix index 412b9fa..e27a215 100644 --- a/nix/modules/home-manager/features/desktop/media/handbrake.nix +++ b/nix/modules/home-manager/features/desktop/media/handbrake.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.media.handbrake.enable = lib.mkEnableOption "Enable handbrake"; +with lib; - config = lib.mkIf config.features.desktop.media.handbrake.enable { +{ + options.features.desktop.media.handbrake.enable = mkEnableOption "Enable handbrake"; + + config = mkIf config.features.desktop.media.handbrake.enable { home.packages = with pkgs; [ handbrake ]; }; } diff --git a/nix/modules/home-manager/features/desktop/media/kdenlive.nix b/nix/modules/home-manager/features/desktop/media/kdenlive.nix index b6f7b21..7069540 100644 --- a/nix/modules/home-manager/features/desktop/media/kdenlive.nix +++ b/nix/modules/home-manager/features/desktop/media/kdenlive.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.media.kdenlive.enable = lib.mkEnableOption "Enable kdenlive"; +with lib; - config = lib.mkIf config.features.desktop.media.kdenlive.enable { +{ + options.features.desktop.media.kdenlive.enable = mkEnableOption "Enable kdenlive"; + + config = mkIf config.features.desktop.media.kdenlive.enable { home.packages = with pkgs; [ kdenlive ]; }; } diff --git a/nix/modules/home-manager/features/desktop/media/mpv.nix b/nix/modules/home-manager/features/desktop/media/mpv.nix index f06a6e2..2704dad 100644 --- a/nix/modules/home-manager/features/desktop/media/mpv.nix +++ b/nix/modules/home-manager/features/desktop/media/mpv.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.desktop.media.mpv.enable = lib.mkEnableOption "Enable mpv media player"; +with lib; - config = lib.mkIf config.features.desktop.media.mpv.enable { +{ + options.features.desktop.media.mpv.enable = mkEnableOption "Enable mpv media player"; + + config = mkIf config.features.desktop.media.mpv.enable { programs.mpv = { enable = true; diff --git a/nix/modules/home-manager/features/desktop/media/pocket-casts.nix b/nix/modules/home-manager/features/desktop/media/pocket-casts.nix index 6f088c4..d71183b 100644 --- a/nix/modules/home-manager/features/desktop/media/pocket-casts.nix +++ b/nix/modules/home-manager/features/desktop/media/pocket-casts.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.media.pocket-casts.enable = lib.mkEnableOption "Enable Pocket Casts"; +with lib; - config = lib.mkIf config.features.desktop.media.pocket-casts.enable { +{ + options.features.desktop.media.pocket-casts.enable = mkEnableOption "Enable Pocket Casts"; + + config = mkIf config.features.desktop.media.pocket-casts.enable { home.packages = with pkgs; [ pocket-casts ]; }; } diff --git a/nix/modules/home-manager/features/desktop/slack.nix b/nix/modules/home-manager/features/desktop/slack.nix index 463a91e..344cf86 100644 --- a/nix/modules/home-manager/features/desktop/slack.nix +++ b/nix/modules/home-manager/features/desktop/slack.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.slack.enable = lib.mkEnableOption "Enable Slack"; +with lib; - config = lib.mkIf config.features.desktop.slack.enable { +{ + options.features.desktop.slack.enable = mkEnableOption "Enable Slack"; + + config = mkIf config.features.desktop.slack.enable { home.packages = with pkgs; [ slack ]; }; } diff --git a/nix/modules/home-manager/features/desktop/zoom.nix b/nix/modules/home-manager/features/desktop/zoom.nix index d1a6c45..417d78e 100644 --- a/nix/modules/home-manager/features/desktop/zoom.nix +++ b/nix/modules/home-manager/features/desktop/zoom.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.zoom.enable = lib.mkEnableOption "Enable zoom"; +with lib; - config = lib.mkIf config.features.desktop.zoom.enable { +{ + options.features.desktop.zoom.enable = mkEnableOption "Enable zoom"; + + config = mkIf config.features.desktop.zoom.enable { home.packages = with pkgs; [ nixpkgs-2405.zoom-us ]; }; } diff --git a/nix/modules/nixos/features/cli/docker.nix b/nix/modules/nixos/features/cli/docker.nix index 8aa1232..10e4263 100644 --- a/nix/modules/nixos/features/cli/docker.nix +++ b/nix/modules/nixos/features/cli/docker.nix @@ -1,9 +1,11 @@ { lib, config, ... }: -{ - options.features.cli.docker.enable = lib.mkEnableOption "Enable Docker"; +with lib; - config = lib.mkIf config.features.cli.docker.enable { +{ + options.features.cli.docker.enable = mkEnableOption "Enable Docker"; + + config = mkIf config.features.cli.docker.enable { virtualisation.docker = { enable = true; diff --git a/nix/modules/nixos/features/desktop/peek.nix b/nix/modules/nixos/features/desktop/peek.nix index da593d7..85137d9 100644 --- a/nix/modules/nixos/features/desktop/peek.nix +++ b/nix/modules/nixos/features/desktop/peek.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.peek.enable = lib.mkEnableOption "Enable peek"; +with lib; - config = lib.mkIf config.features.desktop.peek.enable { +{ + options.features.desktop.peek.enable = mkEnableOption "Enable peek"; + + config = mkIf config.features.desktop.peek.enable { environment.systemPackages = with pkgs; [ peek ]; }; } diff --git a/nix/modules/nixos/features/desktop/screenkey.nix b/nix/modules/nixos/features/desktop/screenkey.nix index 185de46..9bebebf 100644 --- a/nix/modules/nixos/features/desktop/screenkey.nix +++ b/nix/modules/nixos/features/desktop/screenkey.nix @@ -6,10 +6,12 @@ ... }: -{ - options.features.desktop.screenkey.enable = lib.mkEnableOption "Enable screenkey"; +with lib; - config = lib.mkIf config.features.desktop.screenkey.enable { +{ + options.features.desktop.screenkey.enable = mkEnableOption "Enable screenkey"; + + config = mkIf config.features.desktop.screenkey.enable { environment.systemPackages = with pkgs; [ screenkey ]; home-manager.users.${username}.xdg.configFile."screenkey.json".text = builtins.toJSON { diff --git a/nix/modules/nixos/features/gaming.nix b/nix/modules/nixos/features/gaming.nix index d7dd074..c8f4d40 100644 --- a/nix/modules/nixos/features/gaming.nix +++ b/nix/modules/nixos/features/gaming.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.desktop.gaming.enable = lib.mkEnableOption "Enable games"; +with lib; - config = lib.mkIf config.features.desktop.gaming.enable { +{ + options.features.desktop.gaming.enable = mkEnableOption "Enable games"; + + config = mkIf config.features.desktop.gaming.enable { programs.steam.enable = true; environment.systemPackages = with pkgs; [ zeroad ]; diff --git a/nix/modules/nixos/features/homelab/gitea.nix b/nix/modules/nixos/features/homelab/gitea.nix index 47d1760..4667e43 100644 --- a/nix/modules/nixos/features/homelab/gitea.nix +++ b/nix/modules/nixos/features/homelab/gitea.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.homelab.gitea.enable = lib.mkEnableOption "Enable gitea"; +with lib; - config = lib.mkIf config.features.homelab.gitea.enable { +{ + options.features.homelab.gitea.enable = mkEnableOption "Enable gitea"; + + config = mkIf config.features.homelab.gitea.enable { services.gitea = { enable = true; diff --git a/nix/modules/nixos/features/homelab/immich.nix b/nix/modules/nixos/features/homelab/immich.nix index 6bd923c..8b4a5f5 100644 --- a/nix/modules/nixos/features/homelab/immich.nix +++ b/nix/modules/nixos/features/homelab/immich.nix @@ -5,10 +5,12 @@ ... }: -{ - options.features.homelab.immich.enable = lib.mkEnableOption "Enable immich"; +with lib; - config = lib.mkIf config.features.homelab.immich.enable { +{ + options.features.homelab.immich.enable = mkEnableOption "Enable immich"; + + config = mkIf config.features.homelab.immich.enable { services.immich.enable = true; environment.systemPackages = [ pkgs.immich-cli ]; diff --git a/nix/modules/nixos/features/homelab/jellyfin.nix b/nix/modules/nixos/features/homelab/jellyfin.nix index f650ca0..0ac9fef 100644 --- a/nix/modules/nixos/features/homelab/jellyfin.nix +++ b/nix/modules/nixos/features/homelab/jellyfin.nix @@ -1,9 +1,11 @@ { config, lib, ... }: -{ - options.features.homelab.jellyfin.enable = lib.mkEnableOption "Enable jellyfin"; +with lib; - config = lib.mkIf config.features.homelab.jellyfin.enable { +{ + options.features.homelab.jellyfin.enable = mkEnableOption "Enable jellyfin"; + + config = mkIf config.features.homelab.jellyfin.enable { services.jellyfin = { enable = true; openFirewall = true;