From 169bf2bf482cbdedeabddc566f55ef54bea0182d Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 18:52:06 +1000 Subject: [PATCH 1/4] ACTUALLY use users.users..manageHome --- cerulean/nixos/home.nix | 8 +++++--- cerulean/snow/lib/nodes.nix | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cerulean/nixos/home.nix b/cerulean/nixos/home.nix index a63b6e8..0e91e8b 100644 --- a/cerulean/nixos/home.nix +++ b/cerulean/nixos/home.nix @@ -52,15 +52,17 @@ in { users = config.users.users |> attrNames - |> filter (x: pathExists (root + "/homes/${x}")) + |> filter (x: x.manageHome && pathExists /${root}/homes/${x}) |> (x: lib.genAttrs x (y: - import (root + "/homes/${y}"))); + import /${root}/homes/${y})); extraSpecialArgs = _cerulean.specialArgs; sharedModules = [ + ../home + # user configuration - (import (root + "/nixpkgs.nix")) + (import /${root}/nixpkgs.nix) # options declarations (import ./nixpkgs.nix (args // {contextName = "homes";})) ]; diff --git a/cerulean/snow/lib/nodes.nix b/cerulean/snow/lib/nodes.nix index f9b6537..48a583d 100644 --- a/cerulean/snow/lib/nodes.nix +++ b/cerulean/snow/lib/nodes.nix @@ -65,7 +65,7 @@ # flatten recursion result |> concatLists # find import location - |> map (group: nt.findImport (/${root}/groups/${group._name}) + |> map (group: nt.findImport /${root}/groups/${group._name}) # filter by uniqueness |> nt.prim.unique # ignore missing groups From 34a8c23537ddf0c0efd8793c4225dae97e913e13 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 19:29:26 +1000 Subject: [PATCH 2/4] provide per-user args (ie username) --- cerulean/nixos/home.nix | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/cerulean/nixos/home.nix b/cerulean/nixos/home.nix index 0e91e8b..0a3b983 100644 --- a/cerulean/nixos/home.nix +++ b/cerulean/nixos/home.nix @@ -12,18 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. { - root, - config, - lib, _cerulean, + config, + root, + lib, ... } @ args: let inherit (builtins) - attrNames - filter pathExists ; + + inherit + (lib) + filterAttrs + mapAttrs + ; in { imports = [ _cerulean.homeManager.nixosModules.default @@ -49,13 +53,21 @@ in { config = { home-manager = { + useUserPackages = lib.mkDefault false; + useGlobalPkgs = lib.mkDefault true; + + overwriteBackup = lib.mkDefault false; + backupFileExtension = lib.mkDefault "bak"; + users = config.users.users - |> attrNames - |> filter (x: x.manageHome && pathExists /${root}/homes/${x}) - |> (x: - lib.genAttrs x (y: - import /${root}/homes/${y})); + |> filterAttrs (name: value: value.manageHome && pathExists /${root}/homes/${name}) + |> mapAttrs (name: _: { + imports = [import /${root}/homes/${name}]; + + # per-user arguments + _module.args.username = name; + }); extraSpecialArgs = _cerulean.specialArgs; sharedModules = [ From 1c68485dcf0ba4e813a4b72a4f3d71f88137f6c2 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 19:39:57 +1000 Subject: [PATCH 3/4] cerulean now manages trivial home-manager options --- cerulean/home/default.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cerulean/home/default.nix diff --git a/cerulean/home/default.nix b/cerulean/home/default.nix new file mode 100644 index 0000000..8ae23c6 --- /dev/null +++ b/cerulean/home/default.nix @@ -0,0 +1,20 @@ +# NOTE: you can access the system configuration via the `osConfig` arg +{ + username, + lib, + ... +}: { + # WARNING: required for home-manager to work + programs.home-manager.enable = true; # user must apply lib.mkForce + # Nicely reload systemd units when changing configs + systemd.user.startServices = lib.mkDefault "sd-switch"; + + home = { + username = lib.mkDefault username; + homeDirectory = lib.mkDefault "/home/${username}"; + + sessionVariables = { + NIX_SHELL_PRESERVE_PROMPT = lib.mkDefault 1; + }; + }; +} From 39ec2e62d07d2173373db7b59be24851f7104bb9 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 20:10:36 +1000 Subject: [PATCH 4/4] fix nixpkgs disabled when home-manager.useGlobalPkgs --- cerulean/nixos/home.nix | 5 ++--- cerulean/nixos/nixpkgs.nix | 18 +++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cerulean/nixos/home.nix b/cerulean/nixos/home.nix index 0a3b983..82117d8 100644 --- a/cerulean/nixos/home.nix +++ b/cerulean/nixos/home.nix @@ -62,8 +62,8 @@ in { users = config.users.users |> filterAttrs (name: value: value.manageHome && pathExists /${root}/homes/${name}) - |> mapAttrs (name: _: { - imports = [import /${root}/homes/${name}]; + |> mapAttrs (name: _: {...}: { + imports = [/${root}/homes/${name}]; # per-user arguments _module.args.username = name; @@ -73,7 +73,6 @@ in { sharedModules = [ ../home - # user configuration (import /${root}/nixpkgs.nix) # options declarations (import ./nixpkgs.nix (args // {contextName = "homes";})) diff --git a/cerulean/nixos/nixpkgs.nix b/cerulean/nixos/nixpkgs.nix index 40a3d57..946748b 100644 --- a/cerulean/nixos/nixpkgs.nix +++ b/cerulean/nixos/nixpkgs.nix @@ -73,19 +73,23 @@ in { _module.args = removeAttrs repos ["pkgs" "base"]; nixpkgs = let - nixpkgConfig = { + nixpkgsConfig = { config = lib.mkForce (basePkgs.config or {}); overlays = lib.mkForce (basePkgs.overlays or []); }; - in - if contextName == "hosts" - then - nixpkgConfig + + nixpkgsHostsConfig = + nixpkgsConfig // { flake.source = lib.mkForce base; - } + }; + + nixpkgsHomesConfig = lib.mkIf (!config.home-manager.useGlobalPkgs) nixpkgsConfig; + in + if contextName == "hosts" + then nixpkgsHostsConfig else if contextName == "homes" - then nixpkgConfig + then nixpkgsHomesConfig else {}; }; }