From b9441936158437c61631aa49d617b1bedfa8d056 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Sun, 23 Feb 2025 00:01:57 +0100 Subject: [PATCH] treewide: pedantic inherits This fixes inherits and library functions usage, to inherit them explicitely at top level of the file. --- lib/default.nix | 16 ++++++++++------ lib/generators/gtk.nix | 9 +++++++-- lib/generators/tohyprconf.nix | 5 +++-- modules/core/default.nix | 6 ++++-- modules/core/fonts.nix | 6 ++++-- modules/core/hardware/fprintd.nix | 6 ++++-- modules/core/hardware/fwupd.nix | 6 ++++-- modules/core/hardware/printing.nix | 6 ++++-- modules/core/hardware/via.nix | 6 ++++-- modules/core/networking.nix | 6 ++++-- modules/core/security.nix | 6 ++++-- modules/options/profiles/desktop.nix | 5 +++-- modules/options/profiles/gaming.nix | 5 +++-- modules/options/profiles/laptop.nix | 5 +++-- modules/options/profiles/server.nix | 5 +++-- modules/options/style.nix | 9 ++++++--- modules/programs/editors/neovim/default.nix | 16 ++++++++++------ modules/programs/fastfetch.nix | 11 ++++++++--- modules/programs/firefox.nix | 8 +++++--- modules/programs/hypr/idle.nix | 6 +++++- modules/programs/hypr/land/binds.nix | 4 +++- modules/programs/hypr/lock.nix | 10 +++++++--- modules/programs/hypr/paper.nix | 10 +++++++--- modules/programs/media/default.nix | 4 +++- modules/programs/media/tidal-hifi.nix | 7 +++++-- modules/programs/media/zathura.nix | 8 ++++++-- modules/programs/terminal/emulators/foot.nix | 10 +++++++--- modules/programs/terminal/programs/bat.nix | 8 ++++++-- modules/programs/terminal/programs/direnv.nix | 6 ++++-- modules/programs/terminal/programs/git.nix | 7 +++++-- modules/programs/terminal/programs/misc.nix | 4 +++- modules/programs/terminal/programs/tmux.nix | 6 ++++-- modules/programs/terminal/shell/starship.nix | 7 +++++-- modules/programs/terminal/shell/zoxide.nix | 4 +++- modules/programs/wlogout.nix | 12 ++++++++---- modules/programs/xdg.nix | 4 +++- modules/services/brightness.nix | 6 ++++-- modules/services/docker.nix | 6 ++++-- modules/services/documentation.nix | 6 ++++-- modules/services/flatpak.nix | 6 ++++-- modules/services/forgejo.nix | 11 +++++++---- modules/services/gammastep.nix | 5 ++++- modules/services/gnome.nix | 6 ++++-- modules/services/greetd.nix | 9 ++++++--- modules/services/gtk/default.nix | 7 +++++-- modules/services/keyd.nix | 6 ++++-- modules/services/kmscon.nix | 6 ++++-- modules/services/location.nix | 6 ++++-- modules/services/logind.nix | 6 ++++-- modules/services/pipewire.nix | 6 ++++-- modules/services/power.nix | 6 ++++-- modules/services/searx.nix | 6 ++++-- modules/services/ssh.nix | 4 +++- modules/services/swaync/default.nix | 11 +++++++---- modules/services/website.nix | 6 ++++-- .../modules/hjem/collection/programs/firefox.nix | 3 ++- .../modules/hjem/collection/programs/ghostty.nix | 6 ++++-- shared/pkgs/mcuxpresso.nix | 3 ++- 58 files changed, 269 insertions(+), 127 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 2f1ae3f..4e38611 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,19 +1,23 @@ -lib: -with lib; let +lib: let + inherit (builtins) baseNameOf length toString; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.lists) foldl imap0; + inherit (lib.strings) concatLines removePrefix stringToCharacters substring; + # thanks fufexan https://github.com/fufexan/dotfiles/blob/2947f27791e97ea33c48af4ee2d0188fe03f80dd/lib/colors/default.nix#L8-L66 # convert rrggbb hex to rgba(r, g, b, a) css rgba = c: alpha: let color = removePrefix "#" c; - r = toString (hexToDec (__substring 0 2 color)); - g = toString (hexToDec (__substring 2 2 color)); - b = toString (hexToDec (__substring 4 2 color)); + r = toString (hexToDec (substring 0 2 color)); + g = toString (hexToDec (substring 2 2 color)); + b = toString (hexToDec (substring 4 2 color)); a = toString alpha; res = "rgba(${r}, ${g}, ${b}, ${a})"; in res; blurImage = pkgs: path: - pkgs.runCommand "${builtins.baseNameOf path}-blurred" { + pkgs.runCommand "${baseNameOf path}-blurred" { buildInputs = [pkgs.imagemagick]; } '' diff --git a/lib/generators/gtk.nix b/lib/generators/gtk.nix index eb31d4f..0cd9711 100644 --- a/lib/generators/gtk.nix +++ b/lib/generators/gtk.nix @@ -1,7 +1,12 @@ lib: let # toGtk3Ini , formatGtk2Option , and finalGtk2Text are all taken from https://github.com/nix-community/home-manager, with some minor modifications to their function. # All of the gtk generator functions are available under the MIT License. - inherit (lib) generators isBool boolToString mapAttrsToList concatMapStrings isString escape; + inherit (builtins) isBool; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.generators) toINI; + inherit (lib.strings) concatMapStrings escape isString; + inherit (lib.trivial) boolToString; + formatGtk2Option = n: v: let v' = if isBool v @@ -11,7 +16,7 @@ lib: let else toString v; in "${escape ["="] n} = ${v'}"; in { - toGtk3Ini = generators.toINI { + toGtk3Ini = toINI { mkKeyValue = key: value: let value' = if isBool value diff --git a/lib/generators/tohyprconf.nix b/lib/generators/tohyprconf.nix index 20879a7..fb3f1f4 100644 --- a/lib/generators/tohyprconf.nix +++ b/lib/generators/tohyprconf.nix @@ -3,6 +3,7 @@ lib: { indentLevel ? 0, importantPrefixes ? ["$" "bezier" "name"], }: let + inherit (builtins) removeAttrs; inherit (lib) all @@ -26,7 +27,7 @@ lib: { filterAttrs (_: v: isAttrs v || (isList v && all isAttrs v)) attrs; mkSection = n: attrs: - if lib.isList attrs + if isList attrs then (concatMapStringsSep "\n" (a: mkSection n a) attrs) else '' ${indent}${n} { @@ -53,7 +54,7 @@ lib: { importantFields = filterAttrs isImportantField allFields; fields = - builtins.removeAttrs allFields + removeAttrs allFields (mapAttrsToList (n: _: n) importantFields); in mkFields importantFields diff --git a/modules/core/default.nix b/modules/core/default.nix index 6972119..dad67eb 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -1,4 +1,6 @@ -{lib, ...}: { +{lib, ...}: let + inherit (lib.modules) mkDefault; +in { imports = [ ./hardware @@ -10,6 +12,6 @@ ./users.nix ./security.nix ]; - system.stateVersion = lib.mkDefault "24.05"; + system.stateVersion = mkDefault "24.05"; zramSwap.enable = true; } diff --git a/modules/core/fonts.nix b/modules/core/fonts.nix index c2526a3..17f12d5 100644 --- a/modules/core/fonts.nix +++ b/modules/core/fonts.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { fonts = { enableDefaultPackages = false; packages = [ diff --git a/modules/core/hardware/fprintd.nix b/modules/core/hardware/fprintd.nix index d5b4fc3..5998627 100644 --- a/modules/core/hardware/fprintd.nix +++ b/modules/core/hardware/fprintd.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.laptop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.laptop.enable { services.fprintd.enable = true; }; } diff --git a/modules/core/hardware/fwupd.nix b/modules/core/hardware/fwupd.nix index db3e785..d5fb03f 100644 --- a/modules/core/hardware/fwupd.nix +++ b/modules/core/hardware/fwupd.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services.fwupd.enable = true; }; } diff --git a/modules/core/hardware/printing.nix b/modules/core/hardware/printing.nix index 39b1bc9..6d7f1a9 100644 --- a/modules/core/hardware/printing.nix +++ b/modules/core/hardware/printing.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services = { # setup printing service printing.enable = true; diff --git a/modules/core/hardware/via.nix b/modules/core/hardware/via.nix index 8b1b22e..71c4508 100644 --- a/modules/core/hardware/via.nix +++ b/modules/core/hardware/via.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.gaming.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.gaming.enable { hardware.keyboard.qmk.enable = true; environment.systemPackages = with pkgs; [ via diff --git a/modules/core/networking.nix b/modules/core/networking.nix index c09f634..3df20f5 100644 --- a/modules/core/networking.nix +++ b/modules/core/networking.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf (!config.local.profiles.server.enable) { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf (!config.local.profiles.server.enable) { networking = { inherit (config.local.systemVars) hostName; nameservers = ["1.1.1.1" "1.0.0.1"]; diff --git a/modules/core/security.nix b/modules/core/security.nix index 478796b..41ea343 100644 --- a/modules/core/security.nix +++ b/modules/core/security.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { security = { polkit.enable = true; polkit = { diff --git a/modules/options/profiles/desktop.nix b/modules/options/profiles/desktop.nix index 5b0fb45..4ac60b7 100644 --- a/modules/options/profiles/desktop.nix +++ b/modules/options/profiles/desktop.nix @@ -3,13 +3,14 @@ config, ... }: let - inherit (lib) mkEnableOption; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; in { options = { local.profiles.desktop.enable = mkEnableOption "the desktop profile"; }; - config.assertions = lib.mkIf config.local.profiles.desktop.enable [ + config.assertions = mkIf config.local.profiles.desktop.enable [ { assertion = !config.local.profiles.server.enable; message = "The desktop profile cannot be enabled if `local.profiles.server.enable` is set to true."; diff --git a/modules/options/profiles/gaming.nix b/modules/options/profiles/gaming.nix index b434b8f..4d01045 100644 --- a/modules/options/profiles/gaming.nix +++ b/modules/options/profiles/gaming.nix @@ -3,13 +3,14 @@ config, ... }: let - inherit (lib) mkEnableOption; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; in { options = { local.profiles.gaming.enable = mkEnableOption "the gaming profile"; }; - config.assertions = lib.mkIf config.local.profiles.gaming.enable [ + config.assertions = mkIf config.local.profiles.gaming.enable [ { assertion = !config.local.profiles.server.enable; message = "The gaming profile cannot be enabled if `local.profiles.server.enable` is set to true."; diff --git a/modules/options/profiles/laptop.nix b/modules/options/profiles/laptop.nix index 7fa4859..3dbca61 100644 --- a/modules/options/profiles/laptop.nix +++ b/modules/options/profiles/laptop.nix @@ -3,13 +3,14 @@ config, ... }: let - inherit (lib) mkEnableOption; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; in { options = { local.profiles.laptop.enable = mkEnableOption "the laptop profile"; }; - config.assertions = lib.mkIf config.local.profiles.laptop.enable [ + config.assertions = mkIf config.local.profiles.laptop.enable [ { assertion = !config.local.profiles.server.enable; message = "The laptop profile cannot be enabled if `local.profiles.server.enable` is set to true."; diff --git a/modules/options/profiles/server.nix b/modules/options/profiles/server.nix index a772aff..eb57b49 100644 --- a/modules/options/profiles/server.nix +++ b/modules/options/profiles/server.nix @@ -3,13 +3,14 @@ config, ... }: let - inherit (lib) mkEnableOption; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; in { options = { local.profiles.server.enable = mkEnableOption "the server profile"; }; - config.assertions = lib.mkIf config.local.profiles.server.enable [ + config.assertions = mkIf config.local.profiles.server.enable [ { assertion = !config.local.profiles.desktop.enable; message = "The server profile cannot be enabled if `local.profiles.desktop.enable` is set to true."; diff --git a/modules/options/style.nix b/modules/options/style.nix index 6c58ae5..d13ce4e 100644 --- a/modules/options/style.nix +++ b/modules/options/style.nix @@ -6,9 +6,12 @@ inputs, ... }: let - inherit (lib) attrNames mkEnableOption mkOption pathExists; - inherit (lib.types) attrs bool enum package path str; + inherit (builtins) pathExists toString; + inherit (lib.attrsets) attrNames; inherit (lib.lists) singleton; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) attrs bool enum package path str; cfg = config.local.style; in { @@ -136,7 +139,7 @@ in { }; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { assertions = [ (let themePath = cfg.gtk.theme.package + /share/themes + "/${cfg.gtk.theme.name}"; diff --git a/modules/programs/editors/neovim/default.nix b/modules/programs/editors/neovim/default.nix index eb71b9c..48eec5e 100644 --- a/modules/programs/editors/neovim/default.nix +++ b/modules/programs/editors/neovim/default.nix @@ -5,13 +5,18 @@ config, ... }: let + inherit (lib.attrsets) optionalAttrs; + inherit (lib.lists) singleton; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; + styleCfg = config.local.style; customNeovim = inputs.nvf.lib.neovimConfiguration { inherit pkgs; - modules = lib.singleton { - config.vim = lib.mkMerge [ + modules = singleton { + config.vim = { viAlias = true; vimAlias = true; @@ -245,19 +250,18 @@ telescope.enable = true; } - (lib.mkIf styleCfg.enable { + // (optionalAttrs styleCfg.enable { theme = { enable = true; name = "base16"; base16-colors = styleCfg.scheme.palette; }; - }) - ]; + }); }; }; in { imports = [./basedpyright-fix.nix]; - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [customNeovim.neovim]; }; diff --git a/modules/programs/fastfetch.nix b/modules/programs/fastfetch.nix index bde7fbd..839d914 100644 --- a/modules/programs/fastfetch.nix +++ b/modules/programs/fastfetch.nix @@ -4,17 +4,22 @@ config, ... }: let + inherit (builtins) fetchurl; + inherit (lib.generators) toJSON; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; - logo = builtins.fetchurl { + + logo = fetchurl { url = "https://raw.githubusercontent.com/gytis-ivaskevicius/high-quality-nix-content/refs/heads/master/emoji/nix-owo-transparent.png"; sha256 = "137k3i7z4va68v4rvrazy26szc7p2w59h7bc2h8japzjyj6xjs71"; }; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.fastfetch]; files = { - ".config/fastfetch/config.jsonc".text = builtins.toJSON { + ".config/fastfetch/config.jsonc".text = toJSON {} { logo = { source = logo; type = "kitty"; diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 304cd4b..e28b386 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -4,7 +4,9 @@ config, ... }: let - inherit (builtins) readFile; + inherit (builtins) concatStringsSep readFile; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; betterfox = pkgs.fetchFromGitHub { @@ -14,7 +16,7 @@ hash = "sha256-hpkEO5BhMVtINQG8HN4xqfas/R6q5pYPZiFK8bilIDs="; }; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { programs.firefox = { enable = true; @@ -153,7 +155,7 @@ in { }; }; - extraConfig = builtins.concatStringsSep "\n" [ + extraConfig = concatStringsSep "\n" [ (readFile "${betterfox}/user.js") (readFile "${betterfox}/Securefox.js") (readFile "${betterfox}/Fastfox.js") diff --git a/modules/programs/hypr/idle.nix b/modules/programs/hypr/idle.nix index 60d2eaf..e10240a 100644 --- a/modules/programs/hypr/idle.nix +++ b/modules/programs/hypr/idle.nix @@ -6,13 +6,17 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (lib'.generators) toHyprConf; + inherit (config.local.systemVars) username; + inherit (inputs.hypridle.packages.${pkgs.system}) hypridle; hyprlock = "${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock"; in { - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { packages = [hypridle]; files = { diff --git a/modules/programs/hypr/land/binds.nix b/modules/programs/hypr/land/binds.nix index e44d9df..cbe1f25 100644 --- a/modules/programs/hypr/land/binds.nix +++ b/modules/programs/hypr/land/binds.nix @@ -1,7 +1,9 @@ lib: let + inherit (builtins) substring; + # thanks https://github.com/fufexan/dotfiles/blob/c0b3c77d95ce1f574a87e7f7ead672ca0d951245/home/programs/wayland/hyprland/binds.nix#L16-L20 toggle = program: uwsm: let - prog = builtins.substring 0 14 program; + prog = substring 0 14 program; in "pkill ${prog} || ${lib.optionalString uwsm "uwsm app -- "} ${program}"; runOnce = program: "pgrep ${program} || uwsm app -- ${program}"; run = program: "uwsm app -- ${program}"; diff --git a/modules/programs/hypr/lock.nix b/modules/programs/hypr/lock.nix index ae1bfba..02181b2 100644 --- a/modules/programs/hypr/lock.nix +++ b/modules/programs/hypr/lock.nix @@ -6,13 +6,17 @@ config, ... }: let - inherit (lib) mkIf; + inherit (builtins) mapAttrs; + inherit (lib.modules) mkIf; + + inherit (lib') rgba; inherit (lib'.generators) toHyprConf; - inherit (config.local.systemVars) username; + inherit (inputs.hyprlock.packages.${pkgs.system}) hyprlock; + inherit (config.local.systemVars) username; styleCfg = config.local.style; - rgbaPalette = builtins.mapAttrs (_: c: (lib'.rgba c 1)) styleCfg.scheme.palette; + rgbaPalette = mapAttrs (_: c: (rgba c 1)) styleCfg.scheme.palette; in { config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { diff --git a/modules/programs/hypr/paper.nix b/modules/programs/hypr/paper.nix index c2d29b9..5a7e8b1 100644 --- a/modules/programs/hypr/paper.nix +++ b/modules/programs/hypr/paper.nix @@ -6,12 +6,16 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (lib'.generators) toHyprConf; - inherit (config.local.systemVars) username; - inherit (config.local.style) wallpaper; + inherit (inputs.hyprpaper.packages.${pkgs.system}) hyprpaper; + + inherit (config.local.style) wallpaper; + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { packages = [hyprpaper]; files = { diff --git a/modules/programs/media/default.nix b/modules/programs/media/default.nix index 601ba70..74846d5 100644 --- a/modules/programs/media/default.nix +++ b/modules/programs/media/default.nix @@ -4,6 +4,8 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; in { imports = [ @@ -11,7 +13,7 @@ in { ./zathura.nix ]; - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username}.packages = [ pkgs.gnome-calculator pkgs.gthumb diff --git a/modules/programs/media/tidal-hifi.nix b/modules/programs/media/tidal-hifi.nix index 2080e85..f643773 100644 --- a/modules/programs/media/tidal-hifi.nix +++ b/modules/programs/media/tidal-hifi.nix @@ -4,16 +4,19 @@ pkgs, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; + styleCfg = config.local.style; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.tidal-hifi]; files = { # based on https://github.com/rose-pine/tidal. adapted to work with base16 colors. "tidal-hifi/themes/base16.css".text = with styleCfg.scheme.palette; - lib.mkIf styleCfg.enable '' + mkIf styleCfg.enable '' :root { --glass-white-1: ${base05}; --glass-white-1-hover: ${base06}; diff --git a/modules/programs/media/zathura.nix b/modules/programs/media/zathura.nix index 3a317ca..bea1fe0 100644 --- a/modules/programs/media/zathura.nix +++ b/modules/programs/media/zathura.nix @@ -4,12 +4,16 @@ config, ... }: let + inherit (builtins) concatStringsSep toString; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; + toZathura = attrs: - builtins.concatStringsSep "\n" + concatStringsSep "\n" (lib.mapAttrsToList (option: value: "set ${option} \"${toString value}\"") attrs); in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.zathura]; files = { diff --git a/modules/programs/terminal/emulators/foot.nix b/modules/programs/terminal/emulators/foot.nix index ada1641..d27f9c0 100644 --- a/modules/programs/terminal/emulators/foot.nix +++ b/modules/programs/terminal/emulators/foot.nix @@ -4,12 +4,16 @@ config, ... }: let - inherit (lib) optionalAttrs; + inherit (builtins) mapAttrs; + inherit (lib.attrsets) optionalAttrs; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; styleCfg = config.local.style; + # because someone thought this was a great idea: https://github.com/tinted-theming/schemes/commit/61058a8d2e2bd4482b53d57a68feb56cdb991f0b - palette = builtins.mapAttrs (_: color: lib.removePrefix "#" color) styleCfg.scheme.palette; + palette = mapAttrs (_: color: lib.removePrefix "#" color) styleCfg.scheme.palette; toINI = lib.generators.toINI {}; mkColors = palette: { background = palette.base00; @@ -38,7 +42,7 @@ "21" = palette.base06; }; in { - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { packages = [pkgs.foot]; files = { diff --git a/modules/programs/terminal/programs/bat.nix b/modules/programs/terminal/programs/bat.nix index 8fa94c7..a8bc3b8 100644 --- a/modules/programs/terminal/programs/bat.nix +++ b/modules/programs/terminal/programs/bat.nix @@ -4,12 +4,16 @@ config, ... }: let + inherit (builtins) concatStringsSep; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; + toConf = attrs: - builtins.concatStringsSep "\n" + concatStringsSep "\n" (lib.mapAttrsToList (option: value: "--${option}=\"${value}\"") attrs); in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [ pkgs.bat diff --git a/modules/programs/terminal/programs/direnv.nix b/modules/programs/terminal/programs/direnv.nix index 28edce7..939b40d 100644 --- a/modules/programs/terminal/programs/direnv.nix +++ b/modules/programs/terminal/programs/direnv.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { programs.direnv.enable = true; }; } diff --git a/modules/programs/terminal/programs/git.nix b/modules/programs/terminal/programs/git.nix index ffa6bef..c7100c1 100644 --- a/modules/programs/terminal/programs/git.nix +++ b/modules/programs/terminal/programs/git.nix @@ -4,11 +4,14 @@ config, ... }: let - inherit (config.local.systemVars) username; + inherit (lib.modules) mkIf; + inherit (config.local.homeVars) signingKey; + inherit (config.local.systemVars) username; + toINI = lib.generators.toINI {}; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = with pkgs; [git lazygit]; files = { diff --git a/modules/programs/terminal/programs/misc.nix b/modules/programs/terminal/programs/misc.nix index 3e64d53..1dadfae 100644 --- a/modules/programs/terminal/programs/misc.nix +++ b/modules/programs/terminal/programs/misc.nix @@ -4,9 +4,11 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = with pkgs; [ # archives diff --git a/modules/programs/terminal/programs/tmux.nix b/modules/programs/terminal/programs/tmux.nix index da828e2..d63d574 100644 --- a/modules/programs/terminal/programs/tmux.nix +++ b/modules/programs/terminal/programs/tmux.nix @@ -3,8 +3,10 @@ pkgs, osConfig, ... -}: { - config = lib.mkIf osConfig.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf osConfig.local.profiles.desktop.enable { programs.tmux = { enable = true; prefix = "C-space"; diff --git a/modules/programs/terminal/shell/starship.nix b/modules/programs/terminal/shell/starship.nix index 6201563..a48f78a 100644 --- a/modules/programs/terminal/shell/starship.nix +++ b/modules/programs/terminal/shell/starship.nix @@ -4,11 +4,14 @@ config, ... }: let + inherit (lib.modules) mkIf; inherit (lib.strings) concatStrings; - toTOML = (pkgs.formats.toml {}).generate; + inherit (config.local.systemVars) username; + + toTOML = (pkgs.formats.toml {}).generate; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.starship]; files = { diff --git a/modules/programs/terminal/shell/zoxide.nix b/modules/programs/terminal/shell/zoxide.nix index a183294..6765a52 100644 --- a/modules/programs/terminal/shell/zoxide.nix +++ b/modules/programs/terminal/shell/zoxide.nix @@ -4,9 +4,11 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.zoxide]; }; diff --git a/modules/programs/wlogout.nix b/modules/programs/wlogout.nix index 568158f..def11e5 100644 --- a/modules/programs/wlogout.nix +++ b/modules/programs/wlogout.nix @@ -4,6 +4,10 @@ config, ... }: let + inherit (builtins) concatStringsSep map; + inherit (lib.meta) getExe'; + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; mkLayout = items: let @@ -15,15 +19,15 @@ "keybind" : "${item.keybind}" }''; in - builtins.concatStringsSep "\n" (map formatItem items); + concatStringsSep "\n" (map formatItem items); in { - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { packages = [pkgs.wlogout]; files = { ".config/wlogout/layout".text = let - loginctl = lib.getExe' pkgs.systemd "loginctl"; - systemctl = lib.getExe' pkgs.systemd "systemctl"; + loginctl = getExe' pkgs.systemd "loginctl"; + systemctl = getExe' pkgs.systemd "systemctl"; in mkLayout [ { diff --git a/modules/programs/xdg.nix b/modules/programs/xdg.nix index 9395143..61592ce 100644 --- a/modules/programs/xdg.nix +++ b/modules/programs/xdg.nix @@ -4,9 +4,11 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { files = { ".config/mimeapps.list".text = '' diff --git a/modules/services/brightness.nix b/modules/services/brightness.nix index 05da8b3..f7bc178 100644 --- a/modules/services/brightness.nix +++ b/modules/services/brightness.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.laptop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.laptop.enable { hardware.brillo.enable = true; }; } diff --git a/modules/services/docker.nix b/modules/services/docker.nix index 97ecd28..7973aaf 100644 --- a/modules/services/docker.nix +++ b/modules/services/docker.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { virtualisation.podman = { enable = true; dockerCompat = true; diff --git a/modules/services/documentation.nix b/modules/services/documentation.nix index c715c55..8b5798a 100644 --- a/modules/services/documentation.nix +++ b/modules/services/documentation.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { documentation = { enable = true; diff --git a/modules/services/flatpak.nix b/modules/services/flatpak.nix index bbf4f92..c6e064a 100644 --- a/modules/services/flatpak.nix +++ b/modules/services/flatpak.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services.flatpak.enable = true; }; } diff --git a/modules/services/forgejo.nix b/modules/services/forgejo.nix index 904c276..8af3794 100644 --- a/modules/services/forgejo.nix +++ b/modules/services/forgejo.nix @@ -4,7 +4,10 @@ pkgs, ... }: let - inherit (lib) mkAfter removePrefix removeSuffix; + inherit (builtins) attrNames concatStringsSep map readDir toString; + inherit (lib.modules) mkAfter mkIf; + inherit (lib.strings) removePrefix removeSuffix; + srv = config.services.forgejo.settings.server; # https://github.com/isabelroses/dotfiles/blob/06f8f70914c8e672541a52563ee624ce2e62adfb/modules/nixos/services/selfhosted/forgejo.nix#L19-L23 @@ -14,7 +17,7 @@ stripRoot = false; }; in { - config = lib.mkIf config.local.profiles.server.enable { + config = mkIf config.local.profiles.server.enable { services = { forgejo = { enable = true; @@ -40,10 +43,10 @@ in { }; ui = { DEFAULT_THEME = "catppuccin-mocha-lavender"; - THEMES = builtins.concatStringsSep "," ( + THEMES = concatStringsSep "," ( ["auto,forgejo-auto,forgejo-dark,forgejo-light,arc-gree,gitea"] ++ (map (name: removePrefix "theme-" (removeSuffix ".css" name)) ( - builtins.attrNames (builtins.readDir theme) + attrNames (readDir theme) )) ); }; diff --git a/modules/services/gammastep.nix b/modules/services/gammastep.nix index 27bd358..f0e7f8b 100644 --- a/modules/services/gammastep.nix +++ b/modules/services/gammastep.nix @@ -4,10 +4,13 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; + toINI = lib.generators.toINI {}; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { hjem.users.${username} = { packages = [pkgs.gammastep]; files = { diff --git a/modules/services/gnome.nix b/modules/services/gnome.nix index c8f3482..7741f46 100644 --- a/modules/services/gnome.nix +++ b/modules/services/gnome.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services = { # needed for GNOME services outside of GNOME Desktop dbus.packages = with pkgs; [ diff --git a/modules/services/greetd.nix b/modules/services/greetd.nix index 35de5be..ea4f4fa 100644 --- a/modules/services/greetd.nix +++ b/modules/services/greetd.nix @@ -8,11 +8,14 @@ }: # thanks https://git.jacekpoz.pl/poz/niksos/src/commit/f8d5e7ccd9c769f7c0b564f10dff419285e75248/modules/services/greetd.nix let + inherit (builtins) concatStringsSep filter toString; inherit (lib.attrsets) optionalAttrs; inherit (lib.meta) getExe getExe'; + inherit (lib.modules) mkIf; + + inherit (lib'.generators) toHyprConf; inherit (inputs.hyprland.packages.${pkgs.stdenv.system}) hyprland; - inherit (lib'.generators) toHyprConf; styleCfg = config.local.style; @@ -50,7 +53,7 @@ let }); in { # TODO: perhaps turn this into a more generic module if we wanna use other wayland compositors - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { services.greetd = { enable = true; settings = { @@ -83,6 +86,6 @@ in { } ]; in - builtins.concatStringsSep "\n" (map (env: env.name) (builtins.filter (env: env.condition) environments)); + concatStringsSep "\n" (map (env: env.name) (filter (env: env.condition) environments)); }; } diff --git a/modules/services/gtk/default.nix b/modules/services/gtk/default.nix index a13d41f..19bfe2c 100644 --- a/modules/services/gtk/default.nix +++ b/modules/services/gtk/default.nix @@ -6,9 +6,12 @@ lib', ... }: let - inherit (lib.lists) singleton; inherit (lib.gvariant) mkInt32; + inherit (lib.lists) singleton; + inherit (lib.modules) mkIf; + inherit (lib'.generators.gtk) finalGtk2Text toGtk3Ini; + inherit (config.local.systemVars) username; styleCfg = config.local.style; @@ -21,7 +24,7 @@ }; in { config = with styleCfg; - lib.mkIf styleCfg.enable { + mkIf styleCfg.enable { hjem.users.${username} = let gtkCss = pkgs.writeText "gtk-colors" (import ./style.nix lib' styleCfg.scheme.palette); in { diff --git a/modules/services/keyd.nix b/modules/services/keyd.nix index 12e44f4..d5cae64 100644 --- a/modules/services/keyd.nix +++ b/modules/services/keyd.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services.keyd = { enable = true; keyboards.default = { diff --git a/modules/services/kmscon.nix b/modules/services/kmscon.nix index 758df65..4138684 100644 --- a/modules/services/kmscon.nix +++ b/modules/services/kmscon.nix @@ -3,8 +3,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.desktop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.desktop.enable { services.kmscon = { enable = true; fonts = [ diff --git a/modules/services/location.nix b/modules/services/location.nix index ac22b89..ccd4ae9 100644 --- a/modules/services/location.nix +++ b/modules/services/location.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.modules.hyprland.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.modules.hyprland.enable { location.provider = "geoclue2"; services.geoclue2 = { diff --git a/modules/services/logind.nix b/modules/services/logind.nix index 11b55b8..a2e72de 100644 --- a/modules/services/logind.nix +++ b/modules/services/logind.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.laptop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.laptop.enable { services.logind = { lidSwitch = "suspend"; extraConfig = '' diff --git a/modules/services/pipewire.nix b/modules/services/pipewire.nix index 25cc868..d90f39d 100644 --- a/modules/services/pipewire.nix +++ b/modules/services/pipewire.nix @@ -3,12 +3,14 @@ inputs, config, ... -}: { +}: let + inherit (lib.modules) mkIf; +in { imports = [ inputs.nix-gaming.nixosModules.pipewireLowLatency ]; - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { services = { pulseaudio.enable = false; pipewire = { diff --git a/modules/services/power.nix b/modules/services/power.nix index 952a629..167b9cd 100644 --- a/modules/services/power.nix +++ b/modules/services/power.nix @@ -2,8 +2,10 @@ lib, config, ... -}: { - config = lib.mkIf config.local.profiles.laptop.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.laptop.enable { services = { power-profiles-daemon.enable = true; diff --git a/modules/services/searx.nix b/modules/services/searx.nix index 642f2c1..8e21a59 100644 --- a/modules/services/searx.nix +++ b/modules/services/searx.nix @@ -4,12 +4,14 @@ pkgs, config, ... -}: { +}: let + inherit (lib.modules) mkIf; +in { imports = [ inputs.agenix.nixosModules.default ]; - config = lib.mkIf config.local.profiles.server.enable { + config = mkIf config.local.profiles.server.enable { age.secrets.searx-env-file.file = ../../secrets/searx-env-file.age; services = { searx = { diff --git a/modules/services/ssh.nix b/modules/services/ssh.nix index b63c4ab..0272e62 100644 --- a/modules/services/ssh.nix +++ b/modules/services/ssh.nix @@ -3,9 +3,11 @@ config, ... }: let + inherit (lib.modules) mkIf; + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.profiles.desktop.enable { + config = mkIf config.local.profiles.desktop.enable { programs.ssh = { startAgent = true; }; diff --git a/modules/services/swaync/default.nix b/modules/services/swaync/default.nix index ddc1509..c1a9c53 100644 --- a/modules/services/swaync/default.nix +++ b/modules/services/swaync/default.nix @@ -5,11 +5,14 @@ lib', ... }: let - inherit (builtins) toJSON; - inherit (config.local.systemVars) username; + inherit (builtins) readFile toJSON; + inherit (lib.modules) mkIf; + inherit (lib') generateGtkColors; + + inherit (config.local.systemVars) username; in { - config = lib.mkIf config.local.modules.hyprland.enable { + config = mkIf config.local.modules.hyprland.enable { hjem.users.${username} = { files = { ".config/swaync/config.json".text = toJSON { @@ -29,7 +32,7 @@ in { notification-body-image-height = 100; notification-body-image-width = 200; }; - ".config/swaync/style.css".text = (generateGtkColors config.local.style.scheme.palette) + builtins.readFile ./style.css; + ".config/swaync/style.css".text = (generateGtkColors config.local.style.scheme.palette) + readFile ./style.css; }; packages = [pkgs.swaynotificationcenter]; diff --git a/modules/services/website.nix b/modules/services/website.nix index 4eb573c..e2f83c0 100644 --- a/modules/services/website.nix +++ b/modules/services/website.nix @@ -4,8 +4,10 @@ pkgs, config, ... -}: { - config = lib.mkIf config.local.profiles.server.enable { +}: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.local.profiles.server.enable { services.caddy.enable = true; services.caddy.virtualHosts = { "www.nezia.dev" = { diff --git a/shared/modules/hjem/collection/programs/firefox.nix b/shared/modules/hjem/collection/programs/firefox.nix index 3133295..80d00ce 100644 --- a/shared/modules/hjem/collection/programs/firefox.nix +++ b/shared/modules/hjem/collection/programs/firefox.nix @@ -4,6 +4,7 @@ config, ... }: let + inherit (lib.modules) mkIf; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) attrs lines package str; @@ -57,7 +58,7 @@ in { ''; }; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { packages = [firefox]; files = { ".mozilla/firefox/profiles.ini".text = toINI { diff --git a/shared/modules/hjem/collection/programs/ghostty.nix b/shared/modules/hjem/collection/programs/ghostty.nix index c6607db..ec16c8b 100644 --- a/shared/modules/hjem/collection/programs/ghostty.nix +++ b/shared/modules/hjem/collection/programs/ghostty.nix @@ -4,15 +4,17 @@ pkgs, ... }: let + inherit (builtins) concatStringsSep; inherit (lib.attrsets) isAttrs mapAttrs' mapAttrsToList nameValuePair; inherit (lib.generators) mkKeyValueDefault mkValueStringDefault toINIWithGlobalSection; + inherit (lib.modules) mkIf; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) attrs attrsOf package; mkKeyValue = key: value: if isAttrs value # ghostty's configuration format supports (so far) one level of nested keys as key1=key2=value - then builtins.concatStringsSep "\n" (mapAttrsToList (k: v: "${key}=${k}=${v}") value) + then concatStringsSep "\n" (mapAttrsToList (k: v: "${key}=${k}=${v}") value) else (mkKeyValueDefault {mkValueString = mkValueStringDefault {};} "=" key value); toGhosttyConf = toINIWithGlobalSection { @@ -96,7 +98,7 @@ in { }; }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { packages = [cfg.package]; files = { diff --git a/shared/pkgs/mcuxpresso.nix b/shared/pkgs/mcuxpresso.nix index 2ef261d..6b188d7 100644 --- a/shared/pkgs/mcuxpresso.nix +++ b/shared/pkgs/mcuxpresso.nix @@ -3,6 +3,7 @@ pkgs, ... }: let + inherit (lib.strings) makeLibraryPath; name = "mcuxpressoide"; version = "24.9.25"; description = "MCUXpresso IDE"; @@ -104,7 +105,7 @@ pkgs.libudev-zero ]; profile = '' - export LD_LIBRARY_PATH=${lib.makeLibraryPath [pkgs.ncurses5 pkgs.ncurses]}:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=${makeLibraryPath [pkgs.ncurses5 pkgs.ncurses]}:$LD_LIBRARY_PATH ''; extraBuildCommands = ''