👀 Multi-user installation (recommended) https://nixos.org/download.html#nix-quick-install
👀 https://nixos.wiki/wiki/Flakes#Permanent
👀 https://nix-community.github.io/home-manager/index.xhtml#sec-install-standalone
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
Check installation
nix-env --query --installed
home-manager-path
# or
home-manager --version
25.05-pre
git pull [email protected]:sectore/dotfiles.git
cd dotfiles
Symlink home-manager
, nix
and zed
folder to ~/.config
using stow based on YT vid Stow has forever changed the way I manage my dotfiles
stow . -t ~/.config
Side note: home-manager
provides programs.zed-editor
,
but it errors while creating symlinks to settings.json
etc., which Zed tries to override. That ends in errors such as
Permission denied (os error 13) at path "/nix/store/..."
# or
Failed to write settings to file "/nix/store/xxr...-zed-user-settings"
Very similar to zed-industries/zed#16618
Solution is just to add pkgs.zed-editor
to home.packages
and symlink Zed's settings files etc. located in ~/dotfiles/zed/
by using stow
.
Activate configuration of home-manager
after setup or any future changes:
home-manager switch
- Packages https://search.nixos.org/packages?channel=unstable
- Configuration Options
Home Manager can't change the default shell, so we need to do it manually:
# `which zsh`
which zsh
~/.nix-profile/bin/zsh
# add it to `/etc/shells`
sudo vi /etc/shells
# change shell to `zsh`
chsh -s ~/.nix-profile/bin/zsh
Reference:
- How to make ZSH the default shell? https://askubuntu.com/a/1054798
- Change my default shell in Linux using chsh https://www.cyberciti.biz/faq/change-my-default-shell-in-linux-using-chsh/
To access the GPU, programs need access to OpenGL and Vulkan libraries. While this works transparently on NixOS, it does not on other Linux systems. A solution is provided by NixGL, which can be integrated into Home Manager.
^ https://nix-community.github.io/home-manager/index.xhtml#sec-usage-gpu-non-nixos
Needed to run Zed
, Ghostty
, Bevy
etc.
From Bevy's docs:
If running nix on a non NixOS system (such as ubuntu, arch etc.), NixGL is additionally required, to link graphics drivers into the context of software installed by nix:
nixGL docs recommends to install nixGL
via nix-channel
# add channel
nix-channel --add https://github.com/nix-community/nixGL/archive/main.tar.gz nixgl
nix-channel --update
# install nixGL
nix-env -iA nixgl.auto.nixGLDefault
# double check
which nixGL
# install nixGLNvidia
nix-env -if https://github.com/guibou/nixGL/archive/main.tar.gz -A auto.nixGLNvidia
# double check
which nixGLNvidia-550.120
# (after setting a symlink in `zsh.nix`)
which nixGLNvidia
nix-env -e nixGL
nix-channel --remove nixgl
nix-channel --update
- NixOS Wiki: Flakes
- Home Manager: Documentation
- Zero to Flakes: Using direnv to manage dev environments
- Johannes Schickling: Setting up Nix on macOS from scratch (incl. dotfiles via home-manager and Nix flakes)
- Vimjoyer: Nix home-manager tutorial: Declare your entire home directory
- Alex Pearce: Managing dotfiles with Nix
- Red Tomato: My Nix Journey - Use Nix on Ubuntu