From d5211287bd3cb96078f2053488d67d557848a8f2 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 18 Feb 2026 20:13:43 +1000 Subject: [PATCH 01/20] TEMP: use base --- cerulean/nixos/nixpkgs.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cerulean/nixos/nixpkgs.nix b/cerulean/nixos/nixpkgs.nix index 5475e0b..0376f47 100644 --- a/cerulean/nixos/nixpkgs.nix +++ b/cerulean/nixos/nixpkgs.nix @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. { + base, lib, system, config, @@ -78,13 +79,11 @@ in { nixpkgs = if contextName == "hosts" - then - # DEBUG: defaultPkgs - { - flake.source = lib.mkOverride 200 (defaultPkgs.source or null); - overlays = lib.mkOverride 200 (defaultPkgs.overlays or {}); - config = lib.mkOverride 200 (defaultPkgs.config or {}); - } + then { + flake.source = lib.mkOverride 200 base; # DEBUG: temp while getting base to work + overlays = lib.mkOverride 200 (defaultPkgs.overlays or {}); + config = lib.mkOverride 200 (defaultPkgs.config or {}); + } else if contextName == "homes" then { config = lib.mkOverride 200 (defaultPkgs.config or {}); From 087f679e67005b4c8fda93f139eb05c78c644130 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 18 Feb 2026 23:56:05 +1000 Subject: [PATCH 02/20] add modifiable homeManager --- cerulean/nexus/nexus.nix | 10 ++++- cerulean/nexus/nodes.nix | 2 + cerulean/nixos/default.nix | 20 ++++++---- flake.lock | 81 +++++++++++++++++++++----------------- flake.nix | 5 --- 5 files changed, 66 insertions(+), 52 deletions(-) diff --git a/cerulean/nexus/nexus.nix b/cerulean/nexus/nexus.nix index ea8997e..5d0ca02 100644 --- a/cerulean/nexus/nexus.nix +++ b/cerulean/nexus/nexus.nix @@ -54,6 +54,7 @@ base = null; modules = []; args = Terminal {}; + homeManager = null; groups = Terminal {}; nodes = Terminal {}; @@ -192,12 +193,17 @@ in { ... }: let nixosDecl = let + homeManager = + if node.homeManager != null + then node.homeManager + else nexus.homeManager; + userArgs = nexus.args // node.args; ceruleanArgs = { inherit root base; inherit (node) system; _cerulean = { - inherit inputs userArgs ceruleanArgs; + inherit inputs userArgs ceruleanArgs homeManager; specialArgs = userArgs // ceruleanArgs; }; }; @@ -219,9 +225,9 @@ in { self.nixosModules.default (findImport (root + "/hosts/${nodeName}")) - inputs.home-manager.nixosModules.default # inputs.microvm.nixosModules.microvm ] + ++ (homeManager.nixosModules.default or []) ++ (getGroupModules root nodeName node) ++ node.modules ++ nexus.modules; diff --git a/cerulean/nexus/nodes.nix b/cerulean/nexus/nodes.nix index 25b4bb3..13ced2f 100644 --- a/cerulean/nexus/nodes.nix +++ b/cerulean/nexus/nodes.nix @@ -38,6 +38,8 @@ in rec { modules = []; args = Terminal {}; + homeManager = null; + base = null; deploy = { diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index bd8d03d..ea7c359 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -17,14 +17,18 @@ _cerulean, ... } @ args: { - imports = [ - # user configuration - (import (root + "/nixpkgs.nix")) - # options declarations - (import ./nixpkgs.nix (args // {contextName = "hosts";})) - - ./home-manager.nix - ]; + imports = + [ + # user configuration + (import (root + "/nixpkgs.nix")) + # options declarations + (import ./nixpkgs.nix (args // {contextName = "hosts";})) + ] + ++ ( + if _cerulean.homeManager != null + then [./home-manager.nix] + else [] + ); environment.systemPackages = with _cerulean.inputs; [ deploy-rs.packages.${system}.default diff --git a/flake.lock b/flake.lock index 0dd06b1..fc8e402 100644 --- a/flake.lock +++ b/flake.lock @@ -3,7 +3,9 @@ "deploy-rs": { "inputs": { "flake-compat": "flake-compat", - "nixpkgs": "nixpkgs", + "nixpkgs": [ + "nixpkgs" + ], "utils": "utils" }, "locked": { @@ -58,6 +60,27 @@ "type": "github" } }, + "microvm": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "spectrum": "spectrum" + }, + "locked": { + "lastModified": 1771365290, + "narHash": "sha256-1XJOslVyF7yzf6yd/yl1VjGLywsbtwmQh3X1LuJcLI4=", + "owner": "microvm-nix", + "repo": "microvm.nix", + "rev": "789c90b164b55b4379e7a94af8b9c01489024c18", + "type": "github" + }, + "original": { + "owner": "microvm-nix", + "repo": "microvm.nix", + "type": "github" + } + }, "nix-github-actions": { "inputs": { "nixpkgs": [ @@ -105,38 +128,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1743014863, - "narHash": "sha256-jAIUqsiN2r3hCuHji80U7NNEafpIMBXiwKlSrjWMlpg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "bd3bac8bfb542dbde7ffffb6987a1a1f9d41699f", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1768305791, - "narHash": "sha256-AIdl6WAn9aymeaH/NvBj0H9qM+XuAuYbGMZaP0zcXAQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1412caf7bf9e660f2f962917c14b1ea1c3bc695e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1768323494, "narHash": "sha256-yBXJLE6WCtrGo7LKiB6NOt6nisBEEkguC/lq/rP3zRQ=", @@ -152,7 +143,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_2": { "locked": { "lastModified": 1767313136, "narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=", @@ -171,7 +162,7 @@ "nt": { "inputs": { "nix-unit": "nix-unit", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "systems": "systems_2" }, "locked": { @@ -191,12 +182,28 @@ "root": { "inputs": { "deploy-rs": "deploy-rs", - "nixpkgs": "nixpkgs_2", - "nixpkgs-unstable": "nixpkgs-unstable", + "microvm": "microvm", + "nixpkgs": "nixpkgs", "nt": "nt", "systems": "systems_3" } }, + "spectrum": { + "flake": false, + "locked": { + "lastModified": 1759482047, + "narHash": "sha256-H1wiXRQHxxPyMMlP39ce3ROKCwI5/tUn36P8x6dFiiQ=", + "ref": "refs/heads/main", + "rev": "c5d5786d3dc938af0b279c542d1e43bce381b4b9", + "revCount": 996, + "type": "git", + "url": "https://spectrum-os.org/git/spectrum" + }, + "original": { + "type": "git", + "url": "https://spectrum-os.org/git/spectrum" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 89ce6b4..c1a5498 100644 --- a/flake.nix +++ b/flake.nix @@ -23,11 +23,6 @@ nt.url = "github:cry128/nt"; - home-manager = { - url = "github:nix-community/home-manager/release-25.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; From 930eafa8189ec040269c9f36a52baa8622ecc65e Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 11:09:00 +1000 Subject: [PATCH 03/20] ignore target --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3828286..6cdd71c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /hidden +target/ From d9432d87a460c4f6dfb2602bba7e98267c2a0132 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 11:17:27 +1000 Subject: [PATCH 04/20] v0.2.4-alpha --- cerulean/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cerulean/default.nix b/cerulean/default.nix index 47fcdfd..502db05 100644 --- a/cerulean/default.nix +++ b/cerulean/default.nix @@ -21,7 +21,7 @@ mix.newMixture args (mixture: { ./snow ]; - version = "0.2.3"; + version = "0.2.4-alpha"; # WARNING: legacy mkFlake = mixture.snow.flake; From ef5bc338566670380ceec75eb692697c9e81fb7e Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 11:57:49 +1000 Subject: [PATCH 05/20] enable hm --- TODO.md | 3 +++ cerulean/nixos/home-manager.nix | 2 ++ cerulean/nixos/home.nix | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 cerulean/nixos/home.nix diff --git a/TODO.md b/TODO.md index 2f4edac..beb6a6c 100755 --- a/TODO.md +++ b/TODO.md @@ -3,10 +3,13 @@ - [ ] add `options.experimental` for snowflake - [ ] add `legacyImports` support +- [ ] support hs system per dir, ie hosts//overlays or hosts//nixpkgs.nix + ## Queued - [X] base should automatically be set as the default (dont do anything with the default) - [X] try to remove common foot guns, ie abort if the user provides the home-manager or microvm nixosModules since cerulean ALREADY provides these +- [ ] per node home configuration is a lil jank rn - [ ] deploy port should default to the first port given to `services.openssh` diff --git a/cerulean/nixos/home-manager.nix b/cerulean/nixos/home-manager.nix index 8c1aa8b..0927bbf 100644 --- a/cerulean/nixos/home-manager.nix +++ b/cerulean/nixos/home-manager.nix @@ -44,6 +44,8 @@ in { (import (root + "/nixpkgs.nix")) # options declarations (import ./nixpkgs.nix (args // {contextName = "homes";})) + + ./home.nix ]; }; } diff --git a/cerulean/nixos/home.nix b/cerulean/nixos/home.nix new file mode 100644 index 0000000..417e2b7 --- /dev/null +++ b/cerulean/nixos/home.nix @@ -0,0 +1,3 @@ +{...}: { + programs.home-manager.enable = true; # DEBUG: why didn't i enable it already? +} From ba7763801f3bd95b4edeba12fbb8b5c670284aa7 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 16:48:35 +1000 Subject: [PATCH 06/20] use better path notation --- cerulean/nixos/default.nix | 2 +- cerulean/nixos/home-manager.nix | 6 +++--- cerulean/snow/default.nix | 2 +- cerulean/snow/lib/nodes.nix | 2 +- cerulean/snow/module.nix | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 8d96f08..edc85cd 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -24,7 +24,7 @@ # ./legacy-imports.nix # user configuration - (import (root + "/nixpkgs.nix")) + (import /${root}/nixpkgs.nix) # options declarations (import ./nixpkgs.nix (args // {contextName = "hosts";})) diff --git a/cerulean/nixos/home-manager.nix b/cerulean/nixos/home-manager.nix index 0927bbf..d4d8748 100644 --- a/cerulean/nixos/home-manager.nix +++ b/cerulean/nixos/home-manager.nix @@ -33,15 +33,15 @@ in { users = config.users.users |> attrNames - |> filter (x: pathExists (root + "/homes/${x}")) + |> filter (x: pathExists /${root}/homes/${x}) |> (x: lib.genAttrs x (y: - import (root + "/homes/${y}"))); + import /${root}/homes/${y})); extraSpecialArgs = _cerulean.specialArgs; sharedModules = [ # user configuration - (import (root + "/nixpkgs.nix")) + (import /${root}/nixpkgs.nix) # options declarations (import ./nixpkgs.nix (args // {contextName = "homes";})) diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index 048572b..bad3c1b 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -111,7 +111,7 @@ in modules = [ self.nixosModules.default - (findImport (root + "/hosts/${name}")) + (findImport /${root}/hosts/${name}) ] ++ (groupModules root) ++ node.modules diff --git a/cerulean/snow/lib/nodes.nix b/cerulean/snow/lib/nodes.nix index 7f1a21b..f9b6537 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 diff --git a/cerulean/snow/module.nix b/cerulean/snow/module.nix index d45b35a..79b8804 100644 --- a/cerulean/snow/module.nix +++ b/cerulean/snow/module.nix @@ -18,6 +18,6 @@ }: { imports = [ ./nodes - (snow.findImport (root + "/snow")) + (snow.findImport /${root}/snow) ]; } From f985e7ee7049197ca5dc35bcaac900fede642e1c Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 17:54:10 +1000 Subject: [PATCH 07/20] rename channels.default -> channels.base --- cerulean/nixos/nixpkgs.nix | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/cerulean/nixos/nixpkgs.nix b/cerulean/nixos/nixpkgs.nix index 03925c8..40a3d57 100644 --- a/cerulean/nixos/nixpkgs.nix +++ b/cerulean/nixos/nixpkgs.nix @@ -31,7 +31,7 @@ in { default = {}; description = "Declare package repositories"; example = { - "pkgs" = { + "npkgs" = { source = "inputs.nixpkgs"; system = "x86-64-linux"; config = { @@ -53,7 +53,7 @@ in { config = let repos = cfg - |> (xs: removeAttrs xs ["default"]) + |> (xs: removeAttrs xs ["base"]) |> mapAttrs ( name: args: lib.mkForce ( @@ -65,30 +65,27 @@ in { ) ); - # XXX: TODO: would it work to use `base` instead of having default? - defaultPkgs = - cfg.default or (throw '' - Your `nixpkgs.nix` file does not declare a default package source. - Ensure you set `nixpkgs.channels.*.default = ...;` - ''); + basePkgs = cfg.base or {}; in { # NOTE: _module.args is a special option that allows us to # NOTE: set extend specialArgs from inside the modules. # WARNING: pkgs is a reserved specialArg - _module.args = removeAttrs repos ["pkgs" "default"]; + _module.args = removeAttrs repos ["pkgs" "base"]; - nixpkgs = + nixpkgs = let + nixpkgConfig = { + config = lib.mkForce (basePkgs.config or {}); + overlays = lib.mkForce (basePkgs.overlays or []); + }; + in if contextName == "hosts" - then { - flake.source = lib.mkForce base; # DEBUG: temp while getting base to work - overlays = lib.mkForce (defaultPkgs.overlays or {}); - config = lib.mkForce (defaultPkgs.config or {}); - } + then + nixpkgConfig + // { + flake.source = lib.mkForce base; + } else if contextName == "homes" - then { - config = lib.mkForce (defaultPkgs.config or {}); - overlays = lib.mkForce (defaultPkgs.overlays or []); - } + then nixpkgConfig else {}; }; } From c49fdc9769b8f919206d93746a4e59c036daf9f4 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 18:18:10 +1000 Subject: [PATCH 08/20] rename home-manager.nix -> home.nix add options.users.users..manageHome --- cerulean/nixos/default.nix | 2 +- cerulean/nixos/home-manager.nix | 51 ------------------------ cerulean/nixos/home.nix | 70 ++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 54 deletions(-) delete mode 100644 cerulean/nixos/home-manager.nix diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index edc85cd..664a10c 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -33,7 +33,7 @@ ] ++ ( if _cerulean.homeManager != null - then [./home-manager.nix] + then [./home.nix] else [] ); diff --git a/cerulean/nixos/home-manager.nix b/cerulean/nixos/home-manager.nix deleted file mode 100644 index d4d8748..0000000 --- a/cerulean/nixos/home-manager.nix +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2025-2026 _cry64 (Emile Clark-Boman) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -{ - root, - config, - lib, - _cerulean, - ... -} @ args: let - inherit - (builtins) - attrNames - filter - pathExists - ; -in { - imports = [ - _cerulean.homeManager.nixosModules.default - ]; - - home-manager = { - users = - config.users.users - |> attrNames - |> filter (x: pathExists /${root}/homes/${x}) - |> (x: - lib.genAttrs x (y: - import /${root}/homes/${y})); - - extraSpecialArgs = _cerulean.specialArgs; - sharedModules = [ - # user configuration - (import /${root}/nixpkgs.nix) - # options declarations - (import ./nixpkgs.nix (args // {contextName = "homes";})) - - ./home.nix - ]; - }; -} diff --git a/cerulean/nixos/home.nix b/cerulean/nixos/home.nix index 417e2b7..a63b6e8 100644 --- a/cerulean/nixos/home.nix +++ b/cerulean/nixos/home.nix @@ -1,3 +1,69 @@ -{...}: { - programs.home-manager.enable = true; # DEBUG: why didn't i enable it already? +# Copyright 2025-2026 _cry64 (Emile Clark-Boman) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +{ + root, + config, + lib, + _cerulean, + ... +} @ args: let + inherit + (builtins) + attrNames + filter + pathExists + ; +in { + imports = [ + _cerulean.homeManager.nixosModules.default + ]; + + options = { + users.users = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options.manageHome = lib.mkOption { + type = lib.types.bool; + default = true; + example = false; + description = '' + Whether Cerulean should automatically enable home-manager for this user, + and manage their home configuration declaratively. + + Enabled by default, but can be disabled if necessary. + ''; + }; + }); + }; + }; + + config = { + home-manager = { + users = + config.users.users + |> attrNames + |> filter (x: pathExists (root + "/homes/${x}")) + |> (x: + lib.genAttrs x (y: + import (root + "/homes/${y}"))); + + extraSpecialArgs = _cerulean.specialArgs; + sharedModules = [ + # user configuration + (import (root + "/nixpkgs.nix")) + # options declarations + (import ./nixpkgs.nix (args // {contextName = "homes";})) + ]; + }; + }; } From 23449396f7e9a9ffc07ed1f72691bc33997bb88d Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 18:18:17 +1000 Subject: [PATCH 09/20] clean TODO --- TODO.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/TODO.md b/TODO.md index beb6a6c..a9f40e1 100755 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,4 @@ ## Next -- [ ] use the Nix module system instead of projectOnto for `cerulean.mkNexus` - [ ] add `options.experimental` for snowflake - [ ] add `legacyImports` support @@ -26,29 +25,19 @@ - [ ] go through all flake inputs (recursively) and ENSURE we remove all duplicates by using follows!! -- [X] rename nixos-modules/ to nixos/ -- [X] ensure all machines are in groups.all by default - -- [X] fix nixpkgs.nix not working (default not respected) -- [X] remove dependence on nixpkgs - - [ ] allow multiple privesc methods, the standard is pam_ssh_agent_auth ## Low Priority -- [X] rename extraModules to modules? -- [X] rename specialArgs to args? - - [ ] make an extension to the nix module system (different to mix) that allows transformations (ie a stop post config, ie outputs, which it then returns instead of config) +- [ ] support `legacyImports` (?) - [ ] patch microvm so that acpi=off https://github.com/microvm-nix/microvm.nix/commit/b59a26962bb324cc0a134756a323f3e164409b72 cause otherwise 2GB causes a failure -- [ ] rewrite the ceru cli in rust -- [ ] make `ceru` do local and remote deployments +- [ ] write the cerulean cli -- [ ] support `legacyImports` ```nix # REF: foxora From 169bf2bf482cbdedeabddc566f55ef54bea0182d Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 18:52:06 +1000 Subject: [PATCH 10/20] 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 11/20] 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 12/20] 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 13/20] 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 {}; }; } From aec16966ae8b5be33c3739ab1c58921eaeb9e29f Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 20:21:26 +1000 Subject: [PATCH 14/20] add missing license --- cerulean/home/default.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cerulean/home/default.nix b/cerulean/home/default.nix index 8ae23c6..e854221 100644 --- a/cerulean/home/default.nix +++ b/cerulean/home/default.nix @@ -1,9 +1,23 @@ -# NOTE: you can access the system configuration via the `osConfig` arg +# Copyright 2025-2026 _cry64 (Emile Clark-Boman) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. { username, lib, ... }: { + # NOTE: you can access the system configuration via the `osConfig` arg + # WARNING: required for home-manager to work programs.home-manager.enable = true; # user must apply lib.mkForce # Nicely reload systemd units when changing configs From b486ee8cb765f967fc0067356a13d453e7ab768b Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 23:46:02 +1000 Subject: [PATCH 15/20] propagate node config and hostname to nixos modules --- TODO.md | 3 --- cerulean/snow/default.nix | 11 +++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index a9f40e1..5fff9a2 100755 --- a/TODO.md +++ b/TODO.md @@ -5,9 +5,6 @@ - [ ] support hs system per dir, ie hosts//overlays or hosts//nixpkgs.nix ## Queued -- [X] base should automatically be set as the default (dont do anything with the default) -- [X] try to remove common foot guns, ie abort if the user provides the home-manager or microvm nixosModules - since cerulean ALREADY provides these - [ ] per node home configuration is a lil jank rn - [ ] deploy port should default to the first port given to `services.openssh` diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index bad3c1b..c1199a6 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -86,9 +86,10 @@ in userArgs = nodes.args // node.args; ceruleanArgs = { - inherit systems root base; + inherit systems root base node; inherit (node) system; inherit (this) snow; + hostname = name; _cerulean = { inherit inputs userArgs ceruleanArgs homeManager; @@ -128,7 +129,6 @@ in (node.deploy) ssh user - sudoCmd interactiveSudo remoteBuild rollback @@ -140,14 +140,17 @@ in nixosFor = system: inputs.deploy-rs.lib.${system}.activate.nixos; in { - hostname = ssh.host; + hostname = + if ssh.host != null + then ssh.host + else ""; profilesOrder = ["default"]; # profiles priority profiles.default = { path = nixosFor node.system nixosConfigurations.${name}; user = user; - sudo = sudoCmd; + sudo = "sudo -u"; interactiveSudo = interactiveSudo; fastConnection = false; From 6b579dff1e78038c7c62851854e0d95ba38c172f Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 23:46:51 +1000 Subject: [PATCH 16/20] set hostname by default --- cerulean/nixos/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 664a10c..09975e5 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -37,6 +37,8 @@ else [] ); + networking.hostName = lib.mkDefault hostname; + environment.systemPackages = (with pkgs; [ sops From 630389a5989c15d92d883d62862850316322f8fa Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sat, 7 Mar 2026 23:48:38 +1000 Subject: [PATCH 17/20] migrate to cerubld user --- cerulean/nixos/default.nix | 27 +++++---- cerulean/nixos/remote-deploy/default.nix | 72 ++++++++++++++++++++++++ cerulean/snow/nodes/submodule.nix | 39 +++++++++---- 3 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 cerulean/nixos/remote-deploy/default.nix diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 09975e5..a716c2f 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -13,29 +13,32 @@ # limitations under the License. { root, - pkgs, system, + hostname, + node, + pkgs, + lib, _cerulean, ... } @ args: { - imports = with _cerulean.inputs; + imports = [ + _cerulean.inputs.sops-nix.nixosModules.sops + # _cerulean.inputs.microvm.nixosModules.microvm + # add support for `options.legacyImports` # ./legacy-imports.nix - # user configuration - (import /${root}/nixpkgs.nix) - # options declarations + # nixos options declarations (import ./nixpkgs.nix (args // {contextName = "hosts";})) - sops-nix.nixosModules.sops - # microvm.nixosModules.microvm + # user's nixpkg configuration + (import /${root}/nixpkgs.nix) ] - ++ ( - if _cerulean.homeManager != null - then [./home.nix] - else [] - ); + # homemanager options declarations + ++ (lib.optional (_cerulean.homeManager != null) ./home.nix) + # remote deployment configuration + ++ (lib.optional (node.deploy.ssh.host != null) ./remote-deploy); networking.hostName = lib.mkDefault hostname; diff --git a/cerulean/nixos/remote-deploy/default.nix b/cerulean/nixos/remote-deploy/default.nix new file mode 100644 index 0000000..f2f4a90 --- /dev/null +++ b/cerulean/nixos/remote-deploy/default.nix @@ -0,0 +1,72 @@ +{ + config, + node, + lib, + pkgs, + hostname, + ... +}: let + user = node.deploy.ssh.user; + cfg = config.users.users.${user}; + + DEFAULT_USER = "cerubld"; + + isStandardDeployUser = user == DEFAULT_USER; +in { + assertions = [ + { + assertion = builtins.length node.deploy.ssh.publicKeys != 0; + message = '' + The Cerulean deployment user `${user}` for node `${hostname}` must have at least + one publicKey authorized for ssh deployment! Try setting `nodes.nodes..deploy.ssh.publicKeys = [ ... ]` <3 + ''; + } + { + assertion = cfg.isSystemUser && !cfg.isNormalUser; + message = '' + The Cerulean deployment user `${user}` for node `${hostname}` has been configured incorrectly. + Ensure `users.users.${user}.isSystemUser == true` and `users.users.${user}.isNormalUser == false`. + ''; + } + ]; + + warnings = lib.optional (node.deploy.warnNonstandardDeployUser && !isStandardDeployUser) '' + The Cerulean deplyment user `${user}` for node `${hostname}` has been overriden. + It is recommended to leave this user as `${DEFAULT_USER}` unless you TRULY understand what you are doing! + This message can be disabled by setting `.deploy.warnNonstandardBuildUser = false`. + ''; + + # prefer sudo-rs over sudo + security.sudo-rs = { + enable = true; + wheelNeedsPassword = true; + + # allow the build user to run nix commands + extraRules = [ + { + users = [user]; + runAs = "${node.deploy.user}:ALL"; + commands = [ + "${pkgs.nix}/bin/nix" + ]; + } + ]; + }; + + # ensure deployment user has SSH permissions + services.openssh.settings.AllowUsers = [user]; + + users = lib.mkIf isStandardDeployUser { + groups.${user} = {}; + + users.${user} = { + enable = true; + isSystemUser = true; + group = user; + description = "Cerulean's user for building and remote deployment."; + + shell = pkgs.bash; + openssh.authorizedKeys.keys = node.deploy.ssh.publicKeys; + }; + }; +} diff --git a/cerulean/snow/nodes/submodule.nix b/cerulean/snow/nodes/submodule.nix index ea30c4f..6b4ae05 100644 --- a/cerulean/snow/nodes/submodule.nix +++ b/cerulean/snow/nodes/submodule.nix @@ -59,23 +59,32 @@ default = "root"; example = "admin"; description = '' - The user that the system derivation will be deployed to. The command specified in + The user that the system derivation will be built with. The command specified in `.deploy.sudoCmd` will be used if `.deploy.user` is not the same as `.deploy.ssh.user` the same as above). ''; }; - sudoCmd = mkOption { - type = types.str; - default = "sudo -u"; - example = "doas -u"; + warnNonstandardDeployUser = mkOption { + type = types.bool; + default = true; + example = false; description = '' - Which sudo command to use. Must accept at least two arguments: - 1. the user name to execute commands as - 2. the rest is the command to execute + Disables the warning that shows when `deploy.ssh.user` is set to a non-standard value. ''; }; + # sudoCmd = mkOption { + # type = types.str; + # default = "sudo -u"; + # example = "doas -u"; + # description = '' + # Which sudo command to use. Must accept at least two arguments: + # 1. the user name to execute commands as + # 2. the rest is the command to execute + # ''; + # }; + interactiveSudo = mkOption { type = types.bool; default = false; @@ -145,8 +154,8 @@ ssh = { host = mkOption { - type = types.str; - default = ""; + type = types.nullOr types.str; + default = null; example = "dobutterfliescry.net"; description = '' The host to connect to over ssh during deployment @@ -171,6 +180,16 @@ ''; }; + publicKeys = mkOption { + type = types.listOf types.str; + default = []; + example = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIeyZuUUmyUYrYaEJwEMvcXqZFYm1NaZab8klOyK6Imr me@puter"]; + description = '' + SSH public keys that will be authorized to the deployment user. + This key is intended solely for deployment, allowing for fine-grained permission control. + ''; + }; + opts = mkOption { type = types.listOf types.str; default = []; From 02ded5d4f0d53eaeb68f1b68469926fd21acc6db Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sun, 8 Mar 2026 02:21:51 +1000 Subject: [PATCH 18/20] TEMP fix for cerubld not having permissions --- cerulean/nixos/remote-deploy/default.nix | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cerulean/nixos/remote-deploy/default.nix b/cerulean/nixos/remote-deploy/default.nix index f2f4a90..4aa39fd 100644 --- a/cerulean/nixos/remote-deploy/default.nix +++ b/cerulean/nixos/remote-deploy/default.nix @@ -21,13 +21,13 @@ in { one publicKey authorized for ssh deployment! Try setting `nodes.nodes..deploy.ssh.publicKeys = [ ... ]` <3 ''; } - { - assertion = cfg.isSystemUser && !cfg.isNormalUser; - message = '' - The Cerulean deployment user `${user}` for node `${hostname}` has been configured incorrectly. - Ensure `users.users.${user}.isSystemUser == true` and `users.users.${user}.isNormalUser == false`. - ''; - } + # { + # assertion = cfg.isSystemUser && !cfg.isNormalUser; + # message = '' + # The Cerulean deployment user `${user}` for node `${hostname}` has been configured incorrectly. + # Ensure `users.users.${user}.isSystemUser == true` and `users.users.${user}.isNormalUser == false`. + # ''; + # } ]; warnings = lib.optional (node.deploy.warnNonstandardDeployUser && !isStandardDeployUser) '' @@ -47,12 +47,16 @@ in { users = [user]; runAs = "${node.deploy.user}:ALL"; commands = [ - "${pkgs.nix}/bin/nix" + # "${pkgs.nix}/bin/nix" + "ALL" # XXX: WARNING: FIX: TODO: DO NOT FUCKING USE `ALL` ]; } ]; }; + # XXX: WARNING: FIX: TODO: use `trusted-public-keys` instead + nix.settings.trusted-users = [user]; + # ensure deployment user has SSH permissions services.openssh.settings.AllowUsers = [user]; @@ -61,11 +65,17 @@ in { users.${user} = { enable = true; - isSystemUser = true; - group = user; description = "Cerulean's user for building and remote deployment."; + isSystemUser = true; + group = user; + + createHome = true; + home = "/var/lib/cerulean/cerubld"; + + useDefaultShell = false; shell = pkgs.bash; + openssh.authorizedKeys.keys = node.deploy.ssh.publicKeys; }; }; From 902f9d75082772a98a745de5c747f0d27f8c53e3 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sun, 8 Mar 2026 17:13:37 +1000 Subject: [PATCH 19/20] provide systems and snow as flake inputs --- cerulean/snow/default.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index c1199a6..6993ff1 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -48,16 +48,22 @@ in class = "snowflake"; # TODO: abort if inputs contains reserved names specialArgs = - flakeInputs - // { - inherit root; - inherit systems; - inherit (this) snow; # please don't be infinite recursion... - inputs = flakeInputs; - }; + (flakeInputs + // { + inherit systems root; + inherit (this) snow; + inputs = flakeInputs; + }) + |> (x: builtins.removeAttrs x ["self" "nodes"]); modules = [ ./module.nix + ({config, ...}: { + _module.args = { + self = config; + nodes = config.nodes.nodes; + }; + }) ]; }; @@ -86,7 +92,7 @@ in userArgs = nodes.args // node.args; ceruleanArgs = { - inherit systems root base node; + inherit systems root base nodes node; inherit (node) system; inherit (this) snow; hostname = name; From 6c7f335fbde5b6f1931d79d287bf03ee642ba7f5 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sun, 8 Mar 2026 17:14:06 +1000 Subject: [PATCH 20/20] features for v0.2.6-alpha --- TODO.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.md b/TODO.md index 5fff9a2..7a23e43 100755 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,7 @@ ## Next +- [ ] formalize how the snow flake system compiles outputs, this would remove the need for `mapNodes` +- [ ] groups should allow you to set node configuration defaults + - [ ] add `options.experimental` for snowflake - [ ] add `legacyImports` support