From 540718693fc6d6c7627682e63ff4afafc7944f74 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Mon, 13 Apr 2026 13:57:31 +0100 Subject: [PATCH] fix: revert to standalone Home Manager architecture for fast UI updates --- core/system/scripts/nomarchy-update | 6 +-- features/scripts/utils/nomarchy-env-update | 8 ++-- flake.nix | 56 ++++++++++++---------- installer/install.sh | 26 ++++++---- 4 files changed, 53 insertions(+), 43 deletions(-) diff --git a/core/system/scripts/nomarchy-update b/core/system/scripts/nomarchy-update index b4bebaf..3cd406c 100755 --- a/core/system/scripts/nomarchy-update +++ b/core/system/scripts/nomarchy-update @@ -3,7 +3,7 @@ # Nomarchy Update Script # 1. Updates the flake inputs in the repository # 2. Applies system-wide NixOS changes -# 3. Applies user-level Home Manager changes +# 3. Applies user-level Home Manager changes (Standalone) set -e @@ -27,9 +27,9 @@ sudo nix flake update --flake "$REPO_DIR" echo "Applying system-level updates..." sudo nixos-rebuild switch --flake "$REPO_DIR#default" --impure -# 3. Rebuild Home Environment +# 3. Rebuild Home Environment (Standalone) echo "Applying user-level updates..." -home-manager switch --flake "$REPO_DIR#default" --impure +home-manager switch --flake "$REPO_DIR#$USER" --impure # 4. Commit changes if it's a git repo if [ -d "$REPO_DIR/.git" ]; then diff --git a/features/scripts/utils/nomarchy-env-update b/features/scripts/utils/nomarchy-env-update index e0129cb..d232ea8 100644 --- a/features/scripts/utils/nomarchy-env-update +++ b/features/scripts/utils/nomarchy-env-update @@ -2,7 +2,7 @@ # Nomarchy Environment Update Script # 1. Runs the pre-flight state migration -# 2. Applies user-level Home Manager changes +# 2. Applies user-level Home Manager changes (Standalone) set -e @@ -21,8 +21,8 @@ if command -v nomarchy-preflight-migration >/dev/null 2>&1; then nomarchy-preflight-migration fi -# Apply changes via nixos-rebuild (since home-manager is integrated as a NixOS module) -echo "Applying user-level changes from $REPO_DIR using nixos-rebuild..." -sudo nixos-rebuild switch --flake "$REPO_DIR#default" --impure +# Apply Home Manager changes from the local flake (Standalone) +echo "Applying user-level changes from $REPO_DIR#$USER..." +home-manager switch --flake "$REPO_DIR#$USER" --impure echo "Environment update complete." diff --git a/flake.nix b/flake.nix index 6b9cdf5..694ef10 100644 --- a/flake.nix +++ b/flake.nix @@ -54,38 +54,21 @@ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-base.nix" ./hosts/live-iso.nix ./core - home-manager.nixosModules.home-manager { system.stateVersion = "25.11"; - home-manager.extraSpecialArgs = { inherit inputs; }; - services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "nixos"; - - home-manager.useGlobalPkgs = false; - home-manager.useUserPackages = true; - home-manager.users.nixos = { - imports = [ ./features ]; - home.username = "nixos"; - home.homeDirectory = "/home/nixos"; - home.stateVersion = "25.11"; - }; } ]; }; - # VM for testing graphical installer - installerVm = nixpkgs.lib.nixosSystem { - # ... (rest of installerVm) - }; - + # Default configuration (VM and testing) default = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ./core/default.nix ./core/system/vm-guest.nix - home-manager.nixosModules.home-manager { system.stateVersion = "25.11"; networking.hostName = "nomarchy"; @@ -103,15 +86,36 @@ services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "nomarchy"; + } + ]; + }; + }; - home-manager.useGlobalPkgs = false; - home-manager.useUserPackages = true; - home-manager.users.nomarchy = { - imports = [ ./features/default.nix ]; - home.username = "nomarchy"; - home.homeDirectory = "/home/nomarchy"; - home.stateVersion = "25.11"; - }; + 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"; } ]; }; diff --git a/installer/install.sh b/installer/install.sh index 4743e51..1457b4e 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -413,17 +413,19 @@ generate_flake_config() { ./hardware-selection.nix nomarchy.nixosModules.system ./system.nix - home-manager.nixosModules.home-manager + ]; + }; + + homeConfigurations.@USERNAME@ = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = { inputs = nomarchy.inputs // inputs; }; + modules = [ + nomarchy.nixosModules.home + ./home.nix { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users.@USERNAME@ = { - imports = [ nomarchy.nixosModules.home ./home.nix ]; - home.username = "@USERNAME@"; - home.homeDirectory = "/home/@USERNAME@"; - home.stateVersion = "25.11"; - }; + home.username = "@USERNAME@"; + home.homeDirectory = "/home/@USERNAME@"; + home.stateVersion = "25.11"; } ]; }; @@ -451,6 +453,10 @@ EOF $impermanence_opt + environment.systemPackages = with pkgs; [ + home-manager + ]; + services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "$USERNAME";