Skip to content

Issues setting zsh as default shell on macOS with Nix-Darwin #1226

Description

@wittjosiah

I've tried using nix-darwin's attribute to configure /etc/shells (environment.shells = [pkgs.zsh];) but it adds the wrong shell (/run/current-system/sw/bin/zsh).

From running which zsh, the correct path seem to be /etc/profiles/per-user/jdw/bin/zsh However when I add that path to /etc/shells and run chsh -s /etc/profiles/per-user/jdw/bin/zsh when I open a new terminal nix and anything installed by nix does not seem to be in the path anymore:

 π ~ ❯ nix-env
zsh: command not found: nix-env
 π ~ ❯ direnv               
zsh: command not found: direnv
 π ~ ❯ which zsh
/bin/zsh

When I leave the default shell as /bin/bash and manually start zsh everything seems to run as expected but I've been unable to successfully run it as the default. If anyone has any insight into why this might be it would be much appreciated!

My nix-darwin configuration is below:

{ config, pkgs, ... }:

{
  nix.maxJobs = 1;
  nix.buildCores = 1;

  imports = [ <home-manager/nix-darwin> ];

  home-manager.useUserPackages = true;

  home-manager.users.jdw = { pkgs, ... }: {
    home.packages = with pkgs; [
      direnv
      elixir
      iterm2
      git
      gnupg
      silver-searcher
      skhd
      vim
    ];

    programs.tmux = {
      enable = true;
      baseIndex = 1;
      clock24 = true;
      keyMode = "vi";
      secureSocket = false;
      shortcut = "a";
    };

    programs.zsh = {
      enable = true;
      enableAutosuggestions = true;
      enableCompletion = true;

      oh-my-zsh.enable = true;

      plugins = [
        {
          name = "pi-theme";
          file = "pi.zsh-theme";
          src = pkgs.fetchFromGitHub {
            owner = "tobyjamesthomas";
            repo = "pi";
            rev = "96778f903b79212ac87f706cfc345dd07ea8dc85";
            sha256 = "0zjj1pihql5cydj1fiyjlm3163s9zdc63rzypkzmidv88c2kjr1z";
          };
        }
      ];
    };
  };

  system.defaults = {
    dock = {
      autohide = true;
      orientation = "right";
    };

    finder = {
      AppleShowAllExtensions = true;
      _FXShowPosixPathInTitle = true;
      FXEnableExtensionChangeWarning = false;
    };

    NSGlobalDomain = {
     _HIHideMenuBar = true;
     "com.apple.swipescrolldirection" = false;
    };

    screencapture.location = "/tmp";

    trackpad = {
      Clicking = true;
      TrackpadThreeFingerDrag = true;
    };
  };

  system.stateVersion = 4;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions