From 4eddef07be2b771cbfe6628f17965f1165e22ef2 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sat, 12 Oct 2024 17:31:01 +0200 Subject: [PATCH] Nixos: Remove mkLink + mkEnableOpt and rename mkBoolOpt --- flake.nix | 3 ++ home/modules/0_template/options.nix | 2 +- .../1_deprecated/alacritty/options.nix | 2 +- home/modules/1_deprecated/audio/options.nix | 32 ++++++------- home/modules/1_deprecated/emacs/options.nix | 14 +++--- home/modules/1_deprecated/email/options.nix | 10 ++-- home/modules/1_deprecated/flatpak/options.nix | 24 +++++----- home/modules/1_deprecated/gaming/options.nix | 22 ++++----- home/modules/1_deprecated/helix/options.nix | 2 +- home/modules/1_deprecated/misc/options.nix | 10 ++-- .../1_deprecated/nextcloud/options.nix | 4 +- home/modules/1_deprecated/ranger/options.nix | 4 +- home/modules/1_deprecated/vscode/options.nix | 2 +- home/modules/chromium/options.nix | 4 +- home/modules/firefox/options.nix | 12 ++--- home/modules/fish/options.nix | 2 +- home/modules/hyprland/default.nix | 32 ++++++------- home/modules/hyprland/options.nix | 2 +- home/modules/kitty/options.nix | 2 +- home/modules/latex/options.nix | 2 +- home/modules/neovim/options.nix | 6 +-- home/modules/nnn/options.nix | 2 +- home/modules/rofi/default.nix | 12 ++--- home/modules/rofi/options.nix | 2 +- home/modules/waybar/options.nix | 2 +- home/modules/zathura/options.nix | 2 +- lib/default.nix | 3 ++ lib/modules.nix | 47 ++++++------------- lib/nixos.nix | 41 +++++++++------- system/modules/containers/options.nix | 20 ++++---- system/modules/polkit/options.nix | 2 +- system/modules/systemd-networkd/options.nix | 2 +- 32 files changed, 156 insertions(+), 172 deletions(-) diff --git a/flake.nix b/flake.nix index 68ac8512..b0a1b442 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,9 @@ inherit system; config.allowUnfree = true; + + # Alternative to setting config.allowUnfree. + # I read somewhere that this is more suitable when running HM standalone. config.allowUnfreePredicate = pkg: true; # Overlays define changes in the nixpkgs package set. diff --git a/home/modules/0_template/options.nix b/home/modules/0_template/options.nix index dca45c11..66d0e514 100644 --- a/home/modules/0_template/options.nix +++ b/home/modules/0_template/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "TEMPLATE"; + enable = mkEnableOption "TEMPLATE"; } diff --git a/home/modules/1_deprecated/alacritty/options.nix b/home/modules/1_deprecated/alacritty/options.nix index af6d51f3..898b152c 100644 --- a/home/modules/1_deprecated/alacritty/options.nix +++ b/home/modules/1_deprecated/alacritty/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Enable Alacritty"; + enable = mkEnableOption "Enable Alacritty"; } diff --git a/home/modules/1_deprecated/audio/options.nix b/home/modules/1_deprecated/audio/options.nix index e5af6132..b7bd470d 100644 --- a/home/modules/1_deprecated/audio/options.nix +++ b/home/modules/1_deprecated/audio/options.nix @@ -5,44 +5,44 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Audio module"; + enable = mkEnableOption "Audio module"; # TODO: Group these in categories (like instruments/VSTs or sth) # TODO: Make it easier to add many yes/no options, similar to the flatpak stuff # Hosts/Editing - carla.enable = mkEnableOpt "Carla (VST host)"; - bitwig.enable = mkEnableOpt "Bitwig (Digital audio workstation)"; - tenacity.enable = mkEnableOpt "Tenacity (Audacity fork)"; + carla.enable = mkEnableOption "Carla (VST host)"; + bitwig.enable = mkEnableOption "Bitwig (Digital audio workstation)"; + tenacity.enable = mkEnableOption "Tenacity (Audacity fork)"; # Instruments/Plugins - # vcvrack.enable = mkEnableOpt "VCV-Rack (Eurorack simulator)"; # Replaced by cardinal - cardinal.enable = mkEnableOpt "Open Source VCV-Rack plugin wrapper"; - # vital.enable = mkEnableOpt "Vital (Wavetable synthesizer)"; # Replaced by distrho - distrho.enable = mkEnableOpt "Distrho (Linux VST ports)"; + # vcvrack.enable = mkEnableOption "VCV-Rack (Eurorack simulator)"; # Replaced by cardinal + cardinal.enable = mkEnableOption "Open Source VCV-Rack plugin wrapper"; + # vital.enable = mkEnableOption "Vital (Wavetable synthesizer)"; # Replaced by distrho + distrho.enable = mkEnableOption "Distrho (Linux VST ports)"; # Misc - faust.enable = mkEnableOpt "Faust (functional DSP language)"; - bottles.enable = mkEnableOpt "Bottles (flatpak)"; + faust.enable = mkEnableOption "Faust (functional DSP language)"; + bottles.enable = mkEnableOption "Bottles (flatpak)"; # TODO: Automatically add the needed paths, depends on the bottle though # /home/christoph/.var/app/com.usebottles.bottles/data/bottles/bottles/Audio/drive_c/Program Files/Common Files/VST3 # /home/christoph/.var/app/com.usebottles.bottles/data/bottles/bottles/Audio/drive_c/Program Files/VstPlugins yabridge = { - enable = mkEnableOpt "Yabridge (Windows VST plugin manager)"; - autoSync = mkBoolOpt false "Sync yabridge plugins on nixos-rebuild"; + enable = mkEnableOption "Yabridge (Windows VST plugin manager)"; + autoSync = mkBoolOption false "Sync yabridge plugins on nixos-rebuild"; }; noisesuppression = { noisetorch = { - enable = mkEnableOpt "Noisetorch"; - autostart = mkBoolOpt false "Autoload Noisetorch suppression"; + enable = mkEnableOption "Noisetorch"; + autostart = mkBoolOption false "Autoload Noisetorch suppression"; }; # TODO: Store easyeffects presets/config (dconf com/github/wwmm/easyeffects ?) easyeffects = { - enable = mkEnableOpt "EasyEffects"; - autostart = mkBoolOpt false "Autoload EasyEffects suppression profile"; + enable = mkEnableOption "EasyEffects"; + autostart = mkBoolOption false "Autoload EasyEffects suppression profile"; }; }; } diff --git a/home/modules/1_deprecated/emacs/options.nix b/home/modules/1_deprecated/emacs/options.nix index bb44ddbb..a1512663 100644 --- a/home/modules/1_deprecated/emacs/options.nix +++ b/home/modules/1_deprecated/emacs/options.nix @@ -5,16 +5,16 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Emacs module"; + enable = mkEnableOption "Emacs module"; # TODO: Use an enum for this not individual options - nixpkgs = mkBoolOpt false "Use Emacs from the official repositories"; - nativeComp = mkBoolOpt false "Use Emacs 28.x branch with native comp support"; - pgtkNativeComp = mkBoolOpt false "Use Emacs 29.x branch with native comp and pure gtk support"; + nixpkgs = mkBoolOption false "Use Emacs from the official repositories"; + nativeComp = mkBoolOption false "Use Emacs 28.x branch with native comp support"; + pgtkNativeComp = mkBoolOption false "Use Emacs 29.x branch with native comp and pure gtk support"; doom = { - enable = mkEnableOpt "Doom Emacs framework"; - autoSync = mkBoolOpt false "Sync Doom Emacs on nixos-rebuild"; - autoUpgrade = mkBoolOpt false "Upgrade Doom Emacs on nixos-rebuild"; + enable = mkEnableOption "Doom Emacs framework"; + autoSync = mkBoolOption false "Sync Doom Emacs on nixos-rebuild"; + autoUpgrade = mkBoolOption false "Upgrade Doom Emacs on nixos-rebuild"; }; } diff --git a/home/modules/1_deprecated/email/options.nix b/home/modules/1_deprecated/email/options.nix index d48c564e..afa929da 100644 --- a/home/modules/1_deprecated/email/options.nix +++ b/home/modules/1_deprecated/email/options.nix @@ -5,12 +5,12 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Email"; - autosync = mkEnableOpt "Automatically call \"notmuch new\" via systemd timer"; - imapnotify = mkEnableOpt "Use imapnotify to sync and index mail automatically"; + enable = mkEnableOption "Email"; + autosync = mkEnableOption "Automatically call \"notmuch new\" via systemd timer"; + imapnotify = mkEnableOption "Use imapnotify to sync and index mail automatically"; kmail = { - enable = mkEnableOpt "Kmail"; - autostart = mkEnableOpt "Autostart Kmail"; + enable = mkEnableOption "Kmail"; + autostart = mkEnableOption "Autostart Kmail"; }; } diff --git a/home/modules/1_deprecated/flatpak/options.nix b/home/modules/1_deprecated/flatpak/options.nix index 37cde478..172da8e8 100644 --- a/home/modules/1_deprecated/flatpak/options.nix +++ b/home/modules/1_deprecated/flatpak/options.nix @@ -5,22 +5,22 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Flatpak module"; - fontFix = mkBoolOpt true "Link fonts to ~/.local/share/fonts so flatpak apps can find them"; - iconFix = mkBoolOpt true "Link icons to ~/.local/share/icons so flatpak apps can find them"; - autoUpdate = mkBoolOpt false "Update flatpak apps on nixos-rebuild"; - autoPrune = mkBoolOpt false "Remove unused packages on nixos-rebuild"; + enable = mkEnableOption "Flatpak module"; + fontFix = mkBoolOption true "Link fonts to ~/.local/share/fonts so flatpak apps can find them"; + iconFix = mkBoolOption true "Link icons to ~/.local/share/icons so flatpak apps can find them"; + autoUpdate = mkBoolOption false "Update flatpak apps on nixos-rebuild"; + autoPrune = mkBoolOption false "Remove unused packages on nixos-rebuild"; # TODO: Add library function to make this easier # TODO: The flatpak name should be included and a list of all enabled apps should be available # TODO: Do this for strings + packages - discord.enable = mkEnableOpt "Discord"; - spotify.enable = mkEnableOpt "Spotify"; - flatseal.enable = mkEnableOpt "Flatseal"; - bottles.enable = mkEnableOpt "Bottles"; - obsidian.enable = mkEnableOpt "Obsidian"; - jabref.enable = mkEnableOpt "Jabref"; - # xwaylandvideobridge = mkEnableOpt "XWayland Video Bridge"; # TODO + discord.enable = mkEnableOption "Discord"; + spotify.enable = mkEnableOption "Spotify"; + flatseal.enable = mkEnableOption "Flatseal"; + bottles.enable = mkEnableOption "Bottles"; + obsidian.enable = mkEnableOption "Obsidian"; + jabref.enable = mkEnableOption "Jabref"; + # xwaylandvideobridge = mkEnableOption "XWayland Video Bridge"; # TODO # TODO: Can I use extraInstall = { "com.valve.Steam" = true/false; } and pass the module option as value? # This is mainly used by other modules to allow them to use flatpak packages diff --git a/home/modules/1_deprecated/gaming/options.nix b/home/modules/1_deprecated/gaming/options.nix index 201b8469..cfb6ef82 100644 --- a/home/modules/1_deprecated/gaming/options.nix +++ b/home/modules/1_deprecated/gaming/options.nix @@ -5,19 +5,19 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Gaming module"; + enable = mkEnableOption "Gaming module"; - # discordElectron.enable = mkEnableOpt "Discord (Electron) (nixpkgs)"; - # discordChromium.enable = mkEnableOpt "Discord (Chromium)"; - prism.enable = mkEnableOpt "PrismLauncher for Minecraft (flatpak)"; - bottles.enable = mkEnableOpt "Bottles (flatpak)"; - # dwarffortress.enable = mkEnableOpt "Dwarf Fortress"; - cemu.enable = mkEnableOpt "Cemu (nixpkgs)"; + # discordElectron.enable = mkEnableOption "Discord (Electron) (nixpkgs)"; + # discordChromium.enable = mkEnableOption "Discord (Chromium)"; + prism.enable = mkEnableOption "PrismLauncher for Minecraft (flatpak)"; + bottles.enable = mkEnableOption "Bottles (flatpak)"; + # dwarffortress.enable = mkEnableOption "Dwarf Fortress"; + cemu.enable = mkEnableOption "Cemu (nixpkgs)"; steam = { - enable = mkEnableOpt "Steam (flatpak)"; - gamescope = mkBoolOpt false "Enable the gamescope micro compositor (flatpak)"; - adwaita = mkBoolOpt false "Enable the adwaita-for-steam skin"; - protonup = mkBoolOpt false "Enable ProtonUP-QT"; + enable = mkEnableOption "Steam (flatpak)"; + gamescope = mkBoolOption false "Enable the gamescope micro compositor (flatpak)"; + adwaita = mkBoolOption false "Enable the adwaita-for-steam skin"; + protonup = mkBoolOption false "Enable ProtonUP-QT"; }; } diff --git a/home/modules/1_deprecated/helix/options.nix b/home/modules/1_deprecated/helix/options.nix index 2557e1dd..725a601d 100644 --- a/home/modules/1_deprecated/helix/options.nix +++ b/home/modules/1_deprecated/helix/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Helix Editor"; + enable = mkEnableOption "Helix Editor"; } diff --git a/home/modules/1_deprecated/misc/options.nix b/home/modules/1_deprecated/misc/options.nix index a6751cab..6bf8de2d 100644 --- a/home/modules/1_deprecated/misc/options.nix +++ b/home/modules/1_deprecated/misc/options.nix @@ -5,15 +5,15 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Misc module"; + enable = mkEnableOption "Misc module"; keepass = { - enable = mkEnableOpt "KeePassXC"; - autostart = mkBoolOpt false "Autostart KeePassXC"; + enable = mkEnableOption "KeePassXC"; + autostart = mkBoolOption false "Autostart KeePassXC"; }; protonmail = { - enable = mkEnableOpt "ProtonMail"; - autostart = mkBoolOpt false "Autostart ProtonMail Bridge"; + enable = mkEnableOption "ProtonMail"; + autostart = mkBoolOption false "Autostart ProtonMail Bridge"; }; } diff --git a/home/modules/1_deprecated/nextcloud/options.nix b/home/modules/1_deprecated/nextcloud/options.nix index c93a5f80..2992b459 100644 --- a/home/modules/1_deprecated/nextcloud/options.nix +++ b/home/modules/1_deprecated/nextcloud/options.nix @@ -5,6 +5,6 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Nextcloud Client"; - autostart = mkBoolOpt false "Autostart the Nextcloud client (systemd)"; + enable = mkEnableOption "Nextcloud Client"; + autostart = mkBoolOption false "Autostart the Nextcloud client (systemd)"; } diff --git a/home/modules/1_deprecated/ranger/options.nix b/home/modules/1_deprecated/ranger/options.nix index 2abaaba5..49f05da3 100644 --- a/home/modules/1_deprecated/ranger/options.nix +++ b/home/modules/1_deprecated/ranger/options.nix @@ -5,6 +5,6 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Ranger"; - preview = mkBoolOpt false "Enable Ranger image preview"; + enable = mkEnableOption "Ranger"; + preview = mkBoolOption false "Enable Ranger image preview"; } diff --git a/home/modules/1_deprecated/vscode/options.nix b/home/modules/1_deprecated/vscode/options.nix index 4e1c7cb2..7a527d42 100644 --- a/home/modules/1_deprecated/vscode/options.nix +++ b/home/modules/1_deprecated/vscode/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Visual Studio Code"; + enable = mkEnableOption "Visual Studio Code"; } diff --git a/home/modules/chromium/options.nix b/home/modules/chromium/options.nix index 3538bf68..ce6da4f7 100644 --- a/home/modules/chromium/options.nix +++ b/home/modules/chromium/options.nix @@ -5,6 +5,6 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Chromium"; - google = mkEnableOpt "Google Chrome"; + enable = mkEnableOption "Chromium"; + google = mkEnableOption "Google Chrome"; } diff --git a/home/modules/firefox/options.nix b/home/modules/firefox/options.nix index 122fb554..ce1a078d 100644 --- a/home/modules/firefox/options.nix +++ b/home/modules/firefox/options.nix @@ -5,10 +5,10 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Firefox"; - wayland = mkBoolOpt false "Enable firefox wayland support"; - vaapi = mkBoolOpt false "Enable firefox vaapi support"; - disableTabBar = mkBoolOpt false "Disable the firefox tab bar (for TST)"; - defaultBookmarks = mkBoolOpt false "Preset standard bookmarks and folders"; - gnomeTheme = mkBoolOpt false "Use Firefox gnome theme (rafaelmardojai)"; + enable = mkEnableOption "Firefox"; + wayland = mkBoolOption false "Enable firefox wayland support"; + vaapi = mkBoolOption false "Enable firefox vaapi support"; + disableTabBar = mkBoolOption false "Disable the firefox tab bar (for TST)"; + defaultBookmarks = mkBoolOption false "Preset standard bookmarks and folders"; + gnomeTheme = mkBoolOption false "Use Firefox gnome theme (rafaelmardojai)"; } diff --git a/home/modules/fish/options.nix b/home/modules/fish/options.nix index a442f625..419702a2 100644 --- a/home/modules/fish/options.nix +++ b/home/modules/fish/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Fish"; + enable = mkEnableOption "Fish"; } diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index b69e1dae..cd8ec4fa 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -1,5 +1,6 @@ +# TODO: Use the home-manager module instead of generating my own scuffed config files +# # TODO: The keys to reset the workspaces need to depend on actual workspace config -# TODO: Many of the text file generations can be made simpler with pipe and concatLines functions... # TODO: The border color does not fit the current theme { config, @@ -39,7 +40,6 @@ in { }; services = { - # TODO: Make a module out of this # Notification service dunst = { enable = true; @@ -78,14 +78,11 @@ in { }; home = { - # TODO: catppuccin-cursors pointerCursor = { gtk.enable = true; x11.enable = true; package = pkgs.bibata-cursors; name = "Bibata-Modern-Classic"; - # package = pkgs.catppuccin-cursors.latteMauve; - # name = "Catppuccin-Latte-Mauve-Cursors"; size = 16; }; @@ -118,13 +115,22 @@ in { # file = { - # Polkit + # Link the main Hyprland configuration file. + # This file imports all the other generated files. + # TODO: Generate this, so only existing files are imported. + ".config/hypr/hyprland.conf".source = ../../../config/hyprland/hyprland.conf; + + # Provide a polkit authentication UI. + # This is used for example when running systemd commands without root. ".config/hypr/polkit.conf".text = '' - exec-once = ${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1 + exec-once = ${pkgs.kdePackages.polkit-kde-agent-1}/libexec/polkit-kde-authentication-agent-1 ''; - # Monitors for different systems + # Configure different monitors. ".config/hypr/monitors.conf".text = let + # This function is mapped to the "cfg.monitors" attrSet. + # For each key-value entry in "cfg.monitors", + # the key will be assigned to "name" and the value to "conf". mkMonitor = name: conf: "monitor = ${name}, ${toString conf.width}x${toString conf.height}@${toString conf.rate}, ${toString conf.x}x${toString conf.y}, ${toString conf.scale}"; in lib.pipe cfg.monitors [ @@ -133,7 +139,7 @@ in { (builtins.concatStringsSep "\n") ]; - # Bind workspaces to monitors + # Configure how workspaces are mapped to monitors. ".config/hypr/workspaces.conf".text = let mkWorkspace = monitor: workspace: "workspace = ${toString workspace}, monitor:${toString monitor}"; mkWorkspaces = monitor: workspace-list: map (mkWorkspace monitor) workspace-list; @@ -259,14 +265,6 @@ in { } ''; }; - - activation = { - # TODO: Don't symlink at all, why not just tell Hyprland where the config is? Much easier - # NOTE: Keep the hyprland config symlinked, to allow easy changes with hotreload - linkHyprlandConfig = - lib.hm.dag.entryAfter ["writeBoundary"] - (mylib.modules.mkLink "~/NixFlake/config/hyprland/hyprland.conf" "~/.config/hypr/hyprland.conf"); - }; }; }; } diff --git a/home/modules/hyprland/options.nix b/home/modules/hyprland/options.nix index a17a1e3e..17d84bdb 100644 --- a/home/modules/hyprland/options.nix +++ b/home/modules/hyprland/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Hyprland Window Manager + Compositor"; + enable = mkEnableOption "Hyprland Window Manager + Compositor"; kb-layout = mkOption { type = types.str; diff --git a/home/modules/kitty/options.nix b/home/modules/kitty/options.nix index 2f00e47e..3a726b4d 100644 --- a/home/modules/kitty/options.nix +++ b/home/modules/kitty/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Kitty"; + enable = mkEnableOption "Kitty"; } diff --git a/home/modules/latex/options.nix b/home/modules/latex/options.nix index bb4f9231..5d0c56a3 100644 --- a/home/modules/latex/options.nix +++ b/home/modules/latex/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Enable LaTeX"; + enable = mkEnableOption "Enable LaTeX"; } diff --git a/home/modules/neovim/options.nix b/home/modules/neovim/options.nix index 81db2aaf..e4b8513c 100644 --- a/home/modules/neovim/options.nix +++ b/home/modules/neovim/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "NeoVim"; - alias = mkBoolOpt false "Link nvim to vim/vi"; - neovide = mkEnableOpt "NeoVide"; + enable = mkEnableOption "NeoVim"; + alias = mkBoolOption false "Link nvim to vim/vi"; + neovide = mkEnableOption "NeoVide"; } diff --git a/home/modules/nnn/options.nix b/home/modules/nnn/options.nix index d1bdf83b..a7126557 100644 --- a/home/modules/nnn/options.nix +++ b/home/modules/nnn/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "NNN File Manager"; + enable = mkEnableOption "NNN File Manager"; } diff --git a/home/modules/rofi/default.nix b/home/modules/rofi/default.nix index 8da29890..fa26b0fb 100644 --- a/home/modules/rofi/default.nix +++ b/home/modules/rofi/default.nix @@ -2,7 +2,6 @@ # VPN and Container modules should use this rofi module to enable their menus then { config, - nixosConfig, lib, mylib, pkgs, @@ -34,14 +33,9 @@ in { }; }; - home.activation = { - # NOTE: Keep the rofi config symlinked, to allow easy changes with hotreload - linkRofiConfig = - lib.hm.dag.entryAfter ["writeBoundary"] - (mylib.modules.mkLink "~/NixFlake/config/rofi/rofi.rasi" "~/.config/rofi/config.rasi"); - linkRofiColors = - lib.hm.dag.entryAfter ["writeBoundary"] - (mylib.modules.mkLink "~/NixFlake/config/rofi/colors/${cfg.theme}.rasi" "~/.config/rofi/colors.rasi"); + home.file = { + ".config/rofi/config.rasi".source = ../../../config/rofi/rofi.rasi; + ".config/rofi/colors.rasi".source = ../../../config/rofi/colors/${cfg.theme}.rasi; }; }; } diff --git a/home/modules/rofi/options.nix b/home/modules/rofi/options.nix index 082a8a0d..7bf201ec 100644 --- a/home/modules/rofi/options.nix +++ b/home/modules/rofi/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Rofi"; + enable = mkEnableOption "Rofi"; theme = mkOption { type = types.str; diff --git a/home/modules/waybar/options.nix b/home/modules/waybar/options.nix index 4b68c4ae..3b35f56e 100644 --- a/home/modules/waybar/options.nix +++ b/home/modules/waybar/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Waybar"; + enable = mkEnableOption "Waybar"; monitor = mkOption { type = types.str; diff --git a/home/modules/zathura/options.nix b/home/modules/zathura/options.nix index 230d0734..525ddf25 100644 --- a/home/modules/zathura/options.nix +++ b/home/modules/zathura/options.nix @@ -5,5 +5,5 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Enable Zathura"; + enable = mkEnableOption "Enable Zathura"; } diff --git a/lib/default.nix b/lib/default.nix index 3fb8d7ba..1914ea37 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -4,6 +4,9 @@ lib, ... }: { + # Import my own library functions. + # Those are defined as functions returning sets of library functions, + # so those functions have to be called when importing. nixos = import ./nixos.nix {inherit inputs pkgs lib;}; modules = import ./modules.nix {inherit inputs pkgs lib;}; networking = import ./networking.nix {inherit inputs pkgs lib;}; diff --git a/lib/modules.nix b/lib/modules.nix index 41bcdfb2..58083e29 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -1,63 +1,44 @@ -# TODO: Easier mkLink/mkUnlink (include more hm.dag stuff into the function) { inputs, pkgs, lib, ... }: rec { - # Conveniance wrapper for mkOption with boolean type - mkBoolOpt = def: desc: + # Convenience wrapper for "mkOption" with boolean type. + mkBoolOption = def: desc: lib.mkOption { type = lib.types.bool; default = def; description = desc; }; - # Alias for consistency - mkEnableOpt = lib.mkEnableOption; - - # Like mkIf but the predicate is inverted + # Like "lib.mkIf" but the predicate is inverted. + # Returns "do" if "pred" is false. mkElse = pred: do: (lib.mkIf (!pred) do); - # Creates a symlink if it doesn't exist - # If it exists renew the link - mkLink = src: dest: '' - if [ -L "${dest}" ]; then - rm ${dest} - fi - ln -sf ${src} ${dest} - ''; - - # Removes a symlink if it exists - mkUnlink = dest: '' - if [ -L "${dest}" ]; then - rm ${dest} - fi - ''; - - # Returns true if base contains element + # Returns "true" if "base" contains "element". contains = base: element: lib.any (x: x == element) base; - # Returns base without occurences of elements that are also in remove + # Returns "base" without occurences of elements that are also in "remove". without = base: remove: lib.filter (x: !(contains remove x)) base; - # For use with single element sets + # Used with attrSets with a single element. + # Returns the name of the single attr. attrName = set: let names = lib.attrNames set; - in ( + in if (names != []) then (lib.head names) - else null - ); + else null; - # For use with single element sets + # Used with attrSets with a single element. + # Returns the value of the single attr. attrValue = set: let values = lib.attrValues set; - in ( + in if (values != []) then (lib.head values) - else null - ); + else null; } diff --git a/lib/nixos.nix b/lib/nixos.nix index 593f0ec2..39ec5b4d 100644 --- a/lib/nixos.nix +++ b/lib/nixos.nix @@ -14,36 +14,40 @@ lib.nixosSystem { inherit system; - # Make our inputs available to the configuration.nix (for importing modules) - # specialArgs are propagated to all modules + # Values in "specialArgs" are propagated to all system modules. specialArgs = {inherit inputs hostname mylib system username;}; modules = builtins.concatLists [ [ - # Replace the pkgs to include overlays/unfree + # Replace the default "pkgs" with my configured version + # to allow installation of unfree software and my own overlays. {nixpkgs.pkgs = pkgs;} - # Main config file for all configs/hosts + # Import the toplevel system configuration module. ../system ] extraModules - # HM is installed as a system module + # HM is installed as a system module when using mkNixosConfigWithHomeManagerModule. [ inputs.home-manager.nixosModules.home-manager { - # extraSpecialArgs are propagated to all hm config modules - home-manager.extraSpecialArgs = {inherit inputs hostname username mylib;}; + home-manager = { + # Values in "extraSpecialArgs" are propagated to all HM modules. + extraSpecialArgs = {inherit inputs hostname username mylib;}; - # Use systems pkgs, disables nixpkgs.* options in home.nix - home-manager.useGlobalPkgs = true; + # Use the "pkgs" from the system configuration. + # This disables "nixpkgs.*" options in HM modules. + useGlobalPkgs = true; - # Enable installing packages through users.christoph.packages to /etc/profiles instead of ~/.nix-profile - home-manager.useUserPackages = true; + # Packages in "users.${username}.packages" will be installed + # to /etc/profiles instead of ~/.nix-profile. + useUserPackages = true; - # User specific config file - home-manager.users.${username}.imports = [../home/${username}]; + # Import the user-specific HM toplevel module. + users.${username}.imports = [../home/${username}]; + }; } ] ]; @@ -58,16 +62,16 @@ lib.nixosSystem { inherit system; - # Make our inputs available to the configuration.nix (for importing modules) - # specialArgs are propagated to all modules + # Values in "specialArgs" are propagated to all system modules. specialArgs = {inherit inputs hostname mylib system;}; modules = builtins.concatLists [ [ - # Replace the pkgs to include overlays/unfree + # Replace the default "pkgs" with my configured version + # to allow installation of unfree software and my own overlays. {nixpkgs.pkgs = pkgs;} - # Main config file for all configs/hosts + # Import the toplevel system configuration module. ../system ] @@ -85,11 +89,12 @@ inputs.home-manager.lib.homeManagerConfiguration { inherit pkgs; - # HM propagates these to every module + # Values in "extraSpecialArgs" are propagated to all HM modules. extraSpecialArgs = {inherit inputs system mylib username hostname;}; modules = builtins.concatLists [ [ + # Import the user-specific HM toplevel module. ../home/${username} ] diff --git a/system/modules/containers/options.nix b/system/modules/containers/options.nix index 2b70eac8..5690caca 100644 --- a/system/modules/containers/options.nix +++ b/system/modules/containers/options.nix @@ -9,35 +9,35 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Enable OCI Containers"; + enable = mkEnableOption "Enable OCI Containers"; homeassistant = { - enable = mkEnableOpt "Enable HomeAssistant Container"; + enable = mkEnableOption "Enable HomeAssistant Container"; }; stablediffusion = { - enable = mkEnableOpt "Enable StableDiffusion Container with Automatic1111 WebUI"; + enable = mkEnableOption "Enable StableDiffusion Container with Automatic1111 WebUI"; }; jellyfin = { - enable = mkEnableOpt "Enable Jellyfin Container"; + enable = mkEnableOption "Enable Jellyfin Container"; }; fileflows = { - enable = mkEnableOpt "Enable FileFlows Container"; + enable = mkEnableOption "Enable FileFlows Container"; }; sonarr = { - enable = mkEnableOpt "Enable Sonarr Container"; + enable = mkEnableOption "Enable Sonarr Container"; }; radarr = { - enable = mkEnableOpt "Enable Radarr Container"; + enable = mkEnableOption "Enable Radarr Container"; }; hydra = { - enable = mkEnableOpt "Enable Hydra Container"; + enable = mkEnableOption "Enable Hydra Container"; }; sabnzbd = { - enable = mkEnableOpt "Enable SabNzbd Container"; + enable = mkEnableOption "Enable SabNzbd Container"; }; rofiIntegration = { - enable = mkEnableOpt "Enable Rofi Menu for Container Servicing"; + enable = mkEnableOption "Enable Rofi Menu for Container Servicing"; hotkey = mkOption { type = types.str; example = '' diff --git a/system/modules/polkit/options.nix b/system/modules/polkit/options.nix index 2bcf16f2..bc9f355e 100644 --- a/system/modules/polkit/options.nix +++ b/system/modules/polkit/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Polkit"; + enable = mkEnableOption "Polkit"; allowed-system-services = mkOption { type = types.listOf types.str; diff --git a/system/modules/systemd-networkd/options.nix b/system/modules/systemd-networkd/options.nix index 5ca38768..718f4b71 100644 --- a/system/modules/systemd-networkd/options.nix +++ b/system/modules/systemd-networkd/options.nix @@ -5,7 +5,7 @@ }: with lib; with mylib.modules; { - enable = mkEnableOpt "Systemd Network Configuration"; + enable = mkEnableOption "Systemd Network Configuration"; hostname = mkOption { type = types.str;