lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #16189 from zimbatm/usershell-config

User shell config

authored by zimbatm.tngl.sh and committed by

GitHub 31c158ad b0f8416c

+85 -20
+4
lib/types.nix
··· 100 100 in if isDerivation res then res else toDerivation res; 101 101 }; 102 102 103 + shellPackage = package // { 104 + check = x: (package.check x) && (hasAttr "shellPath" x); 105 + }; 106 + 103 107 path = mkOptionType { 104 108 name = "path"; 105 109 # Hacky: there is no ‘isPath’ primop.
+6
nixos/lib/utils.nix
··· 8 8 replaceChars ["/" "-" " "] ["-" "\\x2d" "\\x20"] 9 9 (if hasPrefix "/" s then substring 1 (stringLength s) s else s); 10 10 11 + # Returns a system path for a given shell package 12 + toShellPath = shell: 13 + if types.shellPackage.check shell then 14 + "/run/current-system/sw${shell.shellPath}" 15 + else 16 + shell; 11 17 }
+4 -4
nixos/modules/config/shells-environment.nix
··· 1 1 # This module defines a global environment configuration and 2 2 # a common configuration for all shells. 3 3 4 - { config, lib, pkgs, ... }: 4 + { config, lib, utils, pkgs, ... }: 5 5 6 6 with lib; 7 7 ··· 135 135 136 136 environment.shells = mkOption { 137 137 default = []; 138 - example = [ "/run/current-system/sw/bin/zsh" ]; 138 + example = literalExample "[ pkgs.bashInteractive pkgs.zsh ]"; 139 139 description = '' 140 140 A list of permissible login shells for user accounts. 141 141 No need to mention <literal>/bin/sh</literal> 142 142 here, it is placed into this list implicitly. 143 143 ''; 144 - type = types.listOf types.path; 144 + type = types.listOf (types.either types.shellPackage types.path); 145 145 }; 146 146 147 147 }; ··· 158 158 159 159 environment.etc."shells".text = 160 160 '' 161 - ${concatStringsSep "\n" cfg.shells} 161 + ${concatStringsSep "\n" (map utils.toShellPath cfg.shells)} 162 162 /bin/sh 163 163 ''; 164 164
+18 -7
nixos/modules/config/users-groups.nix
··· 1 - { config, lib, pkgs, ... }: 1 + { config, lib, utils, pkgs, ... }: 2 2 3 3 with lib; 4 4 5 5 let 6 - 7 6 ids = config.ids; 8 7 cfg = config.users; 9 8 ··· 103 102 }; 104 103 105 104 home = mkOption { 106 - type = types.str; 105 + type = types.path; 107 106 default = "/var/empty"; 108 107 description = "The user's home directory."; 109 108 }; ··· 118 117 }; 119 118 120 119 shell = mkOption { 121 - type = types.str; 122 - default = "/run/current-system/sw/bin/nologin"; 120 + type = types.either types.shellPackage types.path; 121 + default = pkgs.nologin; 122 + defaultText = "pkgs.nologin"; 123 + example = literalExample "pkgs.bashInteractive"; 123 124 description = "The path to the user's shell."; 124 125 }; 125 126 ··· 359 360 360 361 spec = pkgs.writeText "users-groups.json" (builtins.toJSON { 361 362 inherit (cfg) mutableUsers; 362 - users = mapAttrsToList (n: u: 363 + users = mapAttrsToList (_: u: 363 364 { inherit (u) 364 - name uid group description home shell createHome isSystemUser 365 + name uid group description home createHome isSystemUser 365 366 password passwordFile hashedPassword 366 367 initialPassword initialHashedPassword; 368 + shell = utils.toShellPath u.shell; 367 369 }) cfg.users; 368 370 groups = mapAttrsToList (n: g: 369 371 { inherit (g) name gid; ··· 372 374 )); 373 375 }) cfg.groups; 374 376 }); 377 + 378 + systemShells = 379 + let 380 + shells = mapAttrsToList (_: u: u.shell) cfg.users; 381 + in 382 + filter types.shellPackage.check shells; 375 383 376 384 in { 377 385 ··· 476 484 group = "nogroup"; 477 485 }; 478 486 }; 487 + 488 + # Install all the user shells 489 + environment.systemPackages = systemShells; 479 490 480 491 users.groups = { 481 492 root.gid = ids.gids.root;
+1 -1
nixos/modules/programs/bash/bash.nix
··· 200 200 # Configuration for readline in bash. 201 201 environment.etc."inputrc".source = ./inputrc; 202 202 203 - users.defaultUserShell = mkDefault "/run/current-system/sw/bin/bash"; 203 + users.defaultUserShell = mkDefault pkgs.bashInteractive; 204 204 205 205 environment.pathsToLink = optionals cfg.enableCompletion [ 206 206 "/etc/bash_completion.d"
+10 -8
nixos/modules/programs/shadow.nix
··· 1 1 # Configuration for the pwdutils suite of tools: passwd, useradd, etc. 2 2 3 - { config, lib, pkgs, ... }: 3 + { config, lib, utils, pkgs, ... }: 4 4 5 5 with lib; 6 6 ··· 43 43 users.defaultUserShell = lib.mkOption { 44 44 description = '' 45 45 This option defines the default shell assigned to user 46 - accounts. This must not be a store path, since the path is 46 + accounts. This can be either a full system path or a shell package. 47 + 48 + This must not be a store path, since the path is 47 49 used outside the store (in particular in /etc/passwd). 48 - Rather, it should be the path of a symlink that points to the 49 - actual shell in the Nix store. 50 50 ''; 51 - example = "/run/current-system/sw/bin/zsh"; 52 - type = types.path; 51 + example = literalExample "pkgs.zsh"; 52 + type = types.either types.path types.shellPackage; 53 53 }; 54 54 55 55 }; ··· 60 60 config = { 61 61 62 62 environment.systemPackages = 63 - lib.optional config.users.mutableUsers pkgs.shadow; 63 + lib.optional config.users.mutableUsers pkgs.shadow ++ 64 + lib.optional (types.shellPackage.check config.users.defaultUserShell) 65 + config.users.defaultUserShell; 64 66 65 67 environment.etc = 66 68 [ { # /etc/login.defs: global configuration for pwdutils. You ··· 74 76 '' 75 77 GROUP=100 76 78 HOME=/home 77 - SHELL=${config.users.defaultUserShell} 79 + SHELL=${utils.toShellPath config.users.defaultUserShell} 78 80 ''; 79 81 target = "default/useradd"; 80 82 }
+3
pkgs/os-specific/linux/shadow/default.nix
··· 53 53 meta = { 54 54 homepage = http://pkg-shadow.alioth.debian.org/; 55 55 description = "Suite containing authentication-related tools such as passwd and su"; 56 + passthru = { 57 + shellPath = "/bin/nologin"; 58 + }; 56 59 }; 57 60 }
+4
pkgs/shells/dash/default.nix
··· 13 13 description = "A POSIX-compliant implementation of /bin/sh that aims to be as small as possible"; 14 14 hydraPlatforms = stdenv.lib.platforms.linux; 15 15 }; 16 + 17 + passthru = { 18 + shellPath = "/bin/dash"; 19 + }; 16 20 }
+4
pkgs/shells/es/default.nix
··· 43 43 maintainers = [ maintainers.sjmackenzie ]; 44 44 platforms = platforms.all; 45 45 }; 46 + 47 + passthru = { 48 + shellPath = "/bin/es"; 49 + }; 46 50 }
+4
pkgs/shells/fish/default.nix
··· 87 87 platforms = platforms.unix; 88 88 maintainers = with maintainers; [ ocharles ]; 89 89 }; 90 + 91 + passthru = { 92 + shellPath = "/bin/fish"; 93 + }; 90 94 }
+4
pkgs/shells/mksh/default.nix
··· 43 43 maintainers = with maintainers; [ AndersonTorres nckx ]; 44 44 platforms = platforms.unix; 45 45 }; 46 + 47 + passthru = { 48 + shellPath = "/bin/mksh"; 49 + }; 46 50 }
+4
pkgs/shells/pash/default.nix
··· 22 22 platforms = platforms.all; 23 23 license = with licenses; [ bsd3 gpl3 ]; 24 24 }; 25 + 26 + passthru = { 27 + shellPath = "/bin/pash"; 28 + }; 25 29 }
+4
pkgs/shells/rush/default.nix
··· 35 35 maintainers = [ stdenv.lib.maintainers.bjg ]; 36 36 platforms = stdenv.lib.platforms.all; 37 37 }; 38 + 39 + passthru = { 40 + shellPath = "/bin/rush"; 41 + }; 38 42 }
+4
pkgs/shells/tcsh/default.nix
··· 19 19 homepage = http://www.tcsh.org/; 20 20 description = "An enhanced version of the Berkeley UNIX C shell (csh)"; 21 21 }; 22 + 23 + passthru = { 24 + shellPath = "/bin/tcsh"; 25 + }; 22 26 }
+4
pkgs/shells/xonsh/default.nix
··· 41 41 maintainers = with maintainers; [ spwhitt garbas ]; 42 42 platforms = platforms.all; 43 43 }; 44 + 45 + passthru = { 46 + shellPath = "/bin/xonsh"; 47 + }; 44 48 }
+4
pkgs/shells/zsh/default.nix
··· 80 80 maintainers = with stdenv.lib.maintainers; [ chaoflow pSub ]; 81 81 platforms = stdenv.lib.platforms.unix; 82 82 }; 83 + 84 + passthru = { 85 + shellPath = "/bin/zsh"; 86 + }; 83 87 }
+3
pkgs/top-level/all-packages.nix
··· 2250 2250 else 2251 2251 nodePackages_4_x; 2252 2252 2253 + # Can be used as a user shell 2254 + nologin = shadow; 2255 + 2253 2256 npm2nix = nodePackages.npm2nix; 2254 2257 2255 2258 ldapvi = callPackage ../tools/misc/ldapvi { };