♻️️ remove with lib; everywhere and partially switch to mkOpt

This commit is contained in:
Jo 2025-01-31 01:10:31 +01:00
parent c5283fe60b
commit 124d6b7ede
27 changed files with 72 additions and 53 deletions

View file

@ -1,9 +1,7 @@
{ {
lib,
pkgs, pkgs,
namespace,
... ...
}: with lib; with lib.${namespace}; }:
{ {
# Declare user packages. # Declare user packages.
home.packages = with pkgs; [ home.packages = with pkgs; [

View file

@ -1,8 +1,11 @@
{ {
lib, lib,
... ...
}: with lib; }:
rec { let
inherit (lib) mkOption;
in
{
## Create a NixOS module option. (Stolen from Jake Hamilton) ## Create a NixOS module option. (Stolen from Jake Hamilton)
## ##
## ```nix ## ```nix

View file

@ -5,12 +5,14 @@
osConfig, osConfig,
namespace, namespace,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkIf mkOption;
inherit (lib.${namespace}) mkOpt;
cfg = config.${namespace}.desktop.gnome; cfg = config.${namespace}.desktop.gnome;
in in
{ {
options.${namespace}.desktop.gnome = with types; { options.${namespace}.desktop.gnome = with lib.types; {
enabled-extensions = mkOption { enabled-extensions = mkOption {
type = listOf package; type = listOf package;
default = with pkgs.gnomeExtensions; [ dash-to-dock user-themes blur-my-shell appindicator unite color-picker clipboard-history ]; 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 { favorite-apps = mkOption {
type = listOf str; 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"]; example = ["org.gnome.Nautilus.desktop" "obsidian.desktop"];
description = "Specify your favorite apps (sorted left to right)."; 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."; 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 { config = mkIf osConfig.${namespace}.desktop.gnome.enable {
@ -51,7 +53,7 @@ in
dconf.settings = { dconf.settings = {
"org/gnome/shell" = { "org/gnome/shell" = {
favorite-apps = cfg.favorite-apps; 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 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) { "org/gnome/shell/extensions/unite" = mkIf (builtins.elem pkgs.gnomeExtensions.unite cfg.enabled-extensions) {

View file

@ -1,15 +1,15 @@
{ {
lib, lib,
namespace,
config, config,
pkgs, pkgs,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkOption;
palette = (pkgs.lib.importJSON (config.catppuccin.sources.palette + "/palette.json")).${config.catppuccin.flavor}.colors; palette = (pkgs.lib.importJSON (config.catppuccin.sources.palette + "/palette.json")).${config.catppuccin.flavor}.colors;
in in
{ {
options.palette = mkOption { type = types.attrsOf types.raw; }; options.palette = mkOption { type = lib.types.attrsOf lib.types.raw; };
config = { config = {
inherit palette; inherit palette;

View file

@ -4,8 +4,10 @@
config, config,
pkgs, pkgs,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
# Stolen from Oli @ git.gay, basically just themes default libadwaita components. # Stolen from Oli @ git.gay, basically just themes default libadwaita components.
css = pkgs.writeTextFile { css = pkgs.writeTextFile {
name = "gtk-css"; name = "gtk-css";

View file

@ -4,11 +4,10 @@
... ...
}: }:
let let
inherit (lib) types;
inherit (lib.${namespace}) mkOpt; inherit (lib.${namespace}) mkOpt;
in in
{ {
options.${namespace}.admin = with types; { options.${namespace}.admin = with lib.types; {
name = mkOpt str "Jo" "The short name of the system admin."; name = mkOpt str "Jo" "The short name of the system admin.";
full-name = mkOpt str "Johannes Reckers" "The full 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)"; email = mkOpt str "system@thevoid.cafe" "The E-Mail of the system admin. (Used for system services by default)";

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.archetypes.server; cfg = config.${namespace}.archetypes.server;
in { in {
options.${namespace}.archetypes.server = { enable = mkEnableOption "Enable the server archetype for your current system"; }; options.${namespace}.archetypes.server = { enable = mkEnableOption "Enable the server archetype for your current system"; };

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.archetypes.workstation; cfg = config.${namespace}.archetypes.workstation;
in { in {
options.${namespace}.archetypes.workstation = { enable = mkEnableOption "Enable the workstation archetype for your current system"; }; options.${namespace}.archetypes.workstation = { enable = mkEnableOption "Enable the workstation archetype for your current system"; };

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.common.audio; cfg = config.${namespace}.common.audio;
in { in {
options.${namespace}.common.audio = { enable = mkEnableOption "whether to enable common audio support and tweaks"; }; options.${namespace}.common.audio = { enable = mkEnableOption "whether to enable common audio support and tweaks"; };

View file

@ -4,8 +4,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.common.bluetooth; cfg = config.${namespace}.common.bluetooth;
in { in {
options.${namespace}.common.bluetooth = { enable = mkEnableOption "Enable bluetooth support on your current system"; }; options.${namespace}.common.bluetooth = { enable = mkEnableOption "Enable bluetooth support on your current system"; };

View file

@ -4,11 +4,12 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf mkOption;
cfg = config.${namespace}.common.fonts; cfg = config.${namespace}.common.fonts;
in { in {
options.${namespace}.common.fonts = with types; { options.${namespace}.common.fonts = with lib.types; {
enable = mkEnableOption "Enable system font management"; enable = mkEnableOption "Enable system font management";
fonts = mkOption { fonts = mkOption {
type = listOf package; type = listOf package;

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.common.grub; cfg = config.${namespace}.common.grub;
in { in {
options.${namespace}.common.grub = { enable = mkEnableOption "grub"; }; options.${namespace}.common.grub = { enable = mkEnableOption "grub"; };

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.common.hardware; cfg = config.${namespace}.common.hardware;
in { in {
options.${namespace}.common.hardware = { enable = mkEnableOption "whether to enable common hardware support"; }; options.${namespace}.common.hardware = { enable = mkEnableOption "whether to enable common hardware support"; };

View file

@ -4,18 +4,15 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
inherit (lib.${namespace}) mkOpt;
cfg = config.${namespace}.common.kernel; cfg = config.${namespace}.common.kernel;
in { in {
options.${namespace}.common.kernel = { options.${namespace}.common.kernel = {
enable = mkEnableOption "Modify the standard kernel settings"; enable = mkEnableOption "Modify the standard kernel settings";
version = mkOption { version = mkOpt lib.types.str "linuxPackages_latest" "Set the kernel version to be used by your system";
type = types.str;
default = "linuxPackages_latest";
example = "linuxPackages_latest";
description = "Set the kernel version to be used by your system";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -3,29 +3,30 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf mkOption;
cfg = config.${namespace}.common.locale; cfg = config.${namespace}.common.locale;
in { in {
options.${namespace}.common.locale = { options.${namespace}.common.locale = {
enable = mkEnableOption "whether to enable common locale tweaks"; enable = mkEnableOption "whether to enable common locale tweaks";
language = mkOption { language = mkOption {
type = types.str; type = lib.types.str;
default = "en_US"; default = "en_US";
example = "en_US"; example = "en_US";
description = "Sets the language for most text, doesn't include monetary or measurement settings"; description = "Sets the language for most text, doesn't include monetary or measurement settings";
}; };
country = mkOption { country = mkOption {
type = types.str; type = lib.types.str;
default = "de_DE"; default = "de_DE";
example = "de_DE"; example = "de_DE";
description = "Sets the language used for monetary or measurement settings (USD vs Euro, etc...)"; description = "Sets the language used for monetary or measurement settings (USD vs Euro, etc...)";
}; };
keymap = mkOption { keymap = mkOption {
type = types.str; type = lib.types.str;
default = "de"; default = "de";
example = "de"; example = "de";
description = "Sets the keymap to be used by the system"; description = "Sets the keymap to be used by the system";

View file

@ -4,8 +4,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.common.nix; cfg = config.${namespace}.common.nix;
in { in {
options.${namespace}.common.nix = { options.${namespace}.common.nix = {

View file

@ -4,8 +4,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.desktop.gnome; cfg = config.${namespace}.desktop.gnome;
in { in {
options.${namespace}.desktop.gnome = { enable = mkEnableOption "gnome"; }; options.${namespace}.desktop.gnome = { enable = mkEnableOption "gnome"; };

View file

@ -3,8 +3,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.desktop.plasma; cfg = config.${namespace}.desktop.plasma;
in { in {
options.${namespace}.desktop.plasma = { enable = mkEnableOption "Whether to enable the KDE Plasma desktop environment"; }; options.${namespace}.desktop.plasma = { enable = mkEnableOption "Whether to enable the KDE Plasma desktop environment"; };

View file

@ -4,12 +4,13 @@
config, config,
namespace, namespace,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf mkOption;
cfg = config.${namespace}.security.yubikey; cfg = config.${namespace}.security.yubikey;
in in
{ {
options.${namespace}.security.yubikey = with types; { options.${namespace}.security.yubikey = with lib.types; {
enable = mkEnableOption "Enable the Yubikey as a security device."; enable = mkEnableOption "Enable the Yubikey as a security device.";
key-id = mkOption { key-id = mkOption {
type = listOf str; type = listOf str;

View file

@ -4,8 +4,9 @@
config, config,
host, host,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.services.bluesky.pds; cfg = config.${namespace}.services.bluesky.pds;
in { in {
options.${namespace}.services.bluesky.pds = { options.${namespace}.services.bluesky.pds = {

View file

@ -4,8 +4,9 @@
config, config,
host, host,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.services.duckdns; cfg = config.${namespace}.services.duckdns;
in { in {
options.${namespace}.services.duckdns = { options.${namespace}.services.duckdns = {

View file

@ -4,9 +4,11 @@
config, config,
host, host,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.services.homepage; cfg = config.${namespace}.services.homepage;
homepageConfigDirectory = lib.snowfall.fs.get-file "resources/services/homepage"; homepageConfigDirectory = lib.snowfall.fs.get-file "resources/services/homepage";
in { in {
options.${namespace}.services.homepage = { enable = mkEnableOption "Enable Homepage, an intuitive dashboard for your services."; }; options.${namespace}.services.homepage = { enable = mkEnableOption "Enable Homepage, an intuitive dashboard for your services."; };

View file

@ -4,8 +4,9 @@
config, config,
host, host,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.services.sharkey; cfg = config.${namespace}.services.sharkey;
in { in {
options.${namespace}.services.sharkey = { enable = mkEnableOption "Enable Sharkey, the activitypub-based microblogging service."; }; options.${namespace}.services.sharkey = { enable = mkEnableOption "Enable Sharkey, the activitypub-based microblogging service."; };

View file

@ -3,14 +3,15 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf mkOption;
cfg = config.${namespace}.services.traefik; cfg = config.${namespace}.services.traefik;
in { in {
options.${namespace}.services.traefik = { options.${namespace}.services.traefik = {
enable = mkEnableOption "Enable the Traefik service."; enable = mkEnableOption "Enable the Traefik service.";
cloudflareEmail = mkOption { cloudflareEmail = mkOption {
type = types.str; type = lib.types.str;
default = config.${namespace}.admin.email; default = config.${namespace}.admin.email;
example = "system@thevoid.cafe"; example = "system@thevoid.cafe";
description = "Specify the E-Mail associated with your Cloudflare account for ACME."; description = "Specify the E-Mail associated with your Cloudflare account for ACME.";

View file

@ -4,8 +4,9 @@
config, config,
host, host,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.services.vaultwarden; cfg = config.${namespace}.services.vaultwarden;
in { in {
options.${namespace}.services.vaultwarden = { enable = mkEnableOption "Enable Vaultwarden, a self-hostable password manager."; }; options.${namespace}.services.vaultwarden = { enable = mkEnableOption "Enable Vaultwarden, a self-hostable password manager."; };

View file

@ -4,8 +4,9 @@
namespace, namespace,
config, config,
... ...
}: with lib; with lib.${namespace}; }:
let let
inherit (lib) mkEnableOption mkIf;
cfg = config.${namespace}.tools.cachix; cfg = config.${namespace}.tools.cachix;
in { in {
options.${namespace}.tools.cachix = { enable = mkEnableOption "Enable the cachix binary cache service on your system."; }; 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 ]; environment.systemPackages = with pkgs; [ cachix ];
}; };
} }

View file

@ -2,9 +2,8 @@
lib, lib,
pkgs, pkgs,
inputs, inputs,
namespace,
... ...
}: with lib; with lib.${namespace}; }:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix