From 59296fbbc36a51892dbe03f5663ee92de20dd494 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Thu, 19 Jan 2023 16:28:54 +0000 Subject: [PATCH 1/2] Assert that fish configuration is enabled if any user has fish as their shell. Suggested-By: matthiasbeyer --- nixos/modules/config/users-groups.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index 76092e738eb..a727f8510f8 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -693,6 +693,16 @@ in { users.groups.${user.name} = {}; ''; } + { + assertion = (user.shell == pkgs.fish) -> (config.programs.fish.enable == true); + message = '' + users.users.${user.name}.shell is set to fish, but + programs.fish.enable is not true. This will cause the fish shell + to lack the basic nix directories in its PATH and might make + logging in as that user impossible. You can fix it with: + programs.fish.enable = true; + ''; + } ] )); From 631b7f6f882b05c2a5c35f088bfdd99ebbcbf1f3 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Thu, 19 Jan 2023 16:59:11 +0000 Subject: [PATCH 2/2] Add support for the other shells --- nixos/modules/config/users-groups.nix | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index a727f8510f8..91d6c9026d8 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -693,17 +693,20 @@ in { users.groups.${user.name} = {}; ''; } - { - assertion = (user.shell == pkgs.fish) -> (config.programs.fish.enable == true); + ] ++ (map (shell: { + assertion = (user.shell == pkgs.${shell}) -> (config.programs.${shell}.enable == true); message = '' - users.users.${user.name}.shell is set to fish, but - programs.fish.enable is not true. This will cause the fish shell - to lack the basic nix directories in its PATH and might make + users.users.${user.name}.shell is set to ${shell}, but + programs.${shell}.enable is not true. This will cause the ${shell} + shell to lack the basic nix directories in its PATH and might make logging in as that user impossible. You can fix it with: - programs.fish.enable = true; + programs.${shell}.enable = true; ''; - } - ] + }) [ + "fish" + "xonsh" + "zsh" + ]) )); warnings =