From 6d6a97e7587ce0152a197fbdd3577d180efa4922 Mon Sep 17 00:00:00 2001 From: nydragon Date: Fri, 4 Apr 2025 22:53:23 +0200 Subject: [PATCH] chore(pre-commit): add statix --- .pre-commit-config.yaml | 9 ++++++++ flake.nix | 1 + home/graphical/thunderbird/default.nix | 3 +-- home/hyprland/default.nix | 4 ++-- home/sway/default.nix | 2 +- modules/nix/overlays.nix | 4 ++-- modules/scripts/default.nix | 2 +- options/fixes/rsyncd.nix | 2 +- options/server/navidrome.nix | 4 ++-- options/server/paperless-ngx/default.nix | 2 +- options/server/rustypaste.nix | 2 +- options/services/rsync-backup/default.nix | 2 +- options/system/users/default.nix | 27 ++++++++++------------- parts/lib/default.nix | 2 +- parts/lib/functions.nix | 2 +- parts/templates/basic/flake.nix | 2 +- parts/templates/rust/flake.nix | 4 ++-- users/ny/programs/fuzzel.nix | 2 +- 18 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 139cb06..c60b4b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,3 +41,12 @@ repos: files: .+\.nix$ args: ["-e", "-l"] stages: [pre-commit] + + - id: statix + name: Lint nix code + entry: statix + language: system + files: .+\.nix$ + pass_filenames: false + args: [fix] + stages: [pre-commit] diff --git a/flake.nix b/flake.nix index caa8fd8..2492c15 100644 --- a/flake.nix +++ b/flake.nix @@ -75,6 +75,7 @@ nodePackages.prettier typos deadnix + statix inputs'.agenix.packages.default ]; shellHook = '' diff --git a/home/graphical/thunderbird/default.nix b/home/graphical/thunderbird/default.nix index 4759f45..d5032e3 100644 --- a/home/graphical/thunderbird/default.nix +++ b/home/graphical/thunderbird/default.nix @@ -1,5 +1,4 @@ -{ ... }: -{ +_: { programs.thunderbird = { enable = true; settings = { diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index be5fce7..36e3bf5 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -9,8 +9,8 @@ let inherit (lib) mapAttrsToList mkIf hasAttr; inherit (lib.my) getExe getExe'; - roles = osConfig.modules.system.roles; - desktop = osConfig.modules.system.roles.desktop; + inherit (osConfig.modules.system) roles; + inherit (osConfig.modules.system.roles) desktop; in mkIf osConfig.programs.hyprland.enable { home.sessionVariables.ELECTRON_OZONE_PLATFORM_HINT = "auto"; diff --git a/home/sway/default.nix b/home/sway/default.nix index dec860d..286ac26 100644 --- a/home/sway/default.nix +++ b/home/sway/default.nix @@ -10,7 +10,7 @@ let inherit (lib) mapAttrs mkIf; inherit (lib.my) getExe getExe'; - desktop = osConfig.modules.system.roles.desktop; + inherit (osConfig.modules.system.roles) desktop; term = getExe desktop.terminal; filemanager = getExe desktop.filemanager; cliphistEnabled = osConfig.modules.services.cliphist.enable; diff --git a/modules/nix/overlays.nix b/modules/nix/overlays.nix index 420343f..6d1624f 100644 --- a/modules/nix/overlays.nix +++ b/modules/nix/overlays.nix @@ -9,10 +9,10 @@ (final: prev: { scripts = import ../scripts { inherit lib config; - pkgs = prev.pkgs; + inherit (prev) pkgs; }; - nysh = inputs'.nysh.packages.nysh; + inherit (inputs'.nysh.packages) nysh; }) ]; } diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix index 95fea17..be7db28 100644 --- a/modules/scripts/default.nix +++ b/modules/scripts/default.nix @@ -8,7 +8,7 @@ let inherit (pkgs.writers) writeFishBin writeBashBin; inherit (lib.my) getExe; - runner = config.modules.system.roles.desktop.runner; + inherit (config.modules.system.roles.desktop) runner; nixos-rebuild = name: word: diff --git a/options/fixes/rsyncd.nix b/options/fixes/rsyncd.nix index afc0d19..4f6c2d8 100644 --- a/options/fixes/rsyncd.nix +++ b/options/fixes/rsyncd.nix @@ -20,7 +20,7 @@ in }; settings = lib.mkOption { - type = settingsFormat.type; + inherit (settingsFormat) type; default = { }; example = { globalSection = { diff --git a/options/server/navidrome.nix b/options/server/navidrome.nix index e8509ca..2ec375e 100644 --- a/options/server/navidrome.nix +++ b/options/server/navidrome.nix @@ -45,7 +45,7 @@ in }; }; }; - settings = options.services.navidrome.settings; + inherit (options.services.navidrome) settings; restartPolicy = mkOption { type = str; default = "always"; @@ -60,7 +60,7 @@ in fileSystems.${cfg.library.path} = mkIf (cfg.library.type == "nfs") { device = "${cfg.library.source.ip}:${cfg.library.source.path}"; fsType = "nfs"; - options = cfg.library.source.options; + inherit (cfg.library.source) options; }; systemd.tmpfiles.rules = mkIf (cfg.library.type == "nfs") [ diff --git a/options/server/paperless-ngx/default.nix b/options/server/paperless-ngx/default.nix index 71b474a..db58993 100644 --- a/options/server/paperless-ngx/default.nix +++ b/options/server/paperless-ngx/default.nix @@ -22,7 +22,7 @@ in description = "Whether the port should be publicly accessible."; type = bool; }; - settings = options.services.paperless.settings; + inherit (options.services.paperless) settings; }; config = mkIf cfg.enable { diff --git a/options/server/rustypaste.nix b/options/server/rustypaste.nix index dc71d98..d79a8e9 100644 --- a/options/server/rustypaste.nix +++ b/options/server/rustypaste.nix @@ -134,7 +134,7 @@ in users.users = mkIf (cfg.user == "rustypaste") { rustypaste = { useDefaultShell = true; - group = cfg.group; + inherit (cfg) group; isSystemUser = true; }; }; diff --git a/options/services/rsync-backup/default.nix b/options/services/rsync-backup/default.nix index 8cc4ef6..de924da 100644 --- a/options/services/rsync-backup/default.nix +++ b/options/services/rsync-backup/default.nix @@ -85,7 +85,7 @@ in port = mkOption { type = port; - default = options.modules.server.rsync-daemon.port.default; + inherit (options.modules.server.rsync-daemon.port) default; }; }; diff --git a/options/system/users/default.nix b/options/system/users/default.nix index 98bb03b..7144e68 100644 --- a/options/system/users/default.nix +++ b/options/system/users/default.nix @@ -15,22 +15,19 @@ let ; cfg = config.modules.system.users; - file = submodule ( - { ... }: - { - options = { - path = mkOption { - type = either package null; - default = null; - }; - - content = mkOption { - type = either str null; - default = null; - }; + file = submodule (_: { + options = { + path = mkOption { + type = either package null; + default = null; }; - } - ); + + content = mkOption { + type = either str null; + default = null; + }; + }; + }); in { options.modules.system.users = mkOption { diff --git a/parts/lib/default.nix b/parts/lib/default.nix index 540b100..2925d64 100644 --- a/parts/lib/default.nix +++ b/parts/lib/default.nix @@ -5,7 +5,7 @@ my = import ./functions.nix { inherit inputs; lib = self; - self = args.self; + inherit (args) self; }; } ); diff --git a/parts/lib/functions.nix b/parts/lib/functions.nix index 17d15d9..e2fd9f0 100644 --- a/parts/lib/functions.nix +++ b/parts/lib/functions.nix @@ -112,7 +112,7 @@ in disko = { mkBoot = size: { - size = size; + inherit size; type = "EF00"; content = { type = "filesystem"; diff --git a/parts/templates/basic/flake.nix b/parts/templates/basic/flake.nix index 460bb42..9be3b40 100644 --- a/parts/templates/basic/flake.nix +++ b/parts/templates/basic/flake.nix @@ -21,7 +21,7 @@ devShell = pkgs.mkShell { buildInputs = with pkgs; [ ]; }; packages.${system} = { - hello = pkgs.hello; + inherit (pkgs) hello; default = self.packages.hello; }; } diff --git a/parts/templates/rust/flake.nix b/parts/templates/rust/flake.nix index f84476c..3b5ce04 100644 --- a/parts/templates/rust/flake.nix +++ b/parts/templates/rust/flake.nix @@ -30,12 +30,12 @@ rustBuild = rustPlatform.buildRustPackage { inherit pname; - version = manifest.version; + inherit (manifest) version; src = ./.; cargoLock.lockFile = ./Cargo.lock; meta = { - description = manifest.description; + inherit (manifest) description; #license = nixpkgs.lib.licenses.unlicense; maintainers = [ ]; }; diff --git a/users/ny/programs/fuzzel.nix b/users/ny/programs/fuzzel.nix index 25d3a9f..1db26b2 100644 --- a/users/ny/programs/fuzzel.nix +++ b/users/ny/programs/fuzzel.nix @@ -4,7 +4,7 @@ let in { rum.programs.fuzzel = { - enable = desktop.enable; + inherit (desktop) enable; settings = { main = { icon-theme = "Papirus-Dark";