|
For testing, introspection and migration purposes, I would like to be able to build a home directory from an existing Most guides assume a cleanly separated project structure, where a single
In my most recent case, I was building a
For tinkering, or maybe better understanding, there is a full demo flake below. I am sorry if i missed a spelled out solution to this. Otherwise, if a hacky solution is possible, maybe update the docs with it. {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
home-manager,
}:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
username = "USER";
hostname = "HOST";
in
rec {
# Attempt 1
# Define regular nixosConfiguration and reach into it to build home selectively
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
modules = [
# home-manager module
home-manager.nixosModules.home-manager
{
home-manager.users.${username}.home = {
inherit username;
stateVersion = "24.11";
homeDirectory = "/home/${username}";
};
}
(
# regular nixos module
{ ... }:
{
nixpkgs.hostPlatform = system;
boot.isContainer = true;
users.users.${username}.isNormalUser = true;
}
)
];
};
# Attempt 2
# Wrap the HM part of the existing nixosConfiguraion into a homeConfiguration
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
nixosConfigurations.${hostname}.config.home-manager.users.${username}
];
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = [
pkgs.nixos-generators
pkgs.home-manager
];
shellHook = ''
set -x
alias ATTEMP_1="nix build .#nixosConfigurations.${hostname}.config.system.build.toplevel" # or something
alias ATTEMP_2="home-manager build --flake .#${username}"
set +x
'';
};
};
} |
Replies: 1 comment 6 replies
|
What did you run and what error did you get? |
Here is an example from my config of where I can find some buildable home-manager thing within a NixOS config: