diff options
author | Will Fancher <elvishjerricco@gmail.com> | 2023-10-21 13:24:16 -0400 |
---|---|---|
committer | Will Fancher <elvishjerricco@gmail.com> | 2023-10-21 13:24:16 -0400 |
commit | 22325ce016eeb59be10ce964e106549ac95c1896 (patch) | |
tree | 5065c0b120e3508d73b7b624a531f9048cde7fbd /nixos/modules/config | |
parent | 7c9cc5a6e5d38010801741ac830a3f8fd667a7a0 (diff) | |
download | nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar.gz nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar.bz2 nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar.lz nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar.xz nixlib-22325ce016eeb59be10ce964e106549ac95c1896.tar.zst nixlib-22325ce016eeb59be10ce964e106549ac95c1896.zip |
systemd-stage-1: Support for user shells
Diffstat (limited to 'nixos/modules/config')
-rw-r--r-- | nixos/modules/config/users-groups.nix | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index 97268a8d83ef..b4251214876e 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -606,6 +606,14 @@ in { defaultText = literalExpression "config.users.users.\${name}.group"; default = cfg.users.${name}.group; }; + options.shell = mkOption { + type = types.passwdEntry types.path; + description = '' + The path to the user's shell in initrd. + ''; + default = "${pkgs.shadow}/bin/nologin"; + defaultText = literalExpression "\${pkgs.shadow}/bin/nologin"; + }; })); }; @@ -750,17 +758,20 @@ in { boot.initrd.systemd = lib.mkIf config.boot.initrd.systemd.enable { contents = { "/etc/passwd".text = '' - ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: { uid, group }: let + ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: { uid, group, shell }: let g = config.boot.initrd.systemd.groups.${group}; - in "${n}:x:${toString uid}:${toString g.gid}::/var/empty:") config.boot.initrd.systemd.users)} + in "${n}:x:${toString uid}:${toString g.gid}::/var/empty:${shell}") config.boot.initrd.systemd.users)} ''; "/etc/group".text = '' ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: { gid }: "${n}:x:${toString gid}:") config.boot.initrd.systemd.groups)} ''; + "/etc/shells".text = lib.concatStringsSep "\n" (lib.unique (lib.mapAttrsToList (_: u: u.shell) config.boot.initrd.systemd.users)) + "\n"; }; + storePaths = [ "${pkgs.shadow}/bin/nologin" ]; + users = { - root = {}; + root = { shell = lib.mkDefault "/bin/bash"; }; nobody = {}; }; |