Merge pull request #203826 from figsoda/lint

nixos/*: apply some lints from statix and nil

figsoda 5195ca23 6065d768

Changed files
+34 -48
nixos
modules
config
misc
profiles
services
cluster
hadoop
continuous-integration
buildbot
databases
games
misc
networking
web-apps
+2 -2
nixos/modules/config/users-groups.nix
···
# Install all the user shells
environment.systemPackages = systemShells;
-
environment.etc = (mapAttrs' (_: { packages, name, ... }: {
+
environment.etc = mapAttrs' (_: { packages, name, ... }: {
name = "profiles/per-user/${name}";
value.source = pkgs.buildEnv {
name = "user-environment";
···
inherit (config.environment) pathsToLink extraOutputsToInstall;
inherit (config.system.path) ignoreCollisions postBuild;
};
-
}) (filterAttrs (_: u: u.packages != []) cfg.users));
+
}) (filterAttrs (_: u: u.packages != []) cfg.users);
environment.profiles = [
"$HOME/.nix-profile"
+2 -7
nixos/modules/misc/nixpkgs.nix
···
optionalAttrs (lhs ? packageOverrides) {
packageOverrides = pkgs:
optCall lhs.packageOverrides pkgs //
-
optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs;
+
optCall (attrByPath [ "packageOverrides" ] { } rhs) pkgs;
} //
optionalAttrs (lhs ? perlPackageOverrides) {
perlPackageOverrides = pkgs:
optCall lhs.perlPackageOverrides pkgs //
-
optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs;
+
optCall (attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
};
configType = mkOptionType {
···
# Context for messages
hostPlatformLine = optionalString hasHostPlatform "${showOptionWithDefLocs opt.hostPlatform}";
buildPlatformLine = optionalString hasBuildPlatform "${showOptionWithDefLocs opt.buildPlatform}";
-
platformLines = optionalString hasPlatform ''
-
Your system configuration configures nixpkgs with platform parameters:
-
${hostPlatformLine
-
}${buildPlatformLine
-
}'';
legacyOptionsDefined =
optional (opt.localSystem.highestPrio < (mkDefault {}).priority) opt.system
+5 -6
nixos/modules/profiles/docker-container.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
+
let
+
inherit (pkgs) writeScript;
-
let inherit (pkgs) writeScript; in
+
pkgs2storeContents = map (x: { object = x; symlink = "none"; });
+
in
-
let
-
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
-
-
in {
+
{
# Docker image config.
imports = [
../installer/cd-dvd/channel.nix
+4 -4
nixos/modules/services/cluster/hadoop/hbase.nix
···
services.hadoop.hbaseSiteInternal."hbase.rootdir" = cfg.hbase.rootdir;
-
networking.firewall.allowedTCPPorts = (mkIf cfg.hbase.master.openFirewall [
+
networking.firewall.allowedTCPPorts = mkIf cfg.hbase.master.openFirewall [
16000 16010
-
]);
+
];
})
···
services.hadoop.hbaseSiteInternal."hbase.rootdir" = cfg.hbase.rootdir;
networking = {
-
firewall.allowedTCPPorts = (mkIf cfg.hbase.regionServer.openFirewall [
+
firewall.allowedTCPPorts = mkIf cfg.hbase.regionServer.openFirewall [
16020 16030
-
]);
+
];
hosts = mkIf cfg.hbase.regionServer.overrideHosts {
"127.0.0.2" = mkForce [ ];
"::1" = mkForce [ ];
+2 -4
nixos/modules/services/continuous-integration/buildbot/master.nix
···
python = cfg.package.pythonModule;
-
escapeStr = s: escape ["'"] s;
+
escapeStr = escape [ "'" ];
defaultMasterCfg = pkgs.writeText "master.cfg" ''
from buildbot.plugins import *
···
description = "Buildbot User.";
isNormalUser = true;
createHome = true;
-
home = cfg.home;
-
group = cfg.group;
-
extraGroups = cfg.extraGroups;
+
inherit (cfg) home group extraGroups;
useDefaultShell = true;
};
};
+3 -7
nixos/modules/services/databases/redis.nix
···
'');
servers = mkOption {
-
type = with types; attrsOf (submodule ({config, name, ...}@args: {
+
type = with types; attrsOf (submodule ({ config, name, ... }: {
options = {
enable = mkEnableOption (lib.mdDoc ''
Redis server.
···
};
config.settings = mkMerge [
{
-
port = config.port;
+
inherit (config) port logfile databases maxclients appendOnly;
daemonize = false;
supervised = "systemd";
loglevel = config.logLevel;
-
logfile = config.logfile;
syslog-enabled = config.syslog;
-
databases = config.databases;
-
maxclients = config.maxclients;
save = if config.save == []
then ''""'' # Disable saving with `save = ""`
else map
···
config.save;
dbfilename = "dump.rdb";
dir = "/var/lib/${redisName name}";
-
appendOnly = config.appendOnly;
appendfsync = config.appendFsync;
slowlog-log-slower-than = config.slowLogLogSlowerThan;
slowlog-max-len = config.slowLogMaxLen;
}
-
(mkIf (config.bind != null) { bind = config.bind; })
+
(mkIf (config.bind != null) { inherit (config) bind; })
(mkIf (config.unixSocket != null) {
unixsocket = config.unixSocket;
unixsocketperm = toString config.unixSocketPerm;
+3 -3
nixos/modules/services/games/crossfire-server.nix
···
exp_table = "";
forbid = "";
metaserver2 = "";
-
motd = (fileContents "${cfg.package}/etc/crossfire/motd");
-
news = (fileContents "${cfg.package}/etc/crossfire/news");
-
rules = (fileContents "${cfg.package}/etc/crossfire/rules");
+
motd = fileContents "${cfg.package}/etc/crossfire/motd";
+
news = fileContents "${cfg.package}/etc/crossfire/news";
+
rules = fileContents "${cfg.package}/etc/crossfire/rules";
settings = "";
stat_bonus = "";
} // cfg.configFiles);
+2 -2
nixos/modules/services/misc/gammu-smsd.nix
···
initDBDir = "share/doc/gammu/examples/sql";
gammuPackage = with cfg.backend; (pkgs.gammu.override {
-
dbiSupport = (service == "sql" && sql.driver == "sqlite");
-
postgresSupport = (service == "sql" && sql.driver == "native_pgsql");
+
dbiSupport = service == "sql" && sql.driver == "sqlite";
+
postgresSupport = service == "sql" && sql.driver == "native_pgsql";
});
in {
+2 -4
nixos/modules/services/networking/keepalived/default.nix
···
''
) vrrpInstances);
-
virtualIpLine = (ip:
-
ip.addr
+
virtualIpLine = ip: ip.addr
+ optionalString (notNullOrEmpty ip.brd) " brd ${ip.brd}"
+ optionalString (notNullOrEmpty ip.dev) " dev ${ip.dev}"
+ optionalString (notNullOrEmpty ip.scope) " scope ${ip.scope}"
-
+ optionalString (notNullOrEmpty ip.label) " label ${ip.label}"
-
);
+
+ optionalString (notNullOrEmpty ip.label) " label ${ip.label}";
notNullOrEmpty = s: !(s == null || s == "");
+1 -1
nixos/modules/services/networking/prosody.nix
···
if builtins.isString x then ''"${x}"''
else if builtins.isBool x then boolToString x
else if builtins.isInt x then toString x
-
else if builtins.isList x then ''{ ${lib.concatStringsSep ", " (map (n: toLua n) x) } }''
+
else if builtins.isList x then "{ ${lib.concatMapStringsSep ", " toLua x} }"
else throw "Invalid Lua value";
createSSLOptsStr = o: ''
+4 -4
nixos/modules/services/networking/softether.nix
···
let
cfg = config.services.softether;
-
package = cfg.package.override { dataDir = cfg.dataDir; };
+
package = cfg.package.override { inherit (cfg) dataDir; };
in
{
···
};
}
-
(mkIf (cfg.vpnserver.enable) {
+
(mkIf cfg.vpnserver.enable {
systemd.services.vpnserver = {
description = "SoftEther VPN Server";
after = [ "softether-init.service" ];
···
};
})
-
(mkIf (cfg.vpnbridge.enable) {
+
(mkIf cfg.vpnbridge.enable {
systemd.services.vpnbridge = {
description = "SoftEther VPN Bridge";
after = [ "softether-init.service" ];
···
};
})
-
(mkIf (cfg.vpnclient.enable) {
+
(mkIf cfg.vpnclient.enable {
systemd.services.vpnclient = {
description = "SoftEther VPN Client";
after = [ "softether-init.service" ];
+2 -2
nixos/modules/services/web-apps/discourse.nix
···
# We only want to create a database if we're actually going to connect to it.
databaseActuallyCreateLocally = cfg.database.createLocally && cfg.database.host == null;
-
tlsEnabled = (cfg.enableACME
+
tlsEnabled = cfg.enableACME
|| cfg.sslCertificate != null
-
|| cfg.sslCertificateKey != null);
+
|| cfg.sslCertificateKey != null;
in
{
options = {
+2 -2
nixos/modules/services/web-apps/invoiceplane.nix
···
)) eachSite;
systemd.services =
-
(mapAttrs' (hostName: cfg: (
+
mapAttrs' (hostName: cfg: (
nameValuePair "invoiceplane-cron-${hostName}" (mkIf cfg.cron.enable {
serviceConfig = {
Type = "oneshot";
···
ExecStart = "${pkgs.curl}/bin/curl --header 'Host: ${hostName}' http://localhost/invoices/cron/recur/${cfg.cron.key}";
};
})
-
)) eachSite);
+
)) eachSite;
}