Hello,
I’m sorry in advance if questions like mine have been asked before. I’m new to Nix and the Nix language (coming from GNU/Guix) and I’ve read through the documentation I could find, most notably:
- NixOS manual
- NixOS wiki
- Home Manager manual
But I couldn’t quite find the answers I’m looking for. For my system configuration with nix (including managing the user directories) I have some prerequisites that are important to me:
- I want to pin the channels I’m using to a certain commit, and update to the latest commit manually (As I understand flakes are perfect for that, so I began setting up one)
- I want to manage my system configuration using nix (obviously) and my home configuration using home-manager
- But I don’t want to seperate the two (standalone mode?) rather, when I run
nixos-rebuild switch
, it should apply changes in both configurations at once. If I understood correctly, this can be achieved if using home manager as a nix module - And even more importantly, I don’t want to separate my home- and system configuration (meaning have one file
configuration.nix
for system and ahome.nix
for home). I’d like to be able to have one file (later down the road I’d like to split the configuration in various smaller files for different purposes [programming.nix
,games.nix
,...
]) that contains both configuration for my system- and my home environment. I like this approach because that way, I can contain afeature
into a single file. Let’s say setting up my WM. I’d involve both changes to the system and the home configuration
- But I don’t want to seperate the two (standalone mode?) rather, when I run
After researching a bit I started to look at some example configuration and took DAlperin’s nix config as a starting point. I used their flake.nix
as a template and tried building from there.
You can find my config here. Now, as far as I can tell, this is working. Taking a look at modules/common.nix
it contains both system- and home relevant configuration. I guess my question is, is this the correct way of doing it? If I take a look at the relevant parts of the home manager manual regarding this, the line
home-manager.users.jdoe = import ./home.nix;
bugs me, because this is precisely what I’m trying to avoid (having a separate config file for home). So I left it out. However, I can already see some flaw in my config. In modules/common.nix
I hardcode home-manager.users.db
. Later down the line I plan on having having different files for different users and assigning them to machines in flake.nix
, so the way I’m doing it at the moment wouldn’t work anymore. Besides that, I haven’t tried adding another file to my setup yet (let’s say modules/shell.nix
, wouldn’t another declaration of
home-manager.users.db = { pkgs, ... }: {
# ...
}
overwrite the first one?
I’m sorry for the wall of text. At the moment, my setup seems to be working. I can rebuild my system using sudo nixos-rebuild --flake .#
and both system- and home configurations get applied. However before moving forward I’d thought about taking a step back and asking for advice on whether this approach is the correct one.
Thanks in advance!