Use Home Manager as a NixOS module

Replace the standalone homeConfigurations output with the Home Manager
NixOS module, so a single nixos-rebuild applies both the system and the
user configuration.

- flake.nix: import home-manager.nixosModules.home-manager, set
  home-manager.users.leo, drop the now-unused pkgs let-binding
  (allowUnfree comes from configuration.nix via useGlobalPkgs)
- home.nix: drop home.username/homeDirectory and
  programs.home-manager.enable, all provided by the module
- README.md: remove the separate install and home-manager switch steps

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FStCxmGBXQUWjgN2xMSvjU
This commit is contained in:
Leo 2026-07-28 10:53:06 +03:00
parent 369502757e
commit 7c37492c69
3 changed files with 17 additions and 22 deletions

View file

@ -6,6 +6,8 @@
4. Add flakes support by appending `nix.settings.experimental-features = ["nix-command" "flakes"];` 4. Add flakes support by appending `nix.settings.experimental-features = ["nix-command" "flakes"];`
5. Rebuild `nixos-rebuild switch` 5. Rebuild `nixos-rebuild switch`
6. Clone this repo to your destination of choice (I go with ~/.dotfiles for the time being) 6. Clone this repo to your destination of choice (I go with ~/.dotfiles for the time being)
7. Install [home-manager](https://nix-community.github.io/home-manager/) 7. Switch to the current version `nixos-rebuild switch --flake . --impure` (Impure, because we do not provide hardware configuration, since it is machine dependant)
8. Switch to the current version `nixos-rebuild switch --flake . --impure` (Impure, because we do not provide hardware configuration, since it is machine dependant)
9. Switch to the current version of home-manager `home-manager switch --flake .` Home Manager is included as a NixOS module, so `nixos-rebuild` applies both the
system and the user configuration. There is no separate `home-manager switch`
step, and no home-manager channel is needed.

View file

@ -11,22 +11,20 @@
let let
lib = nixpkgs.lib; lib = nixpkgs.lib;
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in { in {
nixosConfigurations = { nixosConfigurations = {
nixos = lib.nixosSystem { nixos = lib.nixosSystem {
inherit system; inherit system;
modules = [./configuration.nix]; modules = [
}; ./configuration.nix
}; home-manager.nixosModules.home-manager
homeConfigurations = { {
leo = home-manager.lib.homeManagerConfiguration { home-manager.useGlobalPkgs = true;
inherit pkgs; home-manager.useUserPackages = true;
modules = [ ./home.nix ]; home-manager.users.leo = import ./home.nix;
}; }
];
};
}; };
}; };
} }

View file

@ -1,10 +1,8 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Home Manager needs a bit of information about you and the paths it should # home.username and home.homeDirectory are set automatically by the
# manage. # Home Manager NixOS module, from the home-manager.users.<name> attribute.
home.username = "leo";
home.homeDirectory = "/home/leo";
# This value determines the Home Manager release that your configuration is # This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release # compatible with. This helps avoid breakage when a new Home Manager release
@ -109,7 +107,4 @@
count = "ls -1 | wc -l"; count = "ls -1 | wc -l";
}; };
}; };
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
} }