From 124d6b7edebe4ba098b366b41d7d75404dc7f683 Mon Sep 17 00:00:00 2001 From: Jo Date: Fri, 31 Jan 2025 01:10:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=E2=9A=A1=EF=B8=8F=20remove?= =?UTF-8?q?=20`with=20lib;`=20everywhere=20and=20partially=20switch=20to?= =?UTF-8?q?=20mkOpt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homes/x86_64-linux/cyn@absolutesolver/default.nix | 4 +--- lib/module/default.nix | 7 +++++-- modules/home/desktop/gnome/default.nix | 12 +++++++----- modules/home/palette/default.nix | 6 +++--- modules/home/themes/catppuccin/gnome/default.nix | 4 +++- modules/nixos/admin/default.nix | 3 +-- modules/nixos/archetypes/server/default.nix | 3 ++- modules/nixos/archetypes/workstation/default.nix | 3 ++- modules/nixos/common/audio/default.nix | 3 ++- modules/nixos/common/bluetooth/default.nix | 3 ++- modules/nixos/common/fonts/default.nix | 5 +++-- modules/nixos/common/grub/default.nix | 3 ++- modules/nixos/common/hardware/default.nix | 3 ++- modules/nixos/common/kernel/default.nix | 11 ++++------- modules/nixos/common/locale/default.nix | 9 +++++---- modules/nixos/common/nix/default.nix | 3 ++- modules/nixos/desktop/gnome/default.nix | 3 ++- modules/nixos/desktop/plasma/default.nix | 5 +++-- modules/nixos/security/yubikey/default.nix | 5 +++-- modules/nixos/services/bluesky/pds/default.nix | 3 ++- modules/nixos/services/duckdns/default.nix | 3 ++- modules/nixos/services/homepage/default.nix | 4 +++- modules/nixos/services/sharkey/default.nix | 3 ++- modules/nixos/services/traefik/default.nix | 5 +++-- modules/nixos/services/vaultwarden/default.nix | 3 ++- modules/nixos/tools/cachix/default.nix | 6 +++--- systems/x86_64-linux/absolutesolver/default.nix | 3 +-- 27 files changed, 72 insertions(+), 53 deletions(-) diff --git a/homes/x86_64-linux/cyn@absolutesolver/default.nix b/homes/x86_64-linux/cyn@absolutesolver/default.nix index cb1d7d7..509682d 100644 --- a/homes/x86_64-linux/cyn@absolutesolver/default.nix +++ b/homes/x86_64-linux/cyn@absolutesolver/default.nix @@ -1,9 +1,7 @@ { - lib, pkgs, - namespace, ... -}: with lib; with lib.${namespace}; +}: { # Declare user packages. home.packages = with pkgs; [ diff --git a/lib/module/default.nix b/lib/module/default.nix index 6f99f78..386c102 100644 --- a/lib/module/default.nix +++ b/lib/module/default.nix @@ -1,8 +1,11 @@ { lib, ... -}: with lib; -rec { +}: +let + inherit (lib) mkOption; +in +{ ## Create a NixOS module option. (Stolen from Jake Hamilton) ## ## ```nix diff --git a/modules/home/desktop/gnome/default.nix b/modules/home/desktop/gnome/default.nix index 8f9701c..3b8384f 100644 --- a/modules/home/desktop/gnome/default.nix +++ b/modules/home/desktop/gnome/default.nix @@ -5,12 +5,14 @@ osConfig, namespace, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkIf mkOption; + inherit (lib.${namespace}) mkOpt; cfg = config.${namespace}.desktop.gnome; in { - options.${namespace}.desktop.gnome = with types; { + options.${namespace}.desktop.gnome = with lib.types; { enabled-extensions = mkOption { type = listOf package; default = with pkgs.gnomeExtensions; [ dash-to-dock user-themes blur-my-shell appindicator unite color-picker clipboard-history ]; @@ -19,7 +21,7 @@ in }; favorite-apps = mkOption { type = listOf str; - default = ["org.gnome.Nautilus.desktop" "obsidian.desktop" "zen.desktop" "dev.zed.Zed.desktop"]; + default = ["org.gnome.Nautilus.desktop" "obsidian.desktop" "firefox.desktop" "dev.zed.Zed.desktop"]; example = ["org.gnome.Nautilus.desktop" "obsidian.desktop"]; description = "Specify your favorite apps (sorted left to right)."; }; @@ -42,7 +44,7 @@ in enable-blur = mkOpt bool false "Whether to enable blur-my-shell application blur."; }; }; - wallpaper = mkOpt str (builtins.toString ./wallpapers/abstract/amber-d.jxl) "Specify the path of your prefered Gnome wallpaper."; + wallpaper = mkOpt str (builtins.toString ./wallpapers/arcane/jinx_flare.jpg) "Specify the path of your prefered Gnome wallpaper."; }; config = mkIf osConfig.${namespace}.desktop.gnome.enable { @@ -51,7 +53,7 @@ in dconf.settings = { "org/gnome/shell" = { favorite-apps = cfg.favorite-apps; - enabled-extensions = forEach cfg.enabled-extensions (x: x.extensionUuid); + enabled-extensions = lib.forEach cfg.enabled-extensions (x: x.extensionUuid); disabled-extensions = []; # Make sure none of our extensions are disabled on system rebuild }; "org/gnome/shell/extensions/unite" = mkIf (builtins.elem pkgs.gnomeExtensions.unite cfg.enabled-extensions) { diff --git a/modules/home/palette/default.nix b/modules/home/palette/default.nix index b1b2439..efec6fb 100644 --- a/modules/home/palette/default.nix +++ b/modules/home/palette/default.nix @@ -1,15 +1,15 @@ { lib, - namespace, config, pkgs, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkOption; palette = (pkgs.lib.importJSON (config.catppuccin.sources.palette + "/palette.json")).${config.catppuccin.flavor}.colors; in { - options.palette = mkOption { type = types.attrsOf types.raw; }; + options.palette = mkOption { type = lib.types.attrsOf lib.types.raw; }; config = { inherit palette; diff --git a/modules/home/themes/catppuccin/gnome/default.nix b/modules/home/themes/catppuccin/gnome/default.nix index 265f883..ca6c9df 100644 --- a/modules/home/themes/catppuccin/gnome/default.nix +++ b/modules/home/themes/catppuccin/gnome/default.nix @@ -4,8 +4,10 @@ config, pkgs, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; + # Stolen from Oli @ git.gay, basically just themes default libadwaita components. css = pkgs.writeTextFile { name = "gtk-css"; diff --git a/modules/nixos/admin/default.nix b/modules/nixos/admin/default.nix index bb2d1fe..96a6be1 100644 --- a/modules/nixos/admin/default.nix +++ b/modules/nixos/admin/default.nix @@ -4,11 +4,10 @@ ... }: let - inherit (lib) types; inherit (lib.${namespace}) mkOpt; in { - options.${namespace}.admin = with types; { + options.${namespace}.admin = with lib.types; { name = mkOpt str "Jo" "The short name of the system admin."; full-name = mkOpt str "Johannes Reckers" "The full name of the system admin."; email = mkOpt str "system@thevoid.cafe" "The E-Mail of the system admin. (Used for system services by default)"; diff --git a/modules/nixos/archetypes/server/default.nix b/modules/nixos/archetypes/server/default.nix index 6d44abb..d979720 100644 --- a/modules/nixos/archetypes/server/default.nix +++ b/modules/nixos/archetypes/server/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.archetypes.server; in { options.${namespace}.archetypes.server = { enable = mkEnableOption "Enable the server archetype for your current system"; }; diff --git a/modules/nixos/archetypes/workstation/default.nix b/modules/nixos/archetypes/workstation/default.nix index 2993636..c1f15a9 100644 --- a/modules/nixos/archetypes/workstation/default.nix +++ b/modules/nixos/archetypes/workstation/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.archetypes.workstation; in { options.${namespace}.archetypes.workstation = { enable = mkEnableOption "Enable the workstation archetype for your current system"; }; diff --git a/modules/nixos/common/audio/default.nix b/modules/nixos/common/audio/default.nix index a117a1b..c2b1a7f 100644 --- a/modules/nixos/common/audio/default.nix +++ b/modules/nixos/common/audio/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.common.audio; in { options.${namespace}.common.audio = { enable = mkEnableOption "whether to enable common audio support and tweaks"; }; diff --git a/modules/nixos/common/bluetooth/default.nix b/modules/nixos/common/bluetooth/default.nix index 2271e8b..c508644 100644 --- a/modules/nixos/common/bluetooth/default.nix +++ b/modules/nixos/common/bluetooth/default.nix @@ -4,8 +4,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.common.bluetooth; in { options.${namespace}.common.bluetooth = { enable = mkEnableOption "Enable bluetooth support on your current system"; }; diff --git a/modules/nixos/common/fonts/default.nix b/modules/nixos/common/fonts/default.nix index 3284cc9..9f6eb1d 100644 --- a/modules/nixos/common/fonts/default.nix +++ b/modules/nixos/common/fonts/default.nix @@ -4,11 +4,12 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf mkOption; cfg = config.${namespace}.common.fonts; in { - options.${namespace}.common.fonts = with types; { + options.${namespace}.common.fonts = with lib.types; { enable = mkEnableOption "Enable system font management"; fonts = mkOption { type = listOf package; diff --git a/modules/nixos/common/grub/default.nix b/modules/nixos/common/grub/default.nix index 5031ed2..0b21337 100644 --- a/modules/nixos/common/grub/default.nix +++ b/modules/nixos/common/grub/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.common.grub; in { options.${namespace}.common.grub = { enable = mkEnableOption "grub"; }; diff --git a/modules/nixos/common/hardware/default.nix b/modules/nixos/common/hardware/default.nix index 23106e8..81a1f46 100644 --- a/modules/nixos/common/hardware/default.nix +++ b/modules/nixos/common/hardware/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.common.hardware; in { options.${namespace}.common.hardware = { enable = mkEnableOption "whether to enable common hardware support"; }; diff --git a/modules/nixos/common/kernel/default.nix b/modules/nixos/common/kernel/default.nix index e5fbbbd..69b4248 100644 --- a/modules/nixos/common/kernel/default.nix +++ b/modules/nixos/common/kernel/default.nix @@ -4,18 +4,15 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; + inherit (lib.${namespace}) mkOpt; cfg = config.${namespace}.common.kernel; in { options.${namespace}.common.kernel = { enable = mkEnableOption "Modify the standard kernel settings"; - version = mkOption { - type = types.str; - default = "linuxPackages_latest"; - example = "linuxPackages_latest"; - description = "Set the kernel version to be used by your system"; - }; + version = mkOpt lib.types.str "linuxPackages_latest" "Set the kernel version to be used by your system"; }; config = mkIf cfg.enable { diff --git a/modules/nixos/common/locale/default.nix b/modules/nixos/common/locale/default.nix index 7ac250a..5a792bf 100644 --- a/modules/nixos/common/locale/default.nix +++ b/modules/nixos/common/locale/default.nix @@ -3,29 +3,30 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf mkOption; cfg = config.${namespace}.common.locale; in { options.${namespace}.common.locale = { enable = mkEnableOption "whether to enable common locale tweaks"; language = mkOption { - type = types.str; + type = lib.types.str; default = "en_US"; example = "en_US"; description = "Sets the language for most text, doesn't include monetary or measurement settings"; }; country = mkOption { - type = types.str; + type = lib.types.str; default = "de_DE"; example = "de_DE"; description = "Sets the language used for monetary or measurement settings (USD vs Euro, etc...)"; }; keymap = mkOption { - type = types.str; + type = lib.types.str; default = "de"; example = "de"; description = "Sets the keymap to be used by the system"; diff --git a/modules/nixos/common/nix/default.nix b/modules/nixos/common/nix/default.nix index 6b1628d..b1868d1 100644 --- a/modules/nixos/common/nix/default.nix +++ b/modules/nixos/common/nix/default.nix @@ -4,8 +4,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.common.nix; in { options.${namespace}.common.nix = { diff --git a/modules/nixos/desktop/gnome/default.nix b/modules/nixos/desktop/gnome/default.nix index 3025a1f..89be810 100644 --- a/modules/nixos/desktop/gnome/default.nix +++ b/modules/nixos/desktop/gnome/default.nix @@ -4,8 +4,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.desktop.gnome; in { options.${namespace}.desktop.gnome = { enable = mkEnableOption "gnome"; }; diff --git a/modules/nixos/desktop/plasma/default.nix b/modules/nixos/desktop/plasma/default.nix index 628f118..348a49a 100644 --- a/modules/nixos/desktop/plasma/default.nix +++ b/modules/nixos/desktop/plasma/default.nix @@ -3,8 +3,9 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.desktop.plasma; in { options.${namespace}.desktop.plasma = { enable = mkEnableOption "Whether to enable the KDE Plasma desktop environment"; }; @@ -17,4 +18,4 @@ in { programs.kdeconnect.enable = true; }; -} \ No newline at end of file +} diff --git a/modules/nixos/security/yubikey/default.nix b/modules/nixos/security/yubikey/default.nix index d4c8cd3..90ee33e 100644 --- a/modules/nixos/security/yubikey/default.nix +++ b/modules/nixos/security/yubikey/default.nix @@ -4,12 +4,13 @@ config, namespace, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf mkOption; cfg = config.${namespace}.security.yubikey; in { - options.${namespace}.security.yubikey = with types; { + options.${namespace}.security.yubikey = with lib.types; { enable = mkEnableOption "Enable the Yubikey as a security device."; key-id = mkOption { type = listOf str; diff --git a/modules/nixos/services/bluesky/pds/default.nix b/modules/nixos/services/bluesky/pds/default.nix index 81f78c9..aae99a8 100644 --- a/modules/nixos/services/bluesky/pds/default.nix +++ b/modules/nixos/services/bluesky/pds/default.nix @@ -4,8 +4,9 @@ config, host, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.services.bluesky.pds; in { options.${namespace}.services.bluesky.pds = { diff --git a/modules/nixos/services/duckdns/default.nix b/modules/nixos/services/duckdns/default.nix index e24d864..49def34 100644 --- a/modules/nixos/services/duckdns/default.nix +++ b/modules/nixos/services/duckdns/default.nix @@ -4,8 +4,9 @@ config, host, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.services.duckdns; in { options.${namespace}.services.duckdns = { diff --git a/modules/nixos/services/homepage/default.nix b/modules/nixos/services/homepage/default.nix index fa31f84..fe20073 100644 --- a/modules/nixos/services/homepage/default.nix +++ b/modules/nixos/services/homepage/default.nix @@ -4,9 +4,11 @@ config, host, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.services.homepage; + homepageConfigDirectory = lib.snowfall.fs.get-file "resources/services/homepage"; in { options.${namespace}.services.homepage = { enable = mkEnableOption "Enable Homepage, an intuitive dashboard for your services."; }; diff --git a/modules/nixos/services/sharkey/default.nix b/modules/nixos/services/sharkey/default.nix index 902298b..9061608 100644 --- a/modules/nixos/services/sharkey/default.nix +++ b/modules/nixos/services/sharkey/default.nix @@ -4,8 +4,9 @@ config, host, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.services.sharkey; in { options.${namespace}.services.sharkey = { enable = mkEnableOption "Enable Sharkey, the activitypub-based microblogging service."; }; diff --git a/modules/nixos/services/traefik/default.nix b/modules/nixos/services/traefik/default.nix index 645d69d..0fc27a0 100644 --- a/modules/nixos/services/traefik/default.nix +++ b/modules/nixos/services/traefik/default.nix @@ -3,14 +3,15 @@ namespace, config, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf mkOption; cfg = config.${namespace}.services.traefik; in { options.${namespace}.services.traefik = { enable = mkEnableOption "Enable the Traefik service."; cloudflareEmail = mkOption { - type = types.str; + type = lib.types.str; default = config.${namespace}.admin.email; example = "system@thevoid.cafe"; description = "Specify the E-Mail associated with your Cloudflare account for ACME."; diff --git a/modules/nixos/services/vaultwarden/default.nix b/modules/nixos/services/vaultwarden/default.nix index 019a728..b260dc8 100644 --- a/modules/nixos/services/vaultwarden/default.nix +++ b/modules/nixos/services/vaultwarden/default.nix @@ -4,8 +4,9 @@ config, host, ... -}: with lib; with lib.${namespace}; +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.services.vaultwarden; in { options.${namespace}.services.vaultwarden = { enable = mkEnableOption "Enable Vaultwarden, a self-hostable password manager."; }; diff --git a/modules/nixos/tools/cachix/default.nix b/modules/nixos/tools/cachix/default.nix index 14012db..daa513f 100644 --- a/modules/nixos/tools/cachix/default.nix +++ b/modules/nixos/tools/cachix/default.nix @@ -3,9 +3,10 @@ pkgs, namespace, config, - ... -}: with lib; with lib.${namespace}; + ... +}: let + inherit (lib) mkEnableOption mkIf; cfg = config.${namespace}.tools.cachix; in { options.${namespace}.tools.cachix = { enable = mkEnableOption "Enable the cachix binary cache service on your system."; }; @@ -14,4 +15,3 @@ in { environment.systemPackages = with pkgs; [ cachix ]; }; } - diff --git a/systems/x86_64-linux/absolutesolver/default.nix b/systems/x86_64-linux/absolutesolver/default.nix index e9572d8..a3071f8 100644 --- a/systems/x86_64-linux/absolutesolver/default.nix +++ b/systems/x86_64-linux/absolutesolver/default.nix @@ -2,9 +2,8 @@ lib, pkgs, inputs, - namespace, ... -}: with lib; with lib.${namespace}; +}: { imports = [ ./hardware-configuration.nix