Unable to edit my bashrc and zshrc file

Hi, Im new to nixos. Fell in love with the way its being declarative and started setting up my machine by following a youtube channel named LibrePhoenix.

After this video, which is setting up home-manager, i wanted to add alias to my rc file, but kept getting error saying “im trying to modify readonly file”.
But my rc files file permission seems 777

lrwxrwxrwx 1 User users 70 Dec 15 09:24 .bashrc -> /nix/store/1xhpnjh9zsfrcdb7bj6762rn7r76cgzl-home-manager-files/.bashrc
lrwxrwxrwx 1 User users 69 Dec 15 09:24 .zshrc -> /nix/store/1xhpnjh9zsfrcdb7bj6762rn7r76cgzl-home-manager-files/.zshrc
  1. Is this behavior due to home-manager managing my config files & how do i make changes in the rc files going further.
  2. also i have been used to make common alias in the .profile file earlier. when looking into the nixos’s .profile file, it look like this
> cat .profile 
. "/home/User/.nix-profile/etc/profile.d/hm-session-vars.sh"

So if i add common alias inside the .profile file, can it be sourced into bashrc and zshrc files.

When you are using Home-manager to manage your dotfiles, that is how it will work. It will replace your dotfiles with symlinks to a read-only version that it generates.
The reason you have these two dotfiles (bashrc and zshrc) managed is because you have set programs.bash.enable somewhere in your nix-config. You can use the programs.bash. attributes to configure everything for Bash - overview of what is available can be found here. Anything that is not available as a separate attribute can be added through programs.bash.bashrcExtra which is just a string where you can write out the configuration you would normally put into bashrc.
The same approach goes for ZSH.

You can add session variables to home.sessionVariables for anything you want in both Bash and ZSH.

3 Likes

Thanks a lot for the your reply @drzero.