Skip to content

Commit

Permalink
fix(nix): let Nix manage system shells, default user
Browse files Browse the repository at this point in the history
This commit fixes the issue where settings `users.user.${user}.shell` wouldn't change default shell for the user.

This was long running issue with `nix-darwin` and it's finally resolved upstream. [LnL7/nix-darwin#811][issuse] details how this was resolved.

[issuse]: LnL7/nix-darwin#811
  • Loading branch information
atahanyorganci committed Aug 28, 2024
1 parent c558855 commit 0a1131f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nix/hosts/macbook-pro/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
inputs@{ pkgs, user, ... }:
let
# User ID created by MacOS for the user use `id -u` to get it.
uid = 501;
in
{
imports = [
../../modules/nix-darwin/homebrew.nix
../../modules/nix-darwin/shell.nix
];
# Disable `nix-darwin` documentation
documentation.enable = false;
Expand All @@ -25,11 +30,13 @@ inputs@{ pkgs, user, ... }:
system.configurationRevision = inputs.self.rev or inputs.self.dirtyRev or null;
# Ensures compatibility with defaults from NixOS
system.stateVersion = 4;
# Default user
# Users managed by Nix
users.knownUsers = [ user.username ];
users.users.${user.username} = {
name = user.username;
description = user.name;
home = "/Users/${user.username}";
shell = pkgs.${user.shell};
uid = uid;
};
}
12 changes: 12 additions & 0 deletions nix/modules/nix-darwin/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs, ... }:
let
shells = with pkgs; [
bashInteractive
zsh
fish
];
in
{
environment.shells = shells;
environment.systemPackages = shells;
}

0 comments on commit 0a1131f

Please sign in to comment.