Merge pull request #38111 from oxij/tree/cleanups

assorted cleanups

Changed files
+73 -74
nixos
pkgs
applications
networking
browsers
firefox
+9 -9
nixos/modules/config/nsswitch.nix
···
resolved = canLoadExternalModules && config.services.resolved.enable;
hostArray = [ "files" ]
-
++ optionals mymachines [ "mymachines" ]
-
++ optionals nssmdns [ "mdns_minimal [NOTFOUND=return]" ]
-
++ optionals nsswins [ "wins" ]
-
++ optionals resolved ["resolve [!UNAVAIL=return]"]
+
++ optional mymachines "mymachines"
+
++ optional nssmdns "mdns_minimal [NOTFOUND=return]"
+
++ optional nsswins "wins"
+
++ optional resolved "resolve [!UNAVAIL=return]"
++ [ "dns" ]
-
++ optionals nssmdns [ "mdns" ]
-
++ optionals myhostname ["myhostname" ];
+
++ optional nssmdns "mdns"
+
++ optional myhostname "myhostname";
passwdArray = [ "files" ]
++ optional sssd "sss"
-
++ optionals ldap [ "ldap" ]
-
++ optionals mymachines [ "mymachines" ]
+
++ optional ldap "ldap"
+
++ optional mymachines "mymachines"
++ [ "systemd" ];
shadowArray = [ "files" ]
++ optional sssd "sss"
-
++ optionals ldap [ "ldap" ];
+
++ optional ldap "ldap";
servicesArray = [ "files" ]
++ optional sssd "sss";
+23 -29
nixos/modules/config/users-groups.nix
···
};
};
-
# Install all the user shells
-
environment.systemPackages = systemShells;
-
users.groups = {
root.gid = ids.gids.root;
wheel.gid = ids.gids.wheel;
···
# for backwards compatibility
system.activationScripts.groups = stringAfter [ "users" ] "";
-
environment.etc."subuid" = {
-
text = subuidFile;
-
mode = "0644";
-
};
-
environment.etc."subgid" = {
-
text = subgidFile;
-
mode = "0644";
-
};
+
# Install all the user shells
+
environment.systemPackages = systemShells;
+
+
environment.etc = {
+
"subuid" = {
+
text = subuidFile;
+
mode = "0644";
+
};
+
"subgid" = {
+
text = subgidFile;
+
mode = "0644";
+
};
+
} // (mapAttrs' (name: { packages, ... }: {
+
name = "profiles/per-user/${name}";
+
value.source = pkgs.buildEnv {
+
name = "user-environment";
+
paths = packages;
+
inherit (config.environment) pathsToLink extraOutputsToInstall;
+
inherit (config.system.path) ignoreCollisions postBuild;
+
};
+
}) (filterAttrs (_: u: u.packages != []) cfg.users));
+
+
environment.profiles = [ "/etc/profiles/per-user/$USER" ];
assertions = [
{ assertion = !cfg.enforceIdUniqueness || (uidsAreUnique && gidsAreUnique);
···
};
-
imports =
-
[ (mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ])
-
(mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ])
-
{
-
environment = {
-
etc = mapAttrs' (name: { packages, ... }: {
-
name = "profiles/per-user/${name}";
-
value.source = pkgs.buildEnv {
-
name = "user-environment";
-
paths = packages;
-
inherit (config.environment) pathsToLink extraOutputsToInstall;
-
inherit (config.system.path) ignoreCollisions postBuild;
-
};
-
}) (filterAttrs (_: { packages, ... }: packages != []) cfg.users);
-
profiles = ["/etc/profiles/per-user/$USER"];
-
};
-
}
-
];
}
+5
nixos/modules/rename.nix
···
{
imports = [
+
(mkRenamedOptionModule [ "dysnomia" ] [ "services" "dysnomia" ])
(mkRenamedOptionModule [ "environment" "x11Packages" ] [ "environment" "systemPackages" ])
(mkRenamedOptionModule [ "environment" "enableBashCompletion" ] [ "programs" "bash" "enableCompletion" ])
(mkRenamedOptionModule [ "environment" "nix" ] [ "nix" "package" ])
···
(mkRenamedOptionModule [ "config" "system" "nixosRevision" ] [ "config" "system" "nixos" "revision" ])
(mkRenamedOptionModule [ "config" "system" "nixosCodeName" ] [ "config" "system" "nixos" "codeName" ])
(mkRenamedOptionModule [ "config" "system" "nixosLabel" ] [ "config" "system" "nixos" "label" ])
+
+
# Users
+
(mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ])
+
(mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ])
# Options that are obsolete and have no replacement.
(mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "")
+1 -1
nixos/modules/services/misc/disnix.nix
···
###### implementation
config = mkIf cfg.enable {
-
dysnomia.enable = true;
+
services.dysnomia.enable = true;
environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
+29 -29
nixos/modules/services/misc/dysnomia.nix
···
with lib;
let
-
cfg = config.dysnomia;
-
+
cfg = config.services.dysnomia;
+
printProperties = properties:
concatMapStrings (propertyName:
let
···
if isList property then "${propertyName}=(${lib.concatMapStrings (elem: "\"${toString elem}\" ") (properties."${propertyName}")})\n"
else "${propertyName}=\"${toString property}\"\n"
) (builtins.attrNames properties);
-
+
properties = pkgs.stdenv.mkDerivation {
name = "dysnomia-properties";
buildCommand = ''
···
EOF
'';
};
-
+
containersDir = pkgs.stdenv.mkDerivation {
name = "dysnomia-containers";
buildCommand = ''
mkdir -p $out
cd $out
-
+
${concatMapStrings (containerName:
let
containerProperties = cfg.containers."${containerName}";
···
) (builtins.attrNames cfg.containers)}
'';
};
-
+
linkMutableComponents = {containerName}:
''
mkdir ${containerName}
-
+
${concatMapStrings (componentName:
let
component = cfg.components."${containerName}"."${componentName}";
···
"ln -s ${component} ${containerName}/${componentName}\n"
) (builtins.attrNames (cfg.components."${containerName}" or {}))}
'';
-
+
componentsDir = pkgs.stdenv.mkDerivation {
name = "dysnomia-components";
buildCommand = ''
mkdir -p $out
cd $out
-
+
${concatMapStrings (containerName:
let
components = cfg.components."${containerName}";
···
in
{
options = {
-
dysnomia = {
-
+
services.dysnomia = {
+
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable Dysnomia";
};
-
+
enableAuthentication = mkOption {
type = types.bool;
default = false;
description = "Whether to publish privacy-sensitive authentication credentials";
};
-
+
package = mkOption {
type = types.path;
description = "The Dysnomia package";
};
-
+
properties = mkOption {
description = "An attribute set in which each attribute represents a machine property. Optionally, these values can be shell substitutions.";
default = {};
};
-
+
containers = mkOption {
description = "An attribute set in which each key represents a container and each value an attribute set providing its configuration properties";
default = {};
};
-
+
components = mkOption {
description = "An atttribute set in which each key represents a container and each value an attribute set in which each key represents a component and each value a derivation constructing its initial state";
default = {};
};
-
+
extraContainerProperties = mkOption {
description = "An attribute set providing additional container settings in addition to the default properties";
default = {};
};
-
+
extraContainerPaths = mkOption {
description = "A list of paths containing additional container configurations that are added to the search folders";
default = [];
};
-
+
extraModulePaths = mkOption {
description = "A list of paths containing additional modules that are added to the search folders";
default = [];
};
};
};
-
+
config = mkIf cfg.enable {
-
+
environment.etc = {
"dysnomia/containers" = {
source = containersDir;
···
source = properties;
};
};
-
+
environment.variables = {
DYSNOMIA_STATEDIR = "/var/state/dysnomia-nixos";
DYSNOMIA_CONTAINERS_PATH = "${lib.concatMapStrings (containerPath: "${containerPath}:") cfg.extraContainerPaths}/etc/dysnomia/containers";
DYSNOMIA_MODULES_PATH = "${lib.concatMapStrings (modulePath: "${modulePath}:") cfg.extraModulePaths}/etc/dysnomia/modules";
};
-
+
environment.systemPackages = [ cfg.package ];
-
-
dysnomia.package = pkgs.dysnomia.override (origArgs: {
+
+
services.dysnomia.package = pkgs.dysnomia.override (origArgs: {
enableApacheWebApplication = config.services.httpd.enable;
enableAxis2WebService = config.services.tomcat.axis2.enable;
enableEjabberdDump = config.services.ejabberd.enable;
···
enableTomcatWebApplication = config.services.tomcat.enable;
enableMongoDatabase = config.services.mongodb.enable;
});
-
-
dysnomia.properties = {
+
+
services.dysnomia.properties = {
hostname = config.networking.hostName;
system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;
···
'';
}}");
};
-
-
dysnomia.containers = lib.recursiveUpdate ({
+
+
services.dysnomia.containers = lib.recursiveUpdate ({
process = {};
wrapper = {};
}
+5 -5
nixos/modules/services/networking/tcpcrypt.nix
···
path = [ pkgs.iptables pkgs.tcpcrypt pkgs.procps ];
preStart = ''
-
mkdir -p /var/run/tcpcryptd
-
chown tcpcryptd /var/run/tcpcryptd
-
sysctl -n net.ipv4.tcp_ecn >/run/pre-tcpcrypt-ecn-state
+
mkdir -p /run/tcpcryptd
+
chown tcpcryptd /run/tcpcryptd
+
sysctl -n net.ipv4.tcp_ecn > /run/tcpcryptd/pre-tcpcrypt-ecn-state
sysctl -w net.ipv4.tcp_ecn=0
iptables -t raw -N nixos-tcpcrypt
···
script = "tcpcryptd -x 0x10";
postStop = ''
-
if [ -f /run/pre-tcpcrypt-ecn-state ]; then
-
sysctl -w net.ipv4.tcp_ecn=$(cat /run/pre-tcpcrypt-ecn-state)
+
if [ -f /run/tcpcryptd/pre-tcpcrypt-ecn-state ]; then
+
sysctl -w net.ipv4.tcp_ecn=$(cat /run/tcpcryptd/pre-tcpcrypt-ecn-state)
fi
iptables -t mangle -D POSTROUTING -j nixos-tcpcrypt || true
+1 -1
pkgs/applications/networking/browsers/firefox/wrapper.nix
···
}:
let
-
cfg = stdenv.lib.attrByPath [ browserName ] {} config;
+
cfg = config.${browserName} or {};
enableAdobeFlash = cfg.enableAdobeFlash or false;
ffmpegSupport = browser.ffmpegSupport or false;
gssSupport = browser.gssSupport or false;