Hi all
Im experimenting on making a script to echo my personal aliases into $HOME
and /root/ .bashrc
and then execute source $HOME./bashrc
to initiate my aliases?
Or, is it possible to add a snippet into the configuration to do this?
Example:
.users.users.root = { shell = pkgs.mkShell { buildInputs = [ pkgs.bashInteractive ]; shellHook = '' echo "Setting up root shell environment" echo "alias tolga='sudo /home/tolga/scripts/MYTOOLS/scripts/GENERATION-TRIMMER/TrimmGenerations.sh'" >> $HOME/.profile ''; }; };
When i run the rebuild switch i get the following error:
sudo nixos-rebuild switch
building Nix...
building the system configuration...
error: /nix/store/87fvbizwrib5j4zp48ygv2yv9j29ksbw-nix-shell is not a shell package
(use '--show-trace' to show detailed location information)
mkShell
is a convenience helper for declaring shell environments for use with nix-shell
.
A user’s shell should be an actual shell (such as bashInteractive
).
There are probably a few ways to do what you’re trying to accomplish. If you want these in Nix itself, there’s environment.shellAliases
, but that’ll apply for all users. (Is that acceptable, or do you need to declare them only for the root user?)
I don’t really use any aliases, so I don’t have the best sense of what people do here–but I imagine someone who does will chime in.
1 Like
Thank you very much for your respone
After much tinkering and many failed attempts to get it to work, I finally got my head around it and came up with this, which works fantastically, both in fish and bash:
I’ll mark this thread SOLVED.
1 Like
hi I’m starting-off with nix too can you share how you reference your aliases .nix file in from your main nix config.
just curious
tnx
sure, no problem.
1st up, which console you going to use?
my github: My personal configs
look into core/programs/konsole/default.nix
feel free to dig around, star and fork if you wish