From 5d3fc65be50bbce596b07dca7fd3b90342afd813 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Sun, 7 Dec 2025 11:51:19 +0800 Subject: [PATCH] feat: set fish as user shell --- modules/cli/shell/defaultShell.nix | 34 ++++++++++++++++++++++++++++++ modules/cli/shell/zsh.nix | 8 ------- modules/user.nix | 1 - 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 modules/cli/shell/defaultShell.nix diff --git a/modules/cli/shell/defaultShell.nix b/modules/cli/shell/defaultShell.nix new file mode 100644 index 0000000..43d50e4 --- /dev/null +++ b/modules/cli/shell/defaultShell.nix @@ -0,0 +1,34 @@ +{ + lib, + config, + username, + ... +}: +let + cfg = config.my.cli.shell; +in +{ + options.my.cli.shell.default = lib.mkOption { + type = lib.types.enum [ + "fish" + "zsh" + ]; + default = "fish"; + }; + + config = lib.mkMerge [ + (lib.mkIf (cfg.default == "fish") { + my.cli.shell.fish.enable = true; + users.users.${username} = { + shell = config.my.hm.programs.fish.package; + # do not need `programs.fish.enable = true` since fish is managed by home-manager + ignoreShellProgramCheck = true; + }; + }) + + (lib.mkIf (cfg.default == "zsh") { + my.cli.shell.zsh.enable = true; + users.users.${username}.shell = config.my.hm.programs.zsh.package; + }) + ]; +} diff --git a/modules/cli/shell/zsh.nix b/modules/cli/shell/zsh.nix index 85c40c7..d59028f 100644 --- a/modules/cli/shell/zsh.nix +++ b/modules/cli/shell/zsh.nix @@ -53,14 +53,6 @@ lib.my.makeSwitch { nf = "fastfetch"; tmux = "tmux -T RGB,focus,overline,mouse,clipboard,usstyle"; }; - - # https://wiki.nixos.org/wiki/Fish#Setting_fish_as_default_shell - initContent = lib.mkBefore '' - if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" ]] - then - exec fish -l - fi - ''; }; }; }; diff --git a/modules/user.nix b/modules/user.nix index fc57f5d..d3a552e 100644 --- a/modules/user.nix +++ b/modules/user.nix @@ -25,7 +25,6 @@ lib.my.makeSwitch { users.${username} = { isNormalUser = true; description = userdesc; - shell = pkgs.zsh; extraGroups = [ username "wheel"