Skip to content

Commit

Permalink
treewide: use attrs instead of list for types.loaOf options
Browse files Browse the repository at this point in the history
  • Loading branch information
rnhmjoj authored and worldofpeace committed Jan 6, 2020
1 parent 6bd13cc commit 1d61efb
Show file tree
Hide file tree
Showing 153 changed files with 817 additions and 1,012 deletions.
13 changes: 5 additions & 8 deletions nixos/modules/config/i18n.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@ with lib;
};

# ‘/etc/locale.conf’ is used by systemd.
environment.etc = singleton
{ target = "locale.conf";
source = pkgs.writeText "locale.conf"
''
LANG=${config.i18n.defaultLocale}
${concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${v}'') config.i18n.extraLocaleSettings)}
'';
};
environment.etc."locale.conf".source = pkgs.writeText "locale.conf"
''
LANG=${config.i18n.defaultLocale}
${concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${v}'') config.i18n.extraLocaleSettings)}
'';

};
}
4 changes: 3 additions & 1 deletion nixos/modules/config/ldap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ in

config = mkIf cfg.enable {

environment.etc = optional (!cfg.daemon.enable) ldapConfig;
environment.etc = optionalAttrs (!cfg.daemon.enable) {
"ldap.conf" = ldapConfig;
};

system.activationScripts = mkIf (!cfg.daemon.enable) {
ldap = stringAfter [ "etc" "groups" "users" ] ''
Expand Down
27 changes: 11 additions & 16 deletions nixos/modules/config/pulseaudio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ in {

config = mkMerge [
{
environment.etc = singleton {
target = "pulse/client.conf";
source = clientConf;
environment.etc = {
"pulse/client.conf".source = clientConf;
};

hardware.pulseaudio.configFile = mkDefault "${getBin overriddenPackage}/etc/pulse/default.pa";
Expand All @@ -228,19 +227,16 @@ in {

sound.enable = true;

environment.etc = [
{ target = "asound.conf";
source = alsaConf; }
environment.etc = {
"asound.conf".source = alsaConf;

{ target = "pulse/daemon.conf";
source = writeText "daemon.conf" (lib.generators.toKeyValue {} cfg.daemon.config); }
"pulse/daemon.conf".source = writeText "daemon.conf"
(lib.generators.toKeyValue {} cfg.daemon.config);

{ target = "openal/alsoft.conf";
source = writeText "alsoft.conf" "drivers=pulse"; }
"openal/alsoft.conf".source = writeText "alsoft.conf" "drivers=pulse";

{ target = "libao.conf";
source = writeText "libao.conf" "default_driver=pulse"; }
];
"libao.conf".source = writeText "libao.conf" "default_driver=pulse";
};

# Disable flat volumes to enable relative ones
hardware.pulseaudio.daemon.config.flat-volumes = mkDefault "no";
Expand Down Expand Up @@ -275,9 +271,8 @@ in {
})

(mkIf nonSystemWide {
environment.etc = singleton {
target = "pulse/default.pa";
source = myConfigFile;
environment.etc = {
"pulse/default.pa".source = myConfigFile;
};
systemd.user = {
services.pulseaudio = {
Expand Down
5 changes: 2 additions & 3 deletions nixos/modules/installer/cd-dvd/system-tarball-pc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ in

/* fake entry, just to have a happy stage-1. Users
may boot without having stage-1 though */
fileSystems = [
fileSystems.fake =
{ mountPoint = "/";
device = "/dev/something";
}
];
};

nixpkgs.config = {
packageOverrides = p: {
Expand Down
5 changes: 2 additions & 3 deletions nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ in

/* fake entry, just to have a happy stage-1. Users
may boot without having stage-1 though */
fileSystems = [
fileSystems.fake =
{ mountPoint = "/";
device = "/dev/something";
}
];
};

services.mingetty = {
# Some more help text.
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/installer/cd-dvd/system-tarball.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ in

# In stage 1 of the boot, mount the CD/DVD as the root FS by label
# so that we don't need to know its device.
fileSystems = [ ];
fileSystems = { };

# boot.initrd.availableKernelModules = [ "mvsdio" "reiserfs" "ext3" "ext4" ];

Expand Down
9 changes: 6 additions & 3 deletions nixos/modules/programs/dconf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ let
cfg = config.programs.dconf;

mkDconfProfile = name: path:
{ source = path; target = "dconf/profile/${name}"; };
{
name = "dconf/profile/${name}";
value.source = path;
};

in
{
Expand All @@ -29,8 +32,8 @@ in
###### implementation

config = mkIf (cfg.profiles != {} || cfg.enable) {
environment.etc = optionals (cfg.profiles != {})
(mapAttrsToList mkDconfProfile cfg.profiles);
environment.etc = optionalAttrs (cfg.profiles != {})
(mapAttrs' mkDconfProfile cfg.profiles);

services.dbus.packages = [ pkgs.dconf ];

Expand Down
28 changes: 12 additions & 16 deletions nixos/modules/programs/shadow.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,18 @@ in
config.users.defaultUserShell;

environment.etc =
[ { # /etc/login.defs: global configuration for pwdutils. You
# cannot login without it!
source = pkgs.writeText "login.defs" loginDefs;
target = "login.defs";
}

{ # /etc/default/useradd: configuration for useradd.
source = pkgs.writeText "useradd"
''
GROUP=100
HOME=/home
SHELL=${utils.toShellPath config.users.defaultUserShell}
'';
target = "default/useradd";
}
];
{ # /etc/login.defs: global configuration for pwdutils. You
# cannot login without it!
"login.defs".source = pkgs.writeText "login.defs" loginDefs;

# /etc/default/useradd: configuration for useradd.
"default/useradd".source = pkgs.writeText "useradd"
''
GROUP=100
HOME=/home
SHELL=${utils.toShellPath config.users.defaultUserShell}
'';
};

security.pam.services =
{ chsh = { rootOK = true; };
Expand Down
28 changes: 15 additions & 13 deletions nixos/modules/security/duosec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ let
accept_env_factor=${boolToStr cfg.acceptEnvFactor}
'';

loginCfgFile = optional cfg.ssh.enable
{ source = pkgs.writeText "login_duo.conf" configFileLogin;
mode = "0600";
user = "sshd";
target = "duo/login_duo.conf";
};
loginCfgFile = optionalAttrs cfg.ssh.enable {
"duo/login_duo.conf" =
{ source = pkgs.writeText "login_duo.conf" configFileLogin;
mode = "0600";
user = "sshd";
};
};

pamCfgFile = optional cfg.pam.enable
{ source = pkgs.writeText "pam_duo.conf" configFilePam;
mode = "0600";
user = "sshd";
target = "duo/pam_duo.conf";
};
pamCfgFile = optional cfg.pam.enable {
"duo/pam_duo.conf" =
{ source = pkgs.writeText "pam_duo.conf" configFilePam;
mode = "0600";
user = "sshd";
};
};
in
{
options = {
Expand Down Expand Up @@ -186,7 +188,7 @@ in
environment.systemPackages = [ pkgs.duo-unix ];

security.wrappers.login_duo.source = "${pkgs.duo-unix.out}/bin/login_duo";
environment.etc = loginCfgFile ++ pamCfgFile;
environment.etc = loginCfgFile // pamCfgFile;

/* If PAM *and* SSH are enabled, then don't do anything special.
If PAM isn't used, set the default SSH-only options. */
Expand Down
9 changes: 4 additions & 5 deletions nixos/modules/security/pam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ let

motd = pkgs.writeText "motd" config.users.motd;

makePAMService = pamService:
{ source = pkgs.writeText "${pamService.name}.pam" pamService.text;
target = "pam.d/${pamService.name}";
makePAMService = name: service:
{ name = "pam.d/${name}";
value.source = pkgs.writeText "${name}.pam" service.text;
};

in
Expand Down Expand Up @@ -760,8 +760,7 @@ in
};
};

environment.etc =
mapAttrsToList (n: v: makePAMService v) config.security.pam.services;
environment.etc = mapAttrs' makePAMService config.security.pam.services;

security.pam.services =
{ other.text =
Expand Down
5 changes: 2 additions & 3 deletions nixos/modules/security/pam_mount.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ in
config = mkIf (cfg.enable || anyPamMount) {

environment.systemPackages = [ pkgs.pam_mount ];
environment.etc = [{
target = "security/pam_mount.conf.xml";
environment.etc."security/pam_mount.conf.xml" = {
source =
let
extraUserVolumes = filterAttrs (n: u: u.cryptHomeLuks != null) config.users.users;
Expand Down Expand Up @@ -66,7 +65,7 @@ in
${concatStringsSep "\n" cfg.extraVolumes}
</pam_mount>
'';
}];
};

};
}
5 changes: 2 additions & 3 deletions nixos/modules/security/rtkit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ with lib;

services.dbus.packages = [ pkgs.rtkit ];

users.users = singleton
{ name = "rtkit";
uid = config.ids.uids.rtkit;
users.users.rtkit =
{ uid = config.ids.uids.rtkit;
description = "RealtimeKit daemon";
};

Expand Down
3 changes: 1 addition & 2 deletions nixos/modules/security/sudo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ in

security.pam.services.sudo = { sshAgentAuth = true; };

environment.etc = singleton
environment.etc.sudoers =
{ source =
pkgs.runCommand "sudoers"
{
Expand All @@ -222,7 +222,6 @@ in
# Make sure that the sudoers file is syntactically valid.
# (currently disabled - NIXOS-66)
"${pkgs.buildPackages.sudo}/sbin/visudo -f $src -c && cp $src $out";
target = "sudoers";
mode = "0440";
};

Expand Down
26 changes: 13 additions & 13 deletions nixos/modules/services/audio/mpd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ in {
};
};

users.users = optionalAttrs (cfg.user == name) (singleton {
inherit uid;
inherit name;
group = cfg.group;
extraGroups = [ "audio" ];
description = "Music Player Daemon user";
home = "${cfg.dataDir}";
});

users.groups = optionalAttrs (cfg.group == name) (singleton {
inherit name;
gid = gid;
});
users.users = optionalAttrs (cfg.user == name) {
${name} = {
inherit uid;
group = cfg.group;
extraGroups = [ "audio" ];
description = "Music Player Daemon user";
home = "${cfg.dataDir}";
};
};

users.groups = optionalAttrs (cfg.group == name) {
${name}.gid = gid;
};
};

}
7 changes: 4 additions & 3 deletions nixos/modules/services/backup/mysql-backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ in
};

config = mkIf cfg.enable {
users.users = optionalAttrs (cfg.user == defaultUser) (singleton
{ name = defaultUser;
users.users = optionalAttrs (cfg.user == defaultUser) {
${defaultUser} = {
isSystemUser = true;
createHome = false;
home = cfg.location;
group = "nogroup";
});
};
};

services.mysql.ensureUsers = [{
name = cfg.user;
Expand Down
3 changes: 1 addition & 2 deletions nixos/modules/services/cluster/kubernetes/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ in {
"d /var/lib/kubernetes 0755 kubernetes kubernetes -"
];

users.users = singleton {
name = "kubernetes";
users.users.kubernetes = {
uid = config.ids.uids.kubernetes;
description = "Kubernetes user";
extraGroups = [ "docker" ];
Expand Down
21 changes: 11 additions & 10 deletions nixos/modules/services/continuous-integration/buildbot/master.nix
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,19 @@ in {

config = mkIf cfg.enable {
users.groups = optional (cfg.group == "buildbot") {
name = "buildbot";
buildbot = { };
};

users.users = optional (cfg.user == "buildbot") {
name = "buildbot";
description = "Buildbot User.";
isNormalUser = true;
createHome = true;
home = cfg.home;
group = cfg.group;
extraGroups = cfg.extraGroups;
useDefaultShell = true;
users.users = optionalAttrs (cfg.user == "buildbot") {
buildbot = {
description = "Buildbot User.";
isNormalUser = true;
createHome = true;
home = cfg.home;
group = cfg.group;
extraGroups = cfg.extraGroups;
useDefaultShell = true;
};
};

systemd.services.buildbot-master = {
Expand Down
Loading

0 comments on commit 1d61efb

Please sign in to comment.