The quickest way to change your nix configuration
A small script that opens configuration.nix in your editor and offers to rebuild when you are done.
NixOS is great, but it is a bit tedious to always type out vim /etc/nixos/... etc to make changes to your system, nor do I want a complicated setup for my nix configuration files. So I devised a little script to speed up the progress, which I saved to configure.sh allowing me to configure NixOS by just opening my terminal and typing ./configure.sh
#!/run/current-system/sw/bin/bash
sudo $EDITOR /etc/nixos/configuration.nix
read -p "Want to apply the config? [y/n]" choice
if [[ "$choice" == "y" ]]; then
nixos-rebuild switch --use-remote-sudo
fi
It will open the nix configuration in the editor of your choice and after finishing your edit session, offer to apply it immediately. $EDITOR will resolve to nano by default, but you can change it easily by changing the environment variable from your nix config:
environment.variables = {
EDITOR = "hx";
};newsletter
Stay updated on new blog posts and projects by me; sent less than once per week.
written by
Hi, I’m Bruce, a Computer Science student at ETH Zurich. I build mobile apps, websites and other products, and I write about the interesting things I run into along the way. More about me →