Commit 4c443e83a91f

Vincent Demeester <vincent@sbr.pm>
2026-01-07 23:03:33
refactor: Use inherit syntax in Nix configurations
- Improve readability by following Nix idiomatic patterns - Reduce verbosity in attribute assignments across modules - Remove unused imports for cleaner code Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent c7849d4
Changed files (9)
home
common
lib
modules
jellyfin-auto-collections
jellyfin-favorites-sync
overlays
systems
aix
common
services
rhea
home/common/services/syncthing.nix
@@ -24,7 +24,7 @@ in
       #   ignores = { lines = [ "(?d).DS_Store" "**" ]; };
       # };
       devices = libx.generateSyncthingDevices hostname globals.machines;
-      folders = folders;
+      inherit folders;
     };
   };
 }
home/common/shell/openssh.nix
@@ -30,7 +30,7 @@
     // (
       # Generate shpool session aliases for each machine dynamically
       let
-        lib = pkgs.lib;
+        inherit (pkgs) lib;
         mkShpoolAliases =
           _: machine:
           let
lib/dns-helpers.nix
@@ -17,9 +17,9 @@
       map (machineName: {
         name = machineName;
         value = {
-          A = [ (globals.machines.${machineName}.net.ips or (globals.machines.${machineName}.net.vpn.ips)) ];
+          A = [ (globals.machines.${machineName}.net.ips or globals.machines.${machineName}.net.vpn.ips) ];
           subdomains."*".A = [
-            (globals.machines.${machineName}.net.ips or (globals.machines.${machineName}.net.vpn.ips))
+            (globals.machines.${machineName}.net.ips or globals.machines.${machineName}.net.vpn.ips)
           ];
         };
       }) machineList
modules/jellyfin-auto-collections/default.nix
@@ -37,7 +37,7 @@ let
     // lib.optionalAttrs (cfg.jellyseerr.enable && cfg.jellyseerr.passwordFile != null) {
       jellyseerr = {
         server_url = cfg.jellyseerr.serverUrl;
-        email = cfg.jellyseerr.email;
+        inherit (cfg.jellyseerr) email;
         password = "JELLYSEERR_PASSWORD_PLACEHOLDER";
         user_type = cfg.jellyseerr.userType;
       };
@@ -192,7 +192,7 @@ in
     # Create the user and group
     users.users.${cfg.user} = {
       isSystemUser = true;
-      group = cfg.group;
+      inherit (cfg) group;
       home = cfg.dataDir;
       createHome = true;
     };
modules/jellyfin-favorites-sync/default.nix
@@ -147,7 +147,7 @@ in
     # Create system user/group
     users.users.${cfg.user} = {
       isSystemUser = true;
-      group = cfg.group;
+      inherit (cfg) group;
       description = "Jellyfin favorites sync service user";
       home = "/var/lib/${cfg.user}";
       createHome = true;
overlays/default.nix
@@ -40,13 +40,13 @@ in
       config.allowUnfree = true;
       overlays = [
         (_final: _prev: {
-          claude-code = _prev.claude-code;
-          claude-code-acp = _prev.claude-code-acp;
-          opencode = _prev.opencode;
-          gemini-cli = _prev.gemini-cli;
-          cursor-cli = _prev.cursor-cli;
-          code-cursor = _prev.code-cursor;
-          antigravity = _prev.antigravity;
+          inherit (_prev) claude-code;
+          inherit (_prev) claude-code-acp;
+          inherit (_prev) opencode;
+          inherit (_prev) gemini-cli;
+          inherit (_prev) cursor-cli;
+          inherit (_prev) code-cursor;
+          inherit (_prev) antigravity;
           # example = prev.example.overrideAttrs (oldAttrs: rec {
           # ...
           # });
systems/aix/extra.nix
@@ -1,5 +1,4 @@
 {
-  lib,
   libx,
   globals,
   ...
systems/common/services/bind.nix
@@ -5,7 +5,7 @@
   ...
 }:
 let
-  dns = inputs.dns;
+  inherit (inputs) dns;
 
   # Generate zone file content and write to Nix store
   mkZoneFile =
systems/rhea/extra.nix
@@ -707,7 +707,7 @@ in
       name: cfg:
       lib.nameValuePair "exportarr-${name}" {
         enable = true;
-        port = cfg.port;
+        inherit (cfg) port;
         url = "http://localhost:${toString cfg.servicePort}";
         apiKeyFile = config.age.secrets."exportarr-${name}-apikey".path;
       }