Set: vi: invalid option name after succesful home manager switch

Hi everyone!

I’m a Nixos beginner who wants to customize his own bash experience to work more efficiently. To do that, I’ve been adding my customization to the programs.bash.bashrcExtra attribute. I didn’t have any problems with adding a cool touch to my prompt but now I can’t run nixos-rebuild test nor nixos-rebuild switch, home manager complains with a set: vi: invalid option error after I tried to customize my cursor for bash vi mode command and insert modes.

The only thing that helps just once is to delete the ~/.bashrc link home manager creates and run the test command above mentioned. This is a manual solution that I came up out of curiosity to see if that could break anything but obviously it’s no the desired solution.

Here’s my home.nix code:

{ config, pkgs, … }:
let
dotfiles = “${config.home.homeDirectory}/waves-dotfiles/config”;
create_symlink = path: config.lib.file.mkOutOfStoreSymlink path;
configs = { };
in {
imports = [ ./modules/nvim/nvim.nix ./modules/tmux/tmux.nix ];
xdg.configFile = builtins.mapAttrs (name: subpath: {
source = create_symlink “${dotfiles}/${subpath}”;
recursive = true;
}) configs;
home.username = “wavesinaroom”;
home.homeDirectory = “/home/wavesinaroom”;
home.packages = with pkgs; [ glab xclip ];
programs.git = {
enable = true;
extraConfig = {
user.name = “myuser”;
user.email = ”mymail”;
init.defaultBranch = “main”;
};
};
home.stateVersion = “25.05”;
programs.bash = {
enable = true;
enableCompletion = true;
bashrcExtra = ‘‘
export PROMPT_COMMAND=“echo; trap ‘echo; trap - DEBUG’ DEBUG”
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export PS1='[\e[0;36m] \w[\e[0m]$(__git_ps1)-> ';

set -o vi set show-mode-in-prompt on
set vi-cmd-mode-string “\\1\\e\[2 q\\2”
set vi-ins-mode-string “\\1\\e\[6 q\\2”

‘‘ };

}

output

Dec 04 17:37:16 hplaptop systemd[1]: Starting Home Manager environment for wavesinaroom…Dec 04 17:37:16 hplaptop hm-activate-wavesinaroom[6454]: /home/wavesinaroom/.bashrc: line 6: set: vi: invalid option nameDec 04 17:37:16 hplaptop hm-activate-wavesinaroom[6454]: /nix/store/bmcq1q46phabjginjwwk6jw8z2c53iys-hm-setup-env: line 12: /vi-ins-mode-string/activate: No such file or directory

I also deleted the set vi-ins-mode-string line but I got the same error after doing that.

I couldn’t set a proper code highlighting option here on the forum. When clicking on the code button, my code indent was gone. Sorry about that

Can anyone point out what I’m missing/doing wrong here please?

set doesn’t do what you think it does. I assume you’re getting bash syntax confused with some other language. Remove all the set lines, delete your ~/.bashrc (so the activation can function), and rebuild. That should get you back to a working state. Check out bash documentation and make sure what you want to do actually makes sense (e.g. by typing it in a terminal first).

1 Like

Use triple backticks (```) on empty lines before and after your code blocks.

Your set show-mode-in-prompt on command, and the similar commands following it, should be in .inputrc, not .bashrc. (set -o vi is correct for .bashrc, though.) In Home Manager, that means putting them in programs.readline.variables, like this:

  programs.readline = {
    enable = true;
    variables = {
      show-mode-in-prompt = true;
      # etc.
    };
  };
2 Likes

Thank for taking time to check out my question. According to Arch linux wiki vi option and the other options I tried should go to input.rc like you told me in your answer.

Unfortunately this doesn’t fix the problem. It’s weird you know! For a very strange reason neither test nor switch seem to get the changes I made to home.nix. I get exactly the sme output eventhough I checked that changed the file.

This is the first time it ever happened to me with NixOS. I’ll try to find out what’s going on.

Thanks for the code formatting hint btw. I’ll try that next time.

Hi!

Thanks for taking time to read my question. What I got from the internet is that you can put your bash config inside bashrcExtra so I just did it. Also I thougth that it could work like a .sh file because this attribute gets a string. Yeah, I removed the linked .bashrc and rebuilt, everything is back to normal.