Unable to set or use ZSH shell from standalone Home Manager (using Flakes)

Hi - I am trying to set and use ZSH shell from a standalone Home Manager installation on Arch Linux.

Using the following flake.nix:

  description = "Home Manager configuration of tim";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";

  outputs = { nixpkgs, home-manager, ... }:
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations."tim" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;

        # Specify your home configuration modules here, for example,
        # the path to your home.nix.
        modules = [ ./home.nix ];

        # Optionally use extraSpecialArgs
        # to pass through arguments to home.nix

    programs.zsh.enable = true;
    targets.genericLinux.enable = true;
    environment.shells = with pkgs; [ zsh ];
    #users.defaultUserShell = pkgs.zsh;


home.nix imports the following shell.nix:

{ config, pkgs, lib, users, ... }:


programs.zsh.enable = true;

programs.zsh = {
  shellAliases = {
    ll = "ls -l";
    update = "home-manager switch --flake ~/hmconf";
  history = {
    size = 10000;
    path = "${config.xdg.dataHome}/zsh/history";
  zplug = {
    enable = true;
    plugins = [
      { name = "zsh-users/zsh-autosuggestions"; } # Simple plugin installation

 home.username = "tim";
 home.homeDirectory = "/home/tim";


The above two flakes after running do not add ZSH to /etc/shells.

I have tried manually adding the nix ZSH path to /etc/shells and changing the shell with:

chsh tim

Is there a limitation to using standalone home manager in stopping ZSH being activated or being added to /etc/shells for use?

Many thanks in advance for your advice.

Yes, unfortunately editing /etc/shells requires root permissions, but standalone home-manager doesn’t have that. You would also need to set the shells for all other users, which isn’t really what you want home-manager to do.

In the past, I did what you are doing, just adding the zsh path to /etc/shells manually. Alternatively you could add exec zsh to your ~/.bash_profile, making sure that runs after the home-manager activation.

1 Like

Thank you TLATER!

I edited /etc/shells with the path to zsh within nix profile. I ran chsh to the zsh path in nix profiles (found with using which zsh) before ahving to reboot for the changed shell to take effect.

Yes, that will be required, though I think relogging may be enough?

Note you will need to repeat this every time the zsh location changes, which will be frequent, since any change in its dependencies will cause NixOS to create a new binary/store path.

your suggestion of exec zsh in .bash_profile works but feels a bit awkward. I’m on macOS and wondering if there’s a “better way”? Perhaps some esoteric setting? Anyway, thanks @TLATER