lol

Merge pull request #203826 from figsoda/lint

nixos/*: apply some lints from statix and nil

authored by

figsoda and committed by
GitHub
5195ca23 6065d768

+34 -48
+2 -2
nixos/modules/config/users-groups.nix
··· 618 618 # Install all the user shells 619 619 environment.systemPackages = systemShells; 620 620 621 - environment.etc = (mapAttrs' (_: { packages, name, ... }: { 621 + environment.etc = mapAttrs' (_: { packages, name, ... }: { 622 622 name = "profiles/per-user/${name}"; 623 623 value.source = pkgs.buildEnv { 624 624 name = "user-environment"; ··· 626 626 inherit (config.environment) pathsToLink extraOutputsToInstall; 627 627 inherit (config.system.path) ignoreCollisions postBuild; 628 628 }; 629 - }) (filterAttrs (_: u: u.packages != []) cfg.users)); 629 + }) (filterAttrs (_: u: u.packages != []) cfg.users); 630 630 631 631 environment.profiles = [ 632 632 "$HOME/.nix-profile"
+2 -7
nixos/modules/misc/nixpkgs.nix
··· 23 23 optionalAttrs (lhs ? packageOverrides) { 24 24 packageOverrides = pkgs: 25 25 optCall lhs.packageOverrides pkgs // 26 - optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; 26 + optCall (attrByPath [ "packageOverrides" ] { } rhs) pkgs; 27 27 } // 28 28 optionalAttrs (lhs ? perlPackageOverrides) { 29 29 perlPackageOverrides = pkgs: 30 30 optCall lhs.perlPackageOverrides pkgs // 31 - optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; 31 + optCall (attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs; 32 32 }; 33 33 34 34 configType = mkOptionType { ··· 67 67 # Context for messages 68 68 hostPlatformLine = optionalString hasHostPlatform "${showOptionWithDefLocs opt.hostPlatform}"; 69 69 buildPlatformLine = optionalString hasBuildPlatform "${showOptionWithDefLocs opt.buildPlatform}"; 70 - platformLines = optionalString hasPlatform '' 71 - Your system configuration configures nixpkgs with platform parameters: 72 - ${hostPlatformLine 73 - }${buildPlatformLine 74 - }''; 75 70 76 71 legacyOptionsDefined = 77 72 optional (opt.localSystem.highestPrio < (mkDefault {}).priority) opt.system
+5 -6
nixos/modules/profiles/docker-container.nix
··· 1 1 { config, lib, pkgs, ... }: 2 2 3 - with lib; 3 + let 4 + inherit (pkgs) writeScript; 4 5 5 - let inherit (pkgs) writeScript; in 6 + pkgs2storeContents = map (x: { object = x; symlink = "none"; }); 7 + in 6 8 7 - let 8 - pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l; 9 - 10 - in { 9 + { 11 10 # Docker image config. 12 11 imports = [ 13 12 ../installer/cd-dvd/channel.nix
+4 -4
nixos/modules/services/cluster/hadoop/hbase.nix
··· 141 141 142 142 services.hadoop.hbaseSiteInternal."hbase.rootdir" = cfg.hbase.rootdir; 143 143 144 - networking.firewall.allowedTCPPorts = (mkIf cfg.hbase.master.openFirewall [ 144 + networking.firewall.allowedTCPPorts = mkIf cfg.hbase.master.openFirewall [ 145 145 16000 16010 146 - ]); 146 + ]; 147 147 148 148 }) 149 149 ··· 168 168 services.hadoop.hbaseSiteInternal."hbase.rootdir" = cfg.hbase.rootdir; 169 169 170 170 networking = { 171 - firewall.allowedTCPPorts = (mkIf cfg.hbase.regionServer.openFirewall [ 171 + firewall.allowedTCPPorts = mkIf cfg.hbase.regionServer.openFirewall [ 172 172 16020 16030 173 - ]); 173 + ]; 174 174 hosts = mkIf cfg.hbase.regionServer.overrideHosts { 175 175 "127.0.0.2" = mkForce [ ]; 176 176 "::1" = mkForce [ ];
+2 -4
nixos/modules/services/continuous-integration/buildbot/master.nix
··· 10 10 11 11 python = cfg.package.pythonModule; 12 12 13 - escapeStr = s: escape ["'"] s; 13 + escapeStr = escape [ "'" ]; 14 14 15 15 defaultMasterCfg = pkgs.writeText "master.cfg" '' 16 16 from buildbot.plugins import * ··· 245 245 description = "Buildbot User."; 246 246 isNormalUser = true; 247 247 createHome = true; 248 - home = cfg.home; 249 - group = cfg.group; 250 - extraGroups = cfg.extraGroups; 248 + inherit (cfg) home group extraGroups; 251 249 useDefaultShell = true; 252 250 }; 253 251 };
+3 -7
nixos/modules/services/databases/redis.nix
··· 67 67 ''); 68 68 69 69 servers = mkOption { 70 - type = with types; attrsOf (submodule ({config, name, ...}@args: { 70 + type = with types; attrsOf (submodule ({ config, name, ... }: { 71 71 options = { 72 72 enable = mkEnableOption (lib.mdDoc '' 73 73 Redis server. ··· 271 271 }; 272 272 config.settings = mkMerge [ 273 273 { 274 - port = config.port; 274 + inherit (config) port logfile databases maxclients appendOnly; 275 275 daemonize = false; 276 276 supervised = "systemd"; 277 277 loglevel = config.logLevel; 278 - logfile = config.logfile; 279 278 syslog-enabled = config.syslog; 280 - databases = config.databases; 281 - maxclients = config.maxclients; 282 279 save = if config.save == [] 283 280 then ''""'' # Disable saving with `save = ""` 284 281 else map ··· 286 283 config.save; 287 284 dbfilename = "dump.rdb"; 288 285 dir = "/var/lib/${redisName name}"; 289 - appendOnly = config.appendOnly; 290 286 appendfsync = config.appendFsync; 291 287 slowlog-log-slower-than = config.slowLogLogSlowerThan; 292 288 slowlog-max-len = config.slowLogMaxLen; 293 289 } 294 - (mkIf (config.bind != null) { bind = config.bind; }) 290 + (mkIf (config.bind != null) { inherit (config) bind; }) 295 291 (mkIf (config.unixSocket != null) { 296 292 unixsocket = config.unixSocket; 297 293 unixsocketperm = toString config.unixSocketPerm;
+3 -3
nixos/modules/services/games/crossfire-server.nix
··· 131 131 exp_table = ""; 132 132 forbid = ""; 133 133 metaserver2 = ""; 134 - motd = (fileContents "${cfg.package}/etc/crossfire/motd"); 135 - news = (fileContents "${cfg.package}/etc/crossfire/news"); 136 - rules = (fileContents "${cfg.package}/etc/crossfire/rules"); 134 + motd = fileContents "${cfg.package}/etc/crossfire/motd"; 135 + news = fileContents "${cfg.package}/etc/crossfire/news"; 136 + rules = fileContents "${cfg.package}/etc/crossfire/rules"; 137 137 settings = ""; 138 138 stat_bonus = ""; 139 139 } // cfg.configFiles);
+2 -2
nixos/modules/services/misc/gammu-smsd.nix
··· 45 45 initDBDir = "share/doc/gammu/examples/sql"; 46 46 47 47 gammuPackage = with cfg.backend; (pkgs.gammu.override { 48 - dbiSupport = (service == "sql" && sql.driver == "sqlite"); 49 - postgresSupport = (service == "sql" && sql.driver == "native_pgsql"); 48 + dbiSupport = service == "sql" && sql.driver == "sqlite"; 49 + postgresSupport = service == "sql" && sql.driver == "native_pgsql"; 50 50 }); 51 51 52 52 in {
+2 -4
nixos/modules/services/networking/keepalived/default.nix
··· 84 84 '' 85 85 ) vrrpInstances); 86 86 87 - virtualIpLine = (ip: 88 - ip.addr 87 + virtualIpLine = ip: ip.addr 89 88 + optionalString (notNullOrEmpty ip.brd) " brd ${ip.brd}" 90 89 + optionalString (notNullOrEmpty ip.dev) " dev ${ip.dev}" 91 90 + optionalString (notNullOrEmpty ip.scope) " scope ${ip.scope}" 92 - + optionalString (notNullOrEmpty ip.label) " label ${ip.label}" 93 - ); 91 + + optionalString (notNullOrEmpty ip.label) " label ${ip.label}"; 94 92 95 93 notNullOrEmpty = s: !(s == null || s == ""); 96 94
+1 -1
nixos/modules/services/networking/prosody.nix
··· 263 263 if builtins.isString x then ''"${x}"'' 264 264 else if builtins.isBool x then boolToString x 265 265 else if builtins.isInt x then toString x 266 - else if builtins.isList x then ''{ ${lib.concatStringsSep ", " (map (n: toLua n) x) } }'' 266 + else if builtins.isList x then "{ ${lib.concatMapStringsSep ", " toLua x} }" 267 267 else throw "Invalid Lua value"; 268 268 269 269 createSSLOptsStr = o: ''
+4 -4
nixos/modules/services/networking/softether.nix
··· 5 5 let 6 6 cfg = config.services.softether; 7 7 8 - package = cfg.package.override { dataDir = cfg.dataDir; }; 8 + package = cfg.package.override { inherit (cfg) dataDir; }; 9 9 10 10 in 11 11 { ··· 88 88 }; 89 89 } 90 90 91 - (mkIf (cfg.vpnserver.enable) { 91 + (mkIf cfg.vpnserver.enable { 92 92 systemd.services.vpnserver = { 93 93 description = "SoftEther VPN Server"; 94 94 after = [ "softether-init.service" ]; ··· 109 109 }; 110 110 }) 111 111 112 - (mkIf (cfg.vpnbridge.enable) { 112 + (mkIf cfg.vpnbridge.enable { 113 113 systemd.services.vpnbridge = { 114 114 description = "SoftEther VPN Bridge"; 115 115 after = [ "softether-init.service" ]; ··· 130 130 }; 131 131 }) 132 132 133 - (mkIf (cfg.vpnclient.enable) { 133 + (mkIf cfg.vpnclient.enable { 134 134 systemd.services.vpnclient = { 135 135 description = "SoftEther VPN Client"; 136 136 after = [ "softether-init.service" ];
+2 -2
nixos/modules/services/web-apps/discourse.nix
··· 19 19 # We only want to create a database if we're actually going to connect to it. 20 20 databaseActuallyCreateLocally = cfg.database.createLocally && cfg.database.host == null; 21 21 22 - tlsEnabled = (cfg.enableACME 22 + tlsEnabled = cfg.enableACME 23 23 || cfg.sslCertificate != null 24 - || cfg.sslCertificateKey != null); 24 + || cfg.sslCertificateKey != null; 25 25 in 26 26 { 27 27 options = {
+2 -2
nixos/modules/services/web-apps/invoiceplane.nix
··· 327 327 )) eachSite; 328 328 329 329 systemd.services = 330 - (mapAttrs' (hostName: cfg: ( 330 + mapAttrs' (hostName: cfg: ( 331 331 nameValuePair "invoiceplane-cron-${hostName}" (mkIf cfg.cron.enable { 332 332 serviceConfig = { 333 333 Type = "oneshot"; ··· 335 335 ExecStart = "${pkgs.curl}/bin/curl --header 'Host: ${hostName}' http://localhost/invoices/cron/recur/${cfg.cron.key}"; 336 336 }; 337 337 }) 338 - )) eachSite); 338 + )) eachSite; 339 339 340 340 } 341 341