Just messing around with nu for the first time and set it as the default shell for Alacritty (I’m primarily using Terminal.app).
Unfortunately putting it as the default shell means that it isn’t inheriting PATH
, so none of my nix stuff works (it’s not sourcing /etc/bashrc
, which is where nix-darwin does its magic).
I’m sure I could do something like have my default shell be bash -lc nu
, but that seems a little unsatisfying.
Does anyone have a nu environment config that sets up nix path for darwin? TIA!
For the moment, I went with the following in my alacritty config:
programs.alacritty = {
enable = true;
settings = lib.optionalAttrs isDarwin {
shell.program = "${pkgs.unstable.zellij}/bin/zellij";
};
And this in my zellij config:
programs.zellij = {
enable = true;
settings = lib.optionalAttrs isDarwin {
default_shell = let
nuWithPath = pkgs.writeScriptBin "nu" ''
/usr/bin/env -i USER=$USER HOME=$HOME bash -c 'source /etc/bashrc; ${nushell}/bin/nu'
'';
in "${nuWithPath}/bin/nu";
copy_command = "pbcopy";
};
Startup time is still quite quick, and this allows me to run from Alacritty.app
and I have my nix path available.
Unfortunately the above approach made it so zellij was unable to maintain PWD when opening a new pane. As an alternative approach, I put the following in my home-manager config, which seems to work:
envFile.text = lib.optionalString (osConfig ? environment) ''
$env.PATH = ${builtins.replaceStrings
[
"$USER"
"$HOME"
]
[
config.home.username
config.home.homeDirectory
]
osConfig.environment.systemPath}
'';
osConfig
doesn’t exist in standalone home-manager installations, so I’m not sure how to get osConfig.environment.systemPath
in that case, but for my nix-darwin setup it seems to work and ensures that nu has access to my full nix path.
env.nu
$env.__NIX_DARWIN_SET_ENVIRONMENT_DONE = 1
$env.PATH = [
$"($env.HOME)/.nix-profile/bin"
$"/etc/profiles/per-user/($env.USER)/bin"
"/run/current-system/sw/bin"
"/nix/var/nix/profiles/default/bin"
"/usr/local/bin"
"/usr/bin"
"/usr/sbin"
"/bin"
"/sbin"
]
$env.EDITOR = "VIM"
$env.NIX_PATH = [
$"darwin-config=($env.HOME)/.nixpkgs/darwin-configuration.nix"
"/nix/var/nix/profiles/per-user/root/channels"
]
$env.NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt"
$env.PAGER = "less -R"
$env.TERMINFO_DIRS = [
$"($env.HOME)/.nix-profile/share/terminfo"
$"/etc/profiles/per-user/($env.USER)/share/terminfo"
"/run/current-system/sw/share/terminfo"
"/nix/var/nix/profiles/default/share/terminfo"
"/usr/share/terminfo"
]
$env.XDG_CONFIG_DIRS = [
$"($env.HOME)/.nix-profile/etc/xdg"
$"/etc/profiles/per-user/($env.USER)/etc/xdg"
"/run/current-system/sw/etc/xdg"
"/nix/var/nix/profiles/default/etc/xdg"
]
$env.XDG_DATA_DIRS = [
$"($env.HOME)/.nix-profile/share"
$"/etc/profiles/per-user/($env.USER)/share"
"/run/current-system/sw/share"
"/nix/var/nix/profiles/default/share"
]
$env.TERM = $env.TERM
$env.NIX_USER_PROFILE_DIR = $"/nix/var/nix/profiles/per-user/($env.USER)"
$env.NIX_PROFILES = [
"/nix/var/nix/profiles/default"
"/run/current-system/sw"
$"/etc/profiles/per-user/($env.USER)"
$"($env.HOME)/.nix-profile"
]
if ($"($env.HOME)/.nix-defexpr/channels" | path exists) {
$env.NIX_PATH = ($env.PATH | split row (char esep) | append $"($env.HOME)/.nix-defexpr/channels")
}
if (false in (ls -l `/nix/var/nix`| where type == dir | where name == "/nix/var/nix/db" | get mode | str contains "w")) {
$env.NIX_REMOTE = "daemon"
}