From ec55562ec3906aaf9406eae725c584d9094ae420 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 28 May 2009 12:24:56 +0000 Subject: [PATCH] * Move the configuration of the pwdutils (passwd, useradd etc.) to modules/programs/pwdutils. * Renamed config.system.shell to config.users.defaultUserShell and updated the description to make clear it has to be a non-store path. svn path=/nixos/branches/modular-nixos/; revision=15761 --- etc/default.nix | 20 -------- etc/default/useradd | 3 -- modules/config/users-groups.nix | 5 +- modules/module-list.nix | 1 + {etc => modules/programs/pwdutils}/login.defs | 0 .../programs/pwdutils/passwd.conf | 0 modules/programs/pwdutils/pwdutils.nix | 50 +++++++++++++++++++ .../system/activation/activation-script.nix | 2 +- system/system-options.nix | 12 ----- 9 files changed, 54 insertions(+), 39 deletions(-) delete mode 100644 etc/default/useradd rename {etc => modules/programs/pwdutils}/login.defs (100%) rename etc/default/passwd => modules/programs/pwdutils/passwd.conf (100%) create mode 100644 modules/programs/pwdutils/pwdutils.nix diff --git a/etc/default.nix b/etc/default.nix index 37c0a360d8d..ea37a91adb1 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -72,26 +72,6 @@ let target = "hosts"; } - { # Configuration for pwdutils (login, passwd, useradd, etc.). - # You cannot login without it! - source = ./login.defs; - target = "login.defs"; - } - - { # Configuration for passwd and friends (e.g., hash algorithm - # for /etc/passwd). - source = ./default/passwd; - target = "default/passwd"; - } - - { # Configuration for useradd. - source = pkgs.substituteAll { - src = ./default/useradd; - defaultShell = config.system.shell; - }; - target = "default/useradd"; - } - ] # A bunch of PAM configuration files for various programs. diff --git a/etc/default/useradd b/etc/default/useradd deleted file mode 100644 index df221d58511..00000000000 --- a/etc/default/useradd +++ /dev/null @@ -1,3 +0,0 @@ -GROUP=100 -HOME=/home -SHELL=@defaultShell@ diff --git a/modules/config/users-groups.nix b/modules/config/users-groups.nix index fe2c4138169..9acaae17db9 100644 --- a/modules/config/users-groups.nix +++ b/modules/config/users-groups.nix @@ -42,7 +42,6 @@ in ###### implementation let ids = import ../../system/ids.nix; - defaultShell = config.system.shell; # User accounts to be created/updated by NixOS. users = @@ -53,7 +52,7 @@ let uid = ids.uids.root; description = "System administrator"; home = "/root"; - shell = defaultShell; + shell = config.users.defaultUserShell; group = "root"; } { name = "nobody"; @@ -78,7 +77,7 @@ let , group ? "nogroup" , extraGroups ? [] , home ? "/var/empty" - , shell ? (if useDefaultShell then defaultShell else "/noshell") + , shell ? (if useDefaultShell then config.users.defaultUserShell else "/noshell") , createHome ? false , useDefaultShell ? false }: diff --git a/modules/module-list.nix b/modules/module-list.nix index 5b7d2f7836c..a8ca8a006b5 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -9,6 +9,7 @@ ./installer/grub/grub.nix ./legacy.nix ./programs/bash/bash.nix + ./programs/pwdutils/pwdutils.nix ./programs/ssh.nix ./programs/ssmtp.nix ./security/setuid-wrappers.nix diff --git a/etc/login.defs b/modules/programs/pwdutils/login.defs similarity index 100% rename from etc/login.defs rename to modules/programs/pwdutils/login.defs diff --git a/etc/default/passwd b/modules/programs/pwdutils/passwd.conf similarity index 100% rename from etc/default/passwd rename to modules/programs/pwdutils/passwd.conf diff --git a/modules/programs/pwdutils/pwdutils.nix b/modules/programs/pwdutils/pwdutils.nix new file mode 100644 index 00000000000..ec5d31a1ad1 --- /dev/null +++ b/modules/programs/pwdutils/pwdutils.nix @@ -0,0 +1,50 @@ +# Configuration for the pwdutils suite of tools: passwd, useradd, etc. + +{config, pkgs, ...}: + +let + + options = { + + users.defaultUserShell = pkgs.lib.mkOption { + default = "/var/run/current-system/sw/bin/bash"; + description = '' + This option defined the default shell assigned to user + accounts. This must not be a store path, since the path is + used outside the store (in particular in /etc/passwd). + Rather, it should be the path of a symlink that points to the + actual shell in the Nix store. + ''; + }; + + }; + +in + +{ + require = [options]; + + environment.etc = + [ { # /etc/login.defs: global configuration for pwdutils. You + # cannot login without it! + source = ./login.defs; + target = "login.defs"; + } + + { # /etc/default/passwd: configuration for passwd and friends + # (e.g., hash algorithm for /etc/passwd). + source = ./passwd.conf; + target = "default/passwd"; + } + + { # /etc/default/useradd: configuration for useradd. + source = pkgs.writeText "useradd" + '' + GROUP=100 + HOME=/home + SHELL=${config.users.defaultUserShell} + ''; + target = "default/useradd"; + } + ]; +} diff --git a/modules/system/activation/activation-script.nix b/modules/system/activation/activation-script.nix index 4cf6548ed29..7d3f6b2ceec 100644 --- a/modules/system/activation/activation-script.nix +++ b/modules/system/activation/activation-script.nix @@ -106,7 +106,7 @@ let touch /etc/shadow; chmod 0600 /etc/shadow # Can't use useradd, since it complains that it doesn't know us # (bootstrap problem!). - echo "root:x:0:0:System administrator:$rootHome:${config.system.shell}" >> /etc/passwd + echo "root:x:0:0:System administrator:$rootHome:${config.users.defaultUserShell}" >> /etc/passwd echo "root::::::::" >> /etc/shadow echo | passwd --stdin root fi diff --git a/system/system-options.nix b/system/system-options.nix index 53705900b64..25bc58b5704 100644 --- a/system/system-options.nix +++ b/system/system-options.nix @@ -15,18 +15,6 @@ let Attribute set of derivations used to setup the system. ''; }; - - shell = mkOption { - default = "/var/run/current-system/sw/bin/bash"; - description = '' - This option defines the path to the Bash shell. It should - generally not be overriden. - ''; - merge = list: - assert list != [] && builtins.tail list == []; - builtins.head list; - }; - }; }; in