From 25d008fc47e113a24f5c99ca3e255cde4ec79197 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Tue, 25 Mar 2025 21:06:27 +0300 Subject: [PATCH] fix: don't repeat pkgs.\w too much, add taplo, tokei, typos --- modules/common/agenix.nix | 8 +- modules/common/git.nix | 12 +-- modules/common/helix.nix | 74 +++++++++++-------- modules/common/jujutsu.nix | 12 +-- modules/common/nix.nix | 14 ++-- modules/common/nushell/default.nix | 12 +-- modules/common/packages.nix | 110 ++++++++++++++++------------ modules/common/python.nix | 14 ++-- modules/common/rust.nix | 22 ++++-- modules/linux/fonts.nix | 20 ++--- modules/linux/hyprland/hyprland.nix | 28 +++---- modules/linux/steam.nix | 10 ++- modules/linux/thunar.nix | 31 +++++--- 13 files changed, 213 insertions(+), 154 deletions(-) diff --git a/modules/common/agenix.nix b/modules/common/agenix.nix index bd16eee..a212da8 100644 --- a/modules/common/agenix.nix +++ b/modules/common/agenix.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) attrNames head mkAliasOptionModule mkIf; + inherit (lib) attrNames attrValues head mkAliasOptionModule mkIf; in { imports = [(mkAliasOptionModule [ "secrets" ] [ "age" "secrets" ])]; @@ -12,6 +12,10 @@ in { environment = mkIf config.isDesktop { shellAliases.agenix = "agenix --identity ~/.ssh/id"; - systemPackages = [ pkgs.agenix ]; + systemPackages = attrValues { + inherit (pkgs) + agenix + ; + }; }; } diff --git a/modules/common/git.nix b/modules/common/git.nix index 7accb04..1af4259 100644 --- a/modules/common/git.nix +++ b/modules/common/git.nix @@ -1,5 +1,5 @@ { self, config, lib, pkgs, ... }: let - inherit (lib) head mkAfter enabled merge mkIf; + inherit (lib) attrValues head mkAfter enabled merge mkIf; inherit (lib.strings) match; in { environment.shellAliases = merge { @@ -68,10 +68,12 @@ in { "ask-git" = "gh copilot suggest --target git --"; }; - environment.systemPackages = [ - pkgs.git-absorb - pkgs.tig - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + git-absorb + tig + ; + }; home-manager.sharedModules = [ (homeArgs: let diff --git a/modules/common/helix.nix b/modules/common/helix.nix index 5cf5901..00452d8 100644 --- a/modules/common/helix.nix +++ b/modules/common/helix.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) const enabled genAttrs mkAfter mkIf; + inherit (lib) attrValues const enabled genAttrs mkAfter mkIf; in { environment = { variables.EDITOR = "hx"; @@ -213,47 +213,57 @@ in { }; }]; - environment.systemPackages = mkIf config.isDesktop [ - # CMAKE - pkgs.cmake-language-server + environment.systemPackages = mkIf config.isDesktop <| attrValues { + inherit (pkgs) + # CMAKE + cmake-language-server - # GO - pkgs.gopls + # GO + gopls - # HTML - pkgs.vscode-langservers-extracted - pkgs.nodePackages_latest.prettier + # HTML + vscode-langservers-extracted - # KOTLIN - pkgs.kotlin-language-server + # KOTLIN + kotlin-language-server - # LATEX - pkgs.texlab + # LATEX + texlab - # LUA - pkgs.lua-language-server + # LUA + lua-language-server - # MARKDOWN - pkgs.marksman + # MARKDOWN + marksman - # NIX - pkgs.alejandra - pkgs.nil + # NIX + alejandra + nil - # PYTHON - pkgs.python311Packages.python-lsp-server - # RUST - pkgs.rust-analyzer-nightly - pkgs.lldb + # RUST + rust-analyzer-nightly + lldb - # TYPESCRIPT & OTHERS - pkgs.deno + # TYPESCRIPT & OTHERS + deno - # YAML - pkgs.yaml-language-server + # YAML + yaml-language-server - # ZIG - pkgs.zls - ]; + # ZIG + zls + ; + + inherit (pkgs.python311Packages) + # PYTHON + # TODO: Replace with basedpyright. + python-lsp-server + ; + + inherit (pkgs.nodePackages_latest) + # HTML + prettier + ; + }; } diff --git a/modules/common/jujutsu.nix b/modules/common/jujutsu.nix index dabf6cb..be4c416 100644 --- a/modules/common/jujutsu.nix +++ b/modules/common/jujutsu.nix @@ -1,10 +1,12 @@ { self, config, lib, pkgs, ... }: let - inherit (lib) enabled getExe head; + inherit (lib) attrValues enabled getExe head; in { - environment.systemPackages = [ - pkgs.difftastic - pkgs.radicle-node - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + difftastic + radicle-node + ; + }; home-manager.sharedModules = [(homeArgs: let homeConfig = homeArgs.config; diff --git a/modules/common/nix.nix b/modules/common/nix.nix index f5f4dda..81a77ef 100644 --- a/modules/common/nix.nix +++ b/modules/common/nix.nix @@ -1,5 +1,5 @@ { self, config, inputs, lib, pkgs, ... }: let - inherit (lib) attrsToList concatStringsSep const disabled filter filterAttrs flip id isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs optionals; + inherit (lib) attrValues attrsToList concatStringsSep const disabled filter filterAttrs flip id isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs optionals; inherit (lib.strings) toJSON; registryMap = inputs @@ -46,11 +46,13 @@ in { nix.optimise.automatic = true; - environment.systemPackages = [ - pkgs.nh - pkgs.nix-index - pkgs.nix-output-monitor - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + nh + nix-index + nix-output-monitor + ; + }; home-manager.sharedModules = [{ programs.nushell.configFile.text = mkAfter /* nu */ '' diff --git a/modules/common/nushell/default.nix b/modules/common/nushell/default.nix index 0683e34..b37c130 100644 --- a/modules/common/nushell/default.nix +++ b/modules/common/nushell/default.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) enabled filter first foldl' getExe last match mkIf nameValuePair optionalAttrs readFile removeAttrs splitString; + inherit (lib) attrValues enabled filter first foldl' getExe last match mkIf nameValuePair optionalAttrs readFile removeAttrs splitString; in { environment = optionalAttrs config.isLinux { sessionVariables.SHELLS = getExe pkgs.nushell; @@ -20,10 +20,12 @@ in { tree = "tree -CF --dirsfirst"; }; - systemPackages = [ - pkgs.fish # For completions. - pkgs.zoxide # For completions and better cd. - ]; + systemPackages = attrValues { + inherit (pkgs) + fish # For completions. + zoxide # For completions and better cd. + ; + }; variables.STARSHIP_LOG = "error"; }; diff --git a/modules/common/packages.nix b/modules/common/packages.nix index 34e011f..5c24f0c 100644 --- a/modules/common/packages.nix +++ b/modules/common/packages.nix @@ -1,57 +1,71 @@ { config, lib, pkgs, ... }: let - inherit (lib) optionals; + inherit (lib) attrValues optionalAttrs; in { - environment.systemPackages = [ - pkgs.asciinema - pkgs.cowsay - pkgs.curlHTTP3 - pkgs.dig - pkgs.doggo - pkgs.fastfetch - pkgs.fd - (pkgs.fortune.override { withOffensive = true; }) - pkgs.hyperfine - pkgs.moreutils - pkgs.openssl - pkgs.p7zip - pkgs.pstree - pkgs.rsync - pkgs.timg - pkgs.tree - pkgs.uutils-coreutils-noprefix - pkgs.yazi - pkgs.yt-dlp - ] ++ optionals config.isLinux [ - pkgs.traceroute - pkgs.usbutils - pkgs.strace - ] ++ optionals config.isDesktop [ - pkgs.clang_16 - pkgs.clang-tools_16 - pkgs.deno - pkgs.gh - pkgs.go - pkgs.jdk - pkgs.lld - pkgs.maven - pkgs.zig + environment.systemPackages = attrValues <| { + inherit (pkgs) + asciinema + cowsay + curlHTTP3 + dig + doggo + fastfetch + fd + hyperfine + moreutils + openssl + p7zip + pstree + rsync + timg + tokei + tree + typos + uutils-coreutils-noprefix + yazi + yt-dlp + ; - pkgs.qbittorrent - ] ++ optionals (config.isLinux && config.isDesktop) [ - pkgs.thunderbird + fortune = pkgs.fortune.override { withOffensive = true; }; + } // optionalAttrs config.isLinux { + inherit (pkgs) + traceroute + usbutils + strace + ; + } // optionalAttrs config.isDesktop { + inherit (pkgs) + clang_16 + clang-tools_16 + deno + gh + go + jdk + lld + maven + zig - pkgs.whatsapp-for-linux + qbittorrent + ; + } // optionalAttrs (config.isLinux && config.isDesktop) { + inherit (pkgs) + thunderbird - pkgs.element-desktop - pkgs.zulip - pkgs.fractal + whatsapp-for-linux - pkgs.obs-studio + element-desktop + zulip + fractal - pkgs.krita + obs-studio - pkgs.libreoffice - pkgs.hunspellDicts.en_US - pkgs.hunspellDicts.en_GB-ize - ]; + krita + + libreoffice + ; + + inherit (pkgs.hunspellDicts) + en_US + en_GB-ize + ; + }; } diff --git a/modules/common/python.nix b/modules/common/python.nix index 71ce4c5..db78ec5 100644 --- a/modules/common/python.nix +++ b/modules/common/python.nix @@ -1,6 +1,10 @@ -{ pkgs, ... }: { - environment.systemPackages = [ - pkgs.python314 - pkgs.uv - ]; +{ lib, pkgs, ... }: let + inherit (lib) attrValues; +in { + environment.systemPackages = attrValues { + inherit (pkgs) + python314 + uv + ; + }; } diff --git a/modules/common/rust.nix b/modules/common/rust.nix index d7aaa43..49c20fa 100644 --- a/modules/common/rust.nix +++ b/modules/common/rust.nix @@ -1,18 +1,24 @@ -{ pkgs, ... }: { +{ lib, pkgs, ... }: let + inherit (lib) attrValues; +in { environment.variables.CARGO_NET_GIT_FETCH_WITH_CLI = "true"; - environment.systemPackages = [ - pkgs.cargo-expand - pkgs.cargo-fuzz + environment.systemPackages = attrValues { + inherit (pkgs) + cargo-expand + cargo-fuzz - pkgs.evcxr + evcxr - (pkgs.fenix.complete.withComponents [ + taplo + ; + + fenix = pkgs.fenix.complete.withComponents [ "cargo" "clippy" "rust-src" "rustc" "rustfmt" - ]) - ]; + ]; + }; } diff --git a/modules/linux/fonts.nix b/modules/linux/fonts.nix index 029f4ca..acdcc05 100644 --- a/modules/linux/fonts.nix +++ b/modules/linux/fonts.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) disabled merge mkIf; + inherit (lib) attrValues disabled merge mkIf; in merge (mkIf config.isDesktop { @@ -9,15 +9,17 @@ in merge packages = [ pkgs.terminus_font ]; }; - fonts.packages = [ - config.theme.font.sans.package - config.theme.font.mono.package + fonts.packages = attrValues { + sans = config.theme.font.sans.package; + mono = config.theme.font.mono.package; - pkgs.noto-fonts - pkgs.noto-fonts-cjk-sans - pkgs.noto-fonts-lgc-plus - pkgs.noto-fonts-emoji - ]; + inherit (pkgs) + noto-fonts + noto-fonts-cjk-sans + noto-fonts-lgc-plus + noto-fonts-emoji + ; + }; }) (mkIf config.isServer { diff --git a/modules/linux/hyprland/hyprland.nix b/modules/linux/hyprland/hyprland.nix index 3a346e1..ca4b246 100644 --- a/modules/linux/hyprland/hyprland.nix +++ b/modules/linux/hyprland/hyprland.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) enabled merge mkIf flatten range; + inherit (lib) attrValues enabled merge mkIf flatten range; in merge <| mkIf config.isDesktop { hardware.graphics = enabled; @@ -19,18 +19,20 @@ in merge <| mkIf config.isDesktop { programs.xwayland = enabled; - environment.systemPackages = [ - pkgs.brightnessctl - pkgs.grim - # pkgs.hyprpicker - pkgs.slurp - pkgs.swappy - pkgs.swaybg - pkgs.wl-clipboard - pkgs.wtype - pkgs.xdg-utils - pkgs.xwaylandvideobridge - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + brightnessctl + grim + hyprpicker + slurp + swappy + swaybg + wl-clipboard + wtype + xdg-utils + xwaylandvideobridge + ; + }; home-manager.sharedModules = [{ xdg.configFile."xkb/symbols/tr-swapped-i".text = '' diff --git a/modules/linux/steam.nix b/modules/linux/steam.nix index b5669f0..be8c50b 100644 --- a/modules/linux/steam.nix +++ b/modules/linux/steam.nix @@ -1,10 +1,12 @@ { config, pkgs, lib, ... }: let - inherit (lib) merge mkIf; + inherit (lib) attrValues merge mkIf; in merge <| mkIf config.isDesktop { # Steam uses 32-bit drivers for some unholy fucking reason. hardware.graphics.enable32Bit = true; - environment.systemPackages = [ - pkgs.steam - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + steam + ; + }; } diff --git a/modules/linux/thunar.nix b/modules/linux/thunar.nix index 471f1d9..0a5f5e4 100644 --- a/modules/linux/thunar.nix +++ b/modules/linux/thunar.nix @@ -1,18 +1,25 @@ { config, lib, pkgs, ... }: let - inherit (lib) enabled merge mkIf; + inherit (lib) attrValues enabled merge mkIf; in merge <| mkIf config.isDesktop { programs.thunar = enabled { - plugins = [ - pkgs.xfce.thunar-archive-plugin - pkgs.xfce.thunar-media-tags-plugin - pkgs.xfce.thunar-volman - ]; + plugins = attrValues { + inherit (pkgs.xfce) + thunar-archive-plugin + thunar-media-tags-plugin + thunar-volman + ; + }; }; - environment.systemPackages = [ - pkgs.ark - pkgs.ffmpegthumbnailer - pkgs.libgsf - pkgs.xfce.tumbler - ]; + environment.systemPackages = attrValues { + inherit (pkgs) + ark + ffmpegthumbnailer + libgsf + ; + + inherit (pkgs.xfce) + tumbler + ; + }; }