diff --git a/core/system/vm-guest.nix b/core/system/vm-guest.nix index ac73040..e20aadf 100644 --- a/core/system/vm-guest.nix +++ b/core/system/vm-guest.nix @@ -1,6 +1,20 @@ -{ inputs, lib, ... }: +{ inputs, lib, pkgs, homeActivationPackage ? null, ... }: { + # Pre-activate standalone home-manager if provided + system.activationScripts.home-manager-activate = lib.mkIf (homeActivationPackage != null) { + text = '' + USER_HOME="/home/nomarchy" + if [ ! -d "$USER_HOME" ]; then + mkdir -p "$USER_HOME" + chown nomarchy:users "$USER_HOME" + fi + # Run activation as the nomarchy user + ${pkgs.sudo}/bin/sudo -u nomarchy ${homeActivationPackage}/activate + ''; + deps = [ "users" ]; + }; + # Shared VM configuration virtualisation.vmVariant = { virtualisation.graphics = true; diff --git a/flake.nix b/flake.nix index afc5a23..c830e47 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,26 @@ walker.url = "github:abenz1267/walker"; }; - outputs = { self, nixpkgs, nixos-hardware, disko, impermanence, home-manager, nix-colors, stylix, walker, ... } @ inputs: { + outputs = { self, nixpkgs, nixos-hardware, disko, impermanence, home-manager, nix-colors, stylix, walker, ... } @ inputs: let + # Helper to create standalone home configurations + mkHome = { username, modules ? [] }: home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = { inherit inputs; }; + modules = [ + ./features + { + home.username = username; + home.homeDirectory = "/home/${username}"; + home.stateVersion = "25.11"; + } + ] ++ modules; + }; + + homeConfigs = { + "nixos" = mkHome { username = "nixos"; }; + "nomarchy" = mkHome { username = "nomarchy"; }; + }; + in { # Expose inputs for downstream use inherit inputs; @@ -48,7 +67,10 @@ # Graphical installer ISO (legacy, for users who prefer GUI) installerIsoGraphical = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; + specialArgs = { + inherit inputs; + homeActivationPackage = homeConfigs."nixos".activationPackage; + }; modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-base.nix" @@ -64,7 +86,10 @@ # Default configuration (VM and testing) default = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; + specialArgs = { + inherit inputs; + homeActivationPackage = homeConfigs."nomarchy".activationPackage; + }; modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ./core/default.nix @@ -90,34 +115,6 @@ }; }; - homeConfigurations = { - # Standalone Home Manager configuration for Live ISO - "nixos" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - extraSpecialArgs = { inherit inputs; }; - modules = [ - ./features - { - home.username = "nixos"; - home.homeDirectory = "/home/nixos"; - home.stateVersion = "25.11"; - } - ]; - }; - - # Standalone Home Manager configuration for VM testing - "nomarchy" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - extraSpecialArgs = { inherit inputs; }; - modules = [ - ./features - { - home.username = "nomarchy"; - home.homeDirectory = "/home/nomarchy"; - home.stateVersion = "25.11"; - } - ]; - }; - }; + homeConfigurations = homeConfigs; }; } diff --git a/hosts/live-iso.nix b/hosts/live-iso.nix index bbb2593..fa2b482 100644 --- a/hosts/live-iso.nix +++ b/hosts/live-iso.nix @@ -1,6 +1,20 @@ -{ config, pkgs, inputs, lib, ... }: +{ config, pkgs, inputs, lib, homeActivationPackage, ... }: { + # Pre-activate standalone home-manager for the live environment + system.activationScripts.home-manager-activate = { + text = '' + USER_HOME="/home/nixos" + if [ ! -d "$USER_HOME" ]; then + mkdir -p "$USER_HOME" + chown nixos:users "$USER_HOME" + fi + # Run activation as the nixos user + ${pkgs.sudo}/bin/sudo -u nixos ${homeActivationPackage}/activate + ''; + deps = [ "users" ]; + }; + environment.systemPackages = with pkgs; [ git gum