These are my NixOS and home-manager configurations. They aim for maximum reproducibility through Flakes. This repo is composed by modules to provide plug&play configuration based on hosts and users.
I’m using the standalone approach for home-manager, but it shouldn’t be difficult to integrate all this with the NixOS module.
Be careful if you want to use this “template”, this is not a framework neither an easy-come-easy-go library. I’m a totally beginner.
Here the top-level structure of this repository. I will put a tree like this in every important folder.
.
├── flake.nix
├── flake.lock
├── shell.nix # Shell declaration for this repo
├── wallpapers
├── home # Home-manager configuration
│ ├── mario # User configuration, per host files/folders
│ └── modules # Modules :: options to build a cute home
├── lib # Utility functions
│ ├── default.nix
│ ├── home.nix # Home configurations generator
│ └── nixos.nix # System configurations generator
├── overlays # Overlays folder
├── packages # Personal packages folder
└── system # System configurations
├── hosts # System configuration, olders for each host
└── modules # Modules :: options for system related stuff
- Boot into the NixOS installer;
- Switch to root user;
- Do your manual partitioning, and mount all (if you don’t know how to do this step, go away);
- Installation process:
nix-shell -p git nixFlakes
# Set HOST for the hostname of the new system
HOST=...
# Set USER to your desired username
USER=...
git clone https://github.com/archer-65/nix-dotfiles /etc/dotfiles
cd /etc/dotfiles
# Create a new host folder
mkdir -p system/hosts/$HOST
# This step generates your hardware-configuration and a basic configuration file
nixos-generate-config --root /mnt --dir /etc/dotfiles/system/hosts/$HOST
# You can remove the `configuration.nix` file, follow the other hosts structure to create your own configuration
rm -f system/hosts/$HOST/configuration.nix
# [OPTIONAL] You can copy the other files and modify what you want (be careful!), for instance:
cp system/hosts/mate/{default.nix,options.nix} system/hosts/$HOST/
# Add a set definition in `flake.nix` for the desired host
# Flakes need staged files
git add .
# Install
nixos-install --root /mnt --flake .#$HOST
# Finally move your files where you want. Example:
mv /etc/dotfiles /mnt/home/$USER/.dotfiles
- Reboot;
- Change your password;
- Enjoy;
I’m assuming you’re referring to flake configurations in your working directory…but it doesn’t matter, you can build from github, from other folders or from another planet :).
If you want to build your home-manager configuration:
# Create your own folder with `default.nix` under `/home/configurations`
cp -R /home/$USER/mate.nix /home/$USER/${HOSTNAME}.nix
# Add a set definition in `flake.nix` for the desired host
# Build and activate!
nix build .#homeConfigurations."${USER}@${HOSTNAME}".activationPackage
./result/activate
Update your lock file!
nix flake update
To rebuild system/home:
nixos-rebuild switch --flake .#$HOSTNAME
home-manager switch --flake .#"${USER}@${HOSTNAME}"
Well, I “borrowed” many ideas and functions from other repos…learning nix is really hard, with a steep learning curve.
Thanks to: