Clone the repository into your local .config
directory.
git clone https://github.com/arunoruto/flake ~/.config/flake
If it deviates from this, set the env-variable FLAKE
to the new path.
When first time trying to install the flake, you need to run:
sudo nixos-rebuild switch --flake ./#<device-name>
Like NixOS, home-manager can be also updated from the flake file like follows:
home-manager switch --flake ./#<username>
The flake specifications are surrounded by quotes, since some shells (e.g. zsh) are complaining due to the # symbol.
If nix is used as a package manager on a system, home manager can be installed using nix run
:
nix run nixpkgs#home-manager -- switch --flake .#<username>
After the initial setup, the system can be configured using the nh
command.
It is important to provide the FLAKE
variable in the system, and it needs to point to the flake's repository.
This can be specified per system in its configuration.nix
under environment.sessionVariables
.
If not, it can be appended to the commands.
nh os switch # if the FLAKE variable is set, or
nh os switch ./#<device-name>
nh home switch # if the FLAKE variable is set, or
nh home switch ./#<username>
Generate a facter.json
file for a system and place it in the correct host path:
sudo nix run \
--option experimental-features "nix-command flakes" \
--option extra-substituters https://numtide.cachix.org \
--option extra-trusted-public-keys numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE= \
github:numtide/nixos-facter -- -o facter.json
Nixvim is the nix way to configure neovim. More information can be found in the nvim README.
When using a git fetcher, you need the commit hash/revision/tag/version and the corresponding hash.
You can either fetch everything with an empty hash, let the build error out and copy the hash from the logs,
or use nix-prefetch-git
:
nix run nixpkgs#nix-prefetch-git <URL>
To prefetch candy-icons, you would call:
nix run nixpkgs#nix-prefetch-git https://github.com/EliverLara/candy-icons
If edits are made to the workflow(s), a token with the workflow
scope is needed:
gh auth status # Check current scopes in token
gh auth login --scopes workflow # Request a new one with the workflow scope
Some nice intro is provided by thiscute.world.
vimjoyer has some amazing videos about nix and other nix related stuff:
- Nix explained from the ground up is a really nice introduction to Nix
- NixOS: Everything Everywhere All At Once NixOS from a beginner's perspective, kinda
- Ultimate NixOS Guide | Flakes | Home-manager gives a good introduction for beginners, and introduces flakes and how to use them to configure the system
- Modularize NixOS and Home Manager | Great Practices shows how to organize the files and make them easier to manage
- Nixvim: Neovim Distro Powered By Nix: configure neovim the nix way!
- Is NixOS The Best Gaming Distro | Linux Gaming Setup: nix can be used for gaming too! This video gives nice tips to configure your system for a specific hardware too
Ampersand has a nice video about configuring a NixOS system
similar to vimjoyer's Ultimate NixOS Guide | Flakes | Home-Manager
It can get a bit messy with the generations, especially if nix is installed as a package manager. To clean up such systems, you can use the following commands:
nix-collect-garbage
: can be used on all systems and the parameter--delete-older-than
can be specified with a period (for example"30 days"
). This command is mostly an alias ofnix-store --gc
ornix store gc
, but extends it with the--delete-older-than
and--delete-old
flag.nh clean all
: clean everything using thenh
tool.
- Integrate disko for each system, so it can be built easier later on.
- use-the-fork helped me to move from a standalone config for home-manager to using it as a module
- u/paulgdp gave advice on how
nixosConfig
is an attribute ofargs
if the config is used in NixOS, used inmodules/home-manager/imports.nix
olmokramer
gave an example on how to uselib.genAttrs
in a forum post to configure NixOS systems → extended it for home-manager too