On my system bash and fish work perfectly but zsh and nuShell have issues I can't figure out how to fix

The issue with nuShell is that each time I launch it, it gives this error:

[rudra@nixos:~/nixos-config]$ nu
Error:   × I/O error: Read-only file system (os error 30)

And the issue with zsh is that it can’t find any programs I have installed:

nixos-config ❯ kubectl                                                        master
zsh: command not found: kubectl

Or even very basic UNIX utilities such as ls:

nixos-config ❯ ls  master
zsh: command not found: ls

This means I can’t use my favourite shell (nushell) or second favourite shell (zsh) on nixOS
I’m trapped on using fish (my third favourite) and bash (my fourth favourite)

Here is my complete nixos and home-manager configuration my user in home-manager is “rudra” and “rudratwo” is a backup user in case something goes wrong with “rudra”: GitHub - rudra-code-creator/nixos-flake: My nixos-flake

Please help me if you can.

As an untested guess, this sticks out as a likely culprit:

  # Set environment variables
  home.sessionVariables = {
    EDITOR = "micro";
    PATH = "$PATH:/usr/bin:$HOME/.local/bin:$HOME/rudra-app-repo/";
  };

Try removing the PATH entry here and using home.sessionPath to extend your path instead?

in addition, from a quick look at the home manager config and nu,

  • you are not using home-manager programs.x.enable for x including nushell, carapace, and some others
  • you’re dropping in some dotfiles instead
  • those dotfiles look like largely default (which is unnecessary because they’ll be the default if left unset) plus some manual integration of carapace etc.

At least for nu, and probably also for many of the others, it’s probably better to get h-m to generate those dotfiles for you, and it will include the integrations and shell hooks and so on for each thing into the config for the others.

i suspect the PATH issue above (or something else similar related to PATH) is your first problem, but the rest is a worthwhile migration to go through afterwards.

1 Like

Like this?

  # Set environment variables
  home.sessionVariables = {
    EDITOR = "micro";
    # PATH = "$PATH:/usr/bin:$HOME/.local/bin:$HOME/rudra-app-repo/";
  };

  home.sessionPath = ["$PATH:/usr/bin:$HOME/.local/bin:$HOME/rudra-app-repo/"];

No, like this:

home.sessionPath = [
  # no need for a bare $PATH item; these are all appended to any base
  # PATH you already have
  # and /usr/bin isn't a thing on NixOS (all it should ever contain is
  # `env`, as a concession to shell scripts that haven't been fixup-ed
  # by a Nix derivation)
  "$HOME/.local/bin"
  "$HOME/rudra-app-repo"
];

Unfortunately, no luck

when you start nu using this config, what does $env.PATH output?

By the way, the read-only filesystem error is because your .config/nushell/ is a symlink into the store due to the way you’re deploying the dotfiles and linking the directory, and it will be trying to create the history file there. You could link the individual files into a writeable version of this directory in your home, as a first step, or do as above.

Oh, on re-reading: is this the only issue with nu, and the path issue is something else zsh specific?

I can’t check $env.PATH output because after I launch nu it shows the read-only filesysem error and then exits back to bash immediately, so I’m not sure if the path issue is only for zsh. I will now try adding a history.txt file into dotfiles-rudra so that it can also go in .config and potentially nu can actually launch so i can run $env.PATH

How do I do that? I use ln -s ~/nixos-config/modules/users/rudra/dotfiles-rudra/nushell ~/.config/nushell right? but doesn’t that defeat the whole purpose of home-manager

Guys, I am proud to announce that the nushell error has finally changed it is now

[rudra@nixos:~/nixos-config]$ nu
Error:   × I/O error: Permission denied (os error 13)

It is now just a permissions error!

Progress is being made!

home.file.".config/nushell".recursive = true; might help with this. (Remove the history.txt you created.)

1 Like

error persists still but so do I

1 Like

when I run sudo nu It successfully launches but uses the default config I generated to /root

Is there anyway to link my config to /root using home manager?

The recursive option is creating a directory, and symlinking each file. But the directory is being created with permissions matching the source, which is probably not writable by you.

I don’t actually see an option to override the permissions (which is a little surprising, I may be missing it), so I suggest just making 2 entries, one for each of the .nu files, and having a regular directory there.

1 Like

Ok I’m doing that but should I also comment out the recursive option?

Yeah, you don’t want an entry for the nushell directory at all, just the 2 files inside.

Ok I updated it like you said:

home.file = {
    ".zshrc".source = ./dotfiles-rudra/zshrc/.zshrc;
    ".config/wezterm".source = ./dotfiles-rudra/wezterm;
    ".config/skhd".source = ./dotfiles-rudra/skhd;
    ".config/starship".source = ./dotfiles-rudra/starship;
    ".config/zellij".source = ./dotfiles-rudra/zellij;
    ".config/nvim".source = ./dotfiles-rudra/nvim;

    ".config/nushell/config.nu".source = ./dotfiles-rudra/nushell/config.nu;
    ".config/nushell/env.nu".source = ./dotfiles-rudra/nushell/env.nu;
    # ".config/nushell".recursive = true;

    # ".config/nix".source = ./dotfiles-rudra/nix;
    # ".config/nix-darwin".source = ./dotfiles-rudra/nix-darwin;
    ".config/tmux".source = ./dotfiles-rudra/tmux;
    ".config/ghostty".source = ./dotfiles-rudra/ghostty;
  };

but upon rebuild error occurs:

[rudra@nixos:~/nixos-config/modules/users]$ bash /home/rudra/nixos-config/modules/scripts/flake-build.sh
Building and updating NixOS flake configuration...
Checking for changes...
No changes detected in git.
Rebuilding NixOS configuration...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/store/rs4fjbnw4qx7ns2hzzrz2iz52va7vs5z-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/rs4fjbnw4qx7ns2hzzrz2iz52va7vs5z-source/lib/modules.nix:816:9:

          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error:
       Failed assertions:
       - rudra profile: Conflicting managed target files: .config/nushell/config.nu, .config/nushell/env.nu

       This may happen, for example, if you have a configuration similar to

           home.file = {
             conflict1 = { source = ./foo.nix; target = "baz"; };
             conflict2 = { source = ./bar.nix; target = "baz"; };
           }

[rudra@nixos:~/nixos-config/modules/users]$ 

I beleive this is because the older copies of config.nu and env.nu are still in the nix store how do I get rid of them?

Do I just run nix-collect-garbage -d?

Nah, that’s definitely not it. More likely it’s something like Home Manager generating config.nu and env.nu files itself from other settings, and those are conflicting with your hand-written files. Did you turn on programs.nushell.enable?

Yes I set programs.nushell.enable = true;