I went through the guides but couldn’t find one that mapped 1:1 to what I’m trying to do.
I’m new to NixOS, installed it in a laptop, and already messed up as I started modifying the config directly and lost the original 1st generation config, later came to know about flakes and home manager and I think I have a general idea about how to do version control now.
If I get it right the ideal way to handle it is to extend the config with Flakes that you can organize and position somewhere else that is easier to do version control, the most common being dotfiles repo in GitHub.
Home manager may be useful specifically because the syntax looks cleaner and easier to read, but configs that are commonly saved in dotfiles are better handled outside, the reason is that you own the files rather than having a symlink to a file owned by root and need sudo access to modify them (case in point the .zshrc
we use to configure the Zsh and OhMyZsh packages).
The other reason is that dotfiles are configs for programs, there’s no reason to rebuild when the config changes, in the case of Zsh just reload (re-source maybe) the config (usually omz reload
), so ideally I would just handle all dotfiles with GitHub and GNU Stow.
The 2 issue I’m facing at this point are:
- How to set up version control for the Nix config, flakes and home manager config files (and how that ties up to a new install of NixOS, do I just clone the repo and in the first iteration tell the config to somehow load the flakes and other files?).
- How to set up OhMyZsh, I have installed (or configured) the
pkgs.zsh
andpkgs.ohMyZsh
, but since the path where the latter is installed, I don’t know where to source the latter from the.zshrc
file, I know it get’s installed in the nix store, but as this is configuration only, I want to avoid a very specific path to the OhMyZsh, it should work even If I update the versions of Zsh and OMZ.
The config looks like this:
nix.settings.experimental-features = [ "nix-command" "flakes"];
environment.systemPackages = with pkgs; [
pkgs.git
...
pkgs.oh-my-zsh
pkgs.zsh
vim
wget
];
And my .zshrc
looks like this, the important part that is not working at the moment is the source
of OMZ, I guess I would have to add a very specific case for NixOS?:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
case $(uname) in
Darwin)
export ZSH="/Users/carlos/.oh-my-zsh"
;;
Linux)
export ZSH="$HOME/.oh-my-zsh"
;;
esac
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"
...
source $ZSH/oh-my-zsh.sh