From d0780c1ff4bb15dfd3c3271082667436535e89eb Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 18 Feb 2026 20:13:43 +1000 Subject: [PATCH 01/16] TEMP: use base --- cerulean/default.nix | 2 +- cerulean/nixos/nixpkgs.nix | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cerulean/default.nix b/cerulean/default.nix index 202fdf9..4639fa4 100644 --- a/cerulean/default.nix +++ b/cerulean/default.nix @@ -21,12 +21,12 @@ mix.newMixture args (mixture: { ./nexus ]; - version = "0.2.2"; nixosModules = rec { default = cerulean; cerulean = ./nixos; }; + version = "0.2.3"; overlays = [ # build deploy-rs as a package not from the flake input, 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 53914a77e27689fa8992ddc43c686ac251bccf6c Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 18 Feb 2026 23:56:05 +1000 Subject: [PATCH 02/16] 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 80ec35ebbc86ff9b01ddacc1e8d668a9a9aa0fba Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 19 Feb 2026 13:47:51 +1000 Subject: [PATCH 03/16] update TODO --- TODO.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index 1dde662..355863e 100755 --- a/TODO.md +++ b/TODO.md @@ -1,10 +1,11 @@ -- [ ] base should automatically be set as the default (dont do anything with the default) -- [ ] try to remove common foot guns, ie abort if the user provides the home-manager or microvm nixosModules +- [ ] use the Nix module system instead of projectOnto for `cerulean.mkNexus` + +- [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 - [ ] deploy port should default to the first port given to `services.openssh` -- [ ] use the Nix module system instead of projectOnto for `cerulean.mkNexus` - [ ] create an alternative to nixos-install called cerulean-install that allows people to easily bootstrap new machines (and host it on dobutterfliescry.net) @@ -34,10 +35,6 @@ that allows transformations (ie a stop post config, ie outputs, which it then returns instead of config) - -- [ ] what if we automated the process of replacing windows with Nix?? - then push this to nixos-anywhere or nix-infect lmaooo - - [ ] patch microvm so that acpi=off https://github.com/microvm-nix/microvm.nix/commit/b59a26962bb324cc0a134756a323f3e164409b72 cause otherwise 2GB causes a failure From 56184d62fb66e060960ee8d403c829d5225f5019 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 19 Feb 2026 14:38:52 +1000 Subject: [PATCH 04/16] clarify license --- NOTICE | 26 ++++++++++++++++++++++++++ ceru/ceru | 2 +- ceru/libceru.sh | 2 +- ceru/subcmds/new/cache-key | 2 +- ceru/subcmds/new/default.sh | 2 +- ceru/subcmds/new/password | 2 +- ceru/subcmds/new/ssh-key | 2 +- ceru/subcmds/new/wg-key | 2 +- cerulean/default.nix | 2 +- cerulean/nexus/default.nix | 2 +- cerulean/nexus/nexus.nix | 2 +- cerulean/nexus/nodes.nix | 2 +- cerulean/nexus/snow.nix | 2 +- cerulean/nixos/default.nix | 2 +- cerulean/nixos/home-manager.nix | 2 +- cerulean/nixos/microvm-child.nix | 2 +- cerulean/nixos/microvm-parent.nix | 2 +- cerulean/nixos/nixpkgs.nix | 2 +- flake.nix | 2 +- 19 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 NOTICE diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..f85b4fa --- /dev/null +++ b/NOTICE @@ -0,0 +1,26 @@ +Cerulean (https://dobutterfliescry.net/cerulean) +Copyright 2025-2026 _cry64 (Emile Clark-Boman) + +This product includes software developed by +_cry64 (Emile Clark-Boman) (https://github.com/cry128/nt) under the MIT license. +Copyright 2025-2026 _cry64 (Emile Clark-Boman) + +This product includes software developed by +Eelco Dolstra and the Nixpkgs/NixOS contributors under the MIT license. +Copyright 2003-2026 Eelco Dolstra and the Nixpkgs/NixOS contributors + +This product includes software developed by +the Home Manager contributors (https://github.com/nix-community/home-manager) under the MIT license. +Copyright 2017-2026 Home Manager contributors + +This product includes software developed by +Serokell (https://serokell.io) under the MPL-2.0 license. +Copyright 2020-2026 Serokell + +This product includes software developed by +nix-systems (https://github.com/nix-systems) under the MIT license. +Copyright 2023 nix-systems + +This product includes software developed by +Astro (https://github.com/astro) and the MicroVM.nix contributors (https://github.com/microvm-nix/microvm.nix) under the MIT license. +Copyright 2021 Astro, and MicroVM.nix contributors diff --git a/ceru/ceru b/ceru/ceru index f407960..5630489 100755 --- a/ceru/ceru +++ b/ceru/ceru @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/ceru/libceru.sh b/ceru/libceru.sh index 95aba51..ed1b6c3 100755 --- a/ceru/libceru.sh +++ b/ceru/libceru.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/ceru/subcmds/new/cache-key b/ceru/subcmds/new/cache-key index 0b5aa13..e193e83 100755 --- a/ceru/subcmds/new/cache-key +++ b/ceru/subcmds/new/cache-key @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/ceru/subcmds/new/default.sh b/ceru/subcmds/new/default.sh index af34920..88175fa 100755 --- a/ceru/subcmds/new/default.sh +++ b/ceru/subcmds/new/default.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/ceru/subcmds/new/password b/ceru/subcmds/new/password index d5cd795..232539b 100755 --- a/ceru/subcmds/new/password +++ b/ceru/subcmds/new/password @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/ceru/subcmds/new/ssh-key b/ceru/subcmds/new/ssh-key index d0aa524..651aadb 100755 --- a/ceru/subcmds/new/ssh-key +++ b/ceru/subcmds/new/ssh-key @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/ceru/subcmds/new/wg-key b/ceru/subcmds/new/wg-key index 2efa85c..bab6773 100755 --- a/ceru/subcmds/new/wg-key +++ b/ceru/subcmds/new/wg-key @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/cerulean/default.nix b/cerulean/default.nix index 4639fa4..a2dba7d 100644 --- a/cerulean/default.nix +++ b/cerulean/default.nix @@ -1,4 +1,4 @@ -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/cerulean/nexus/default.nix b/cerulean/nexus/default.nix index 65495bf..7a756aa 100644 --- a/cerulean/nexus/default.nix +++ b/cerulean/nexus/default.nix @@ -1,4 +1,4 @@ -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/cerulean/nexus/nexus.nix b/cerulean/nexus/nexus.nix index 5d0ca02..6f79b26 100644 --- a/cerulean/nexus/nexus.nix +++ b/cerulean/nexus/nexus.nix @@ -1,4 +1,4 @@ -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/cerulean/nexus/nodes.nix b/cerulean/nexus/nodes.nix index 13ced2f..0e3d03d 100644 --- a/cerulean/nexus/nodes.nix +++ b/cerulean/nexus/nodes.nix @@ -1,4 +1,4 @@ -# Copyright 2025 Emile Clark-Boman +# 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. diff --git a/cerulean/nexus/snow.nix b/cerulean/nexus/snow.nix index 28496ca..736779f 100644 --- a/cerulean/nexus/snow.nix +++ b/cerulean/nexus/snow.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index ea7c359..02bbe8b 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/cerulean/nixos/home-manager.nix b/cerulean/nixos/home-manager.nix index 1d281cb..7c87a0c 100644 --- a/cerulean/nixos/home-manager.nix +++ b/cerulean/nixos/home-manager.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/cerulean/nixos/microvm-child.nix b/cerulean/nixos/microvm-child.nix index 2b6a12e..d13e217 100644 --- a/cerulean/nixos/microvm-child.nix +++ b/cerulean/nixos/microvm-child.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/cerulean/nixos/microvm-parent.nix b/cerulean/nixos/microvm-parent.nix index 2b6a12e..d13e217 100644 --- a/cerulean/nixos/microvm-parent.nix +++ b/cerulean/nixos/microvm-parent.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/cerulean/nixos/nixpkgs.nix b/cerulean/nixos/nixpkgs.nix index 0376f47..f07fc35 100644 --- a/cerulean/nixos/nixpkgs.nix +++ b/cerulean/nixos/nixpkgs.nix @@ -1,4 +1,4 @@ -# Copyright 2026 Emile Clark-Boman +# 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. diff --git a/flake.nix b/flake.nix index c1a5498..0e6d711 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,4 @@ -# Copyright 2025 Emile Clark-Boman +# 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. From 8f7eb8ff3fdb61e821ce5bdae98857af7c033705 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 19 Feb 2026 22:41:08 +1000 Subject: [PATCH 05/16] finish snow nodes module --- cerulean/nexus/snow.nix | 108 ------------------- cerulean/snow/default.nix | 18 ++++ cerulean/snow/nodes/default.nix | 49 +++++++++ cerulean/snow/nodes/shared.nix | 82 +++++++++++++++ cerulean/snow/nodes/submodule.nix | 166 ++++++++++++++++++++++++++++++ 5 files changed, 315 insertions(+), 108 deletions(-) delete mode 100644 cerulean/nexus/snow.nix create mode 100644 cerulean/snow/default.nix create mode 100644 cerulean/snow/nodes/default.nix create mode 100644 cerulean/snow/nodes/shared.nix create mode 100644 cerulean/snow/nodes/submodule.nix diff --git a/cerulean/nexus/snow.nix b/cerulean/nexus/snow.nix deleted file mode 100644 index 736779f..0000000 --- a/cerulean/nexus/snow.nix +++ /dev/null @@ -1,108 +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. -{ - inputs, - lib, - ... -}: { - # nexus - options = let - inherit - (lib) - mkOption - types - ; - in { - modules = mkOption { - type = types.listOf types.path; - }; - args = mkOption { - type = types.attrs; - }; - - groups = mkOption { - type = types.attrs; - }; - - nodes = mkOption { - type = types.attrsOf (types.submoduleWith ({...}: { - options = { - enabled = mkOption { - type = types.bool; - default = true; - }; - system = mkOption { - type = types.enum inputs.systems; - }; - groups = mkOption { - type = types.list; - }; - modules = mkOption { - type = types.list; - }; - args = mkOption { - type = types.attrs; - }; - - deploy = { - user = mkOption { - type = types.str; - }; - sudoCmd = mkOption { - type = types.str; - }; - interactiveSudo = mkOption { - type = types.bool; - }; - - remoteBuild = mkOption { - type = types.bool; - }; - autoRollback = mkOption { - type = types.bool; - }; - magicRollback = mkOption { - type = types.bool; - }; - - activationTimeout = mkOption { - type = types.int; - }; - confirmTimeout = mkOption { - type = types.int; - }; - - ssh = { - host = mkOption { - type = types.str; - }; - user = mkOption { - type = types.str; - }; - port = mkOption { - type = types.int; - }; - opts = mkOption { - type = types.listOf types.str; - }; - }; - }; - }; - })); - }; - }; - - config = { - }; -} diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix new file mode 100644 index 0000000..1fe87f2 --- /dev/null +++ b/cerulean/snow/default.nix @@ -0,0 +1,18 @@ +# 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. +{...}: { + imports = [ + ./nodes + ]; +} diff --git a/cerulean/snow/nodes/default.nix b/cerulean/snow/nodes/default.nix new file mode 100644 index 0000000..c458a41 --- /dev/null +++ b/cerulean/snow/nodes/default.nix @@ -0,0 +1,49 @@ +# 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. +{lib, ...}: { + options.nodes = let + inherit + (lib) + mkOption + types + ; + in + mkOption { + description = '' + Cerulean node declarations. + ''; + type = types.submoduleWith { + imports = [./shared.nix]; + + options = { + groups = mkOption { + type = types.attrs; + default = {}; + example = lib.literalExpression "{ servers = { staging = {}; production = {}; }; }"; + description = '' + Hierarchical groups that nodes can be a member of. + ''; + }; + + nodes = mkOption { + type = types.attrsOf (types.submoduleWith (import ./submodule.nix)); + # example = { ... }; # TODO + description = '' + Node (host systems) declarations. + ''; + }; + }; + }; + }; +} diff --git a/cerulean/snow/nodes/shared.nix b/cerulean/snow/nodes/shared.nix new file mode 100644 index 0000000..c840d22 --- /dev/null +++ b/cerulean/snow/nodes/shared.nix @@ -0,0 +1,82 @@ +# 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. +{lib, ...}: let + inherit + (lib) + mkOption + types + ; + + flakeRef = types.either types.str types.path; +in { + options = { + base = lib.mkOption { + # In newer Nix versions, particularly with lazy trees, outPath of + # flakes becomes a Nix-language path object. We deliberately allow this + # to gracefully come through the interface in discussion with @roberth. + # + # See: https://github.com/NixOS/nixpkgs/pull/278522#discussion_r1460292639 + type = types.nullOr flakeRef; + + default = null; + defaultText = "if (using nixpkgsFlake.lib.nixosSystem) then self.outPath else null"; + + example = lib.literalExpression "inputs.nixpkgs"; + + description = '' + The path to the nixpkgs source used to build a system. A `base` package set + is required to be set, and can be specified via either: + 1. `options.nodes.base` (default `base` used for all systems) + 2. `options.nodes.nodes..base` (takes prescedence over `options.nodes.base`) + + This can also be optionally set if the NixOS system is not built with a flake but still uses + pinned sources: set this to the store path for the nixpkgs sources used to build the system, + as may be obtained by `fetchTarball`, for example. + + Note: the name of the store path must be "source" due to + . + ''; + }; + + modules = mkOption { + type = types.listOf types.raw; + default = []; + example = lib.literalExpression "[ { environment.systemPackages = [ pkgs.git ]; } ]"; + description = '' + Shared modules to import; equivalent to the NixOS module system's `extraModules`. + ''; + }; + + args = mkOption { + type = types.attrs; + default = {}; + example = lib.literalExpression "{ inherit inputs; }"; + description = '' + Shared args to provided for each node; equivalent to the NixOS module system's `specialArgs`. + ''; + }; + + homeManager = mkOption { + type = types.nullOr flakeRef; + default = null; + example = lib.literalExpression "inputs.home-manager"; + description = '' + The path to the home-manager source. A `homeManager` flake reference + is required to be set for `homes/` to be evaluated, and can be specified via either: + 1. `options.nodes.homeManager` (default `homManager` used for all systems) + 2. `options.nodes.nodes..homeManager` (takes prescedence over `options.nodes.homeManager`) + ''; + }; + }; +} diff --git a/cerulean/snow/nodes/submodule.nix b/cerulean/snow/nodes/submodule.nix new file mode 100644 index 0000000..5d7ffe6 --- /dev/null +++ b/cerulean/snow/nodes/submodule.nix @@ -0,0 +1,166 @@ +# 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. +{ + inputs, + lib, + ... +}: { + imports = [./shared.nix]; + + options = let + inherit + (lib) + mkOption + types + ; + in { + enabled = lib.mkOption { + type = types.bool; + default = true; + example = true; + description = '' + Whether to enable this node. Nodes are enabled by default. + ''; + }; + + system = types.nullOr mkOption { + type = types.enum inputs.systems; + default = null; + example = "x86_64-linux"; + description = '' + The target system architecture to compile for. + ''; + }; + + groups = mkOption { + type = types.functionTo types.list; + default = []; + example = lib.literalExpression "( groups: [ groups.servers groups.secure-boot ] )"; + description = '' + A function from the `groups` hierarchy to a list of groups this node inherits from. + ''; + }; + + deploy = { + user = mkOption { + type = types.str; + default = "root"; + example = "admin"; + description = '' + The user that the system derivation will be deployed to. 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"; + 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; + example = false; + description = '' + Whether to enable interactive sudo (password based sudo). + NOT RECOMMENDED. Use one of Cerulean's recommended auth methods instead. + ''; + }; + + remoteBuild = mkOption { + type = types.bool; + default = false; + example = false; + description = '' + Whether to build the system derivation on the target system. + Will also fetch all external dependencies from the target system's substituters. + ''; + }; + + autoRollback = mkOption { + type = types.bool; + default = true; + example = true; + description = '' + If the previous system derivation should be re-activated if activation fails. + ''; + }; + + activationTimeout = mkOption { + type = types.int; + default = 500; + example = 30; + description = '' + Time window in seconds allowed for system derivation activation. + If timeout occurs, remote deployment is considered to have failed. + ''; + }; + + confirmTimeout = mkOption { + type = types.int; + default = 30; + example = 15; + description = '' + Time window in seconds allowed for activation confirmation. + If timeout occurs, remote deployment is considered to have failed. + ''; + }; + + ssh = { + host = mkOption { + type = types.str; + default = ""; + example = "dobutterfliescry.net"; + description = '' + The host to connect to over ssh during deployment + ''; + }; + + user = mkOption { + type = types.str; + default = "cerubld"; + example = "custom-user"; + description = '' + The user to connect to over ssh during deployment. + ''; + }; + + port = mkOption { + type = types.int; + default = 22; + example = 2222; + description = '' + The port to connect to over ssh during deployment. + ''; + }; + + opts = mkOption { + type = types.listOf types.str; + default = []; + example = ["-i" "~/.ssh/id_rsa"]; + description = '' + Extra ssh arguments to use during deployment. + ''; + }; + }; + }; + }; +} From 43f5c8581ee7701479f82269d314b9ffb834ad4c Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 19 Feb 2026 22:41:17 +1000 Subject: [PATCH 06/16] use lib.optional --- cerulean/nixos/default.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 02bbe8b..99325ef 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -13,6 +13,7 @@ # limitations under the License. { root, + lib, system, _cerulean, ... @@ -24,11 +25,7 @@ # options declarations (import ./nixpkgs.nix (args // {contextName = "hosts";})) ] - ++ ( - if _cerulean.homeManager != null - then [./home-manager.nix] - else [] - ); + ++ lib.optional (_cerulean.homeManager != null) [./home-manager.nix]; environment.systemPackages = with _cerulean.inputs; [ deploy-rs.packages.${system}.default From e4ab4f4b5a81716fcb01a146c6a36e3bc99c62da Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 19 Feb 2026 22:43:57 +1000 Subject: [PATCH 07/16] update TODO --- TODO.md | 4 ++++ cerulean/nixos/default.nix | 3 +++ 2 files changed, 7 insertions(+) diff --git a/TODO.md b/TODO.md index 355863e..2f4edac 100755 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,9 @@ +## Next - [ ] use the Nix module system instead of projectOnto for `cerulean.mkNexus` +- [ ] add `options.experimental` for snowflake +- [ ] add `legacyImports` support +## 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 diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 99325ef..ae593ef 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -20,6 +20,9 @@ } @ args: { imports = [ + # add support for `options.legacyImports` + # ./legacy-imports.nix + # user configuration (import (root + "/nixpkgs.nix")) # options declarations From 45c53f025add7c7c9e76e6632877f66d05193bbf Mon Sep 17 00:00:00 2001 From: _cry64 Date: Fri, 20 Feb 2026 02:08:04 +1000 Subject: [PATCH 08/16] support snow.flake --- cerulean/default.nix | 13 ++- cerulean/nixos/default.nix | 6 +- cerulean/nixos/home-manager.nix | 4 + cerulean/nixos/nixpkgs.nix | 12 +- cerulean/snow/default.nix | 176 +++++++++++++++++++++++++++++- cerulean/snow/lib/nodes.nix | 96 ++++++++++++++++ cerulean/snow/module.nix | 23 ++++ cerulean/snow/nodes/default.nix | 51 +++++---- cerulean/snow/nodes/submodule.nix | 11 +- flake.nix | 1 + 10 files changed, 352 insertions(+), 41 deletions(-) create mode 100644 cerulean/snow/lib/nodes.nix create mode 100644 cerulean/snow/module.nix diff --git a/cerulean/default.nix b/cerulean/default.nix index a2dba7d..065621a 100644 --- a/cerulean/default.nix +++ b/cerulean/default.nix @@ -20,12 +20,10 @@ mix.newMixture args (mixture: { includes.public = [ ./nexus ]; + submods.public = [ + ./snow + ]; - - nixosModules = rec { - default = cerulean; - cerulean = ./nixos; - }; version = "0.2.3"; overlays = [ @@ -33,4 +31,9 @@ mix.newMixture args (mixture: { # hence we can rely on a nixpkg binary cache. inputs.deploy-rs.overlays.default ]; + + nixosModules = rec { + default = cerulean; + cerulean = ./nixos; + }; }) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index ae593ef..9e28aa5 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -28,7 +28,11 @@ # options declarations (import ./nixpkgs.nix (args // {contextName = "hosts";})) ] - ++ lib.optional (_cerulean.homeManager != null) [./home-manager.nix]; + ++ ( + if _cerulean.homeManager != null + then [./home-manager.nix] + else [] + ); environment.systemPackages = with _cerulean.inputs; [ deploy-rs.packages.${system}.default diff --git a/cerulean/nixos/home-manager.nix b/cerulean/nixos/home-manager.nix index 7c87a0c..8c1aa8b 100644 --- a/cerulean/nixos/home-manager.nix +++ b/cerulean/nixos/home-manager.nix @@ -25,6 +25,10 @@ pathExists ; in { + imports = [ + _cerulean.homeManager.nixosModules.default + ]; + home-manager = { users = config.users.users diff --git a/cerulean/nixos/nixpkgs.nix b/cerulean/nixos/nixpkgs.nix index f07fc35..03925c8 100644 --- a/cerulean/nixos/nixpkgs.nix +++ b/cerulean/nixos/nixpkgs.nix @@ -75,19 +75,19 @@ 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"]; + _module.args = removeAttrs repos ["pkgs" "default"]; nixpkgs = if contextName == "hosts" 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 {}); + flake.source = lib.mkForce base; # DEBUG: temp while getting base to work + overlays = lib.mkForce (defaultPkgs.overlays or {}); + config = lib.mkForce (defaultPkgs.config or {}); } else if contextName == "homes" then { - config = lib.mkOverride 200 (defaultPkgs.config or {}); - overlays = lib.mkOverride 200 (defaultPkgs.overlays or []); + config = lib.mkForce (defaultPkgs.config or {}); + overlays = lib.mkForce (defaultPkgs.overlays or []); } else {}; }; diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index 1fe87f2..7cd0b18 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -11,8 +11,174 @@ # 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. -{...}: { - imports = [ - ./nodes - ]; -} +{ + this, + self, + inputs, + systems, + nt, + mix, + ... +} @ args: let + inherit + (builtins) + all + attrNames + elem + mapAttrs + warn + ; + + inherit (inputs.nixpkgs) lib; + + inherit (nt) findImport; +in + mix.newMixture args (mixture: let + inherit (mixture) mapNodes; + in { + includes.private = [ + ./lib/nodes.nix + ]; + + inherit findImport; + + # snow.flake + flake = flakeInputs: root: let + module = lib.evalModules { + 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; + }; + + modules = [ + ./module.nix + ]; + }; + + nodes = module.config.nodes; + in rec { + nixosConfigurations = mapNodes nodes ( + { + base, + lib, + name, + node, + groupModules, + ... + }: let + homeManager = + if node.homeManager != null + then node.homeManager + else if nodes.homeManager != null + then nodes.homeManager + else + warn '' + [snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified! + [snowflake] home-manager will NOT be used! User configuration will be ignored! + '' + null; + + userArgs = nodes.args // node.args; + ceruleanArgs = { + inherit systems root base; + inherit (node) system; + inherit (this) snow; + + _cerulean = { + inherit inputs userArgs ceruleanArgs homeManager; + specialArgs = userArgs // ceruleanArgs; + }; + }; + specialArgs = assert (userArgs + |> attrNames + |> all (argName: + ! ceruleanArgs ? argName + || abort '' + `specialArgs` are like super important to Cerulean my love... rollback; + magicRollback = magicRollback -> rollback; + activationTimeout = activationTimeout; + confirmTimeout = confirmTimeout; + + remoteBuild = remoteBuild; + sshUser = ssh.user; + sshOpts = + ssh.opts + ++ ( + if elem "-p" ssh.opts + then [] + else ["-p" (toString ssh.port)] + ) + ++ ( + if elem "-A" ssh.opts + then [] + else ["-A"] + ); + }; + }); + + checks = + inputs.deploy-rs.lib + |> mapAttrs (system: deployLib: + deployLib.deployChecks deploy); + }; + }) diff --git a/cerulean/snow/lib/nodes.nix b/cerulean/snow/lib/nodes.nix new file mode 100644 index 0000000..7f1a21b --- /dev/null +++ b/cerulean/snow/lib/nodes.nix @@ -0,0 +1,96 @@ +# 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. +{nt, ...}: let + inherit + (builtins) + concatLists + elem + filter + isAttrs + mapAttrs + pathExists + typeOf + ; + + rootGroupName = "all"; + + parseGroupsDecl = groups: let + validGroup = g: + isAttrs g + || throw '' + Cerulean Nexus groups must be provided as attribute sets, got "${typeOf g}" instead! + Ensure all the group definitions are attribute sets under your call to `cerulean.mkNexus`. + NOTE: Groups can be accessed via `self.groups.PATH.TO.YOUR.GROUP` + ''; + delegate = parent: gName: g: let + result = + (g + // { + _name = gName; + _parent = parent; + }) + |> mapAttrs (name: value: + if elem name ["_name" "_parent"] + # ignore metadata fields + then value + else assert validGroup value; (delegate result name value)); + in + result; + in + assert validGroup groups; + delegate null rootGroupName groups; + + getGroupModules = root: groups: + # ensure root group is always added + groups + # add all inherited groups via _parent + |> map (let + delegate = g: + if g._parent == null + then [g] + else [g] ++ delegate (g._parent); + in + delegate) + # flatten recursion result + |> concatLists + # find import location + |> map (group: nt.findImport (root + "/groups/${group._name}")) + # filter by uniqueness + |> nt.prim.unique + # ignore missing groups + |> filter pathExists; +in { + mapNodes = nodes: f: + nodes.nodes + |> mapAttrs (name: node: let + # use per-node base or default to nodes' base + base = + if node.base != null + then node.base + else if nodes.base != null + then nodes.base + else + abort '' + Cerulean cannot construct nodes node "${name}" without a base package source. + Ensure `nodes.nodes.*.base` or `nodes.base` is a flake reference to the github:NixOS/nixpkgs repository. + ''; + in + f rec { + inherit name node base; + inherit (base) lib; + + groups = node.groups (parseGroupsDecl nodes.groups); + groupModules = root: getGroupModules root groups; + }); +} diff --git a/cerulean/snow/module.nix b/cerulean/snow/module.nix new file mode 100644 index 0000000..d45b35a --- /dev/null +++ b/cerulean/snow/module.nix @@ -0,0 +1,23 @@ +# 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, + snow, + ... +}: { + imports = [ + ./nodes + (snow.findImport (root + "/snow")) + ]; +} diff --git a/cerulean/snow/nodes/default.nix b/cerulean/snow/nodes/default.nix index c458a41..d3bc9b7 100644 --- a/cerulean/snow/nodes/default.nix +++ b/cerulean/snow/nodes/default.nix @@ -11,7 +11,11 @@ # 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. -{lib, ...}: { +{ + lib, + specialArgs, + ... +}: { options.nodes = let inherit (lib) @@ -24,26 +28,35 @@ Cerulean node declarations. ''; type = types.submoduleWith { - imports = [./shared.nix]; + inherit specialArgs; - options = { - groups = mkOption { - type = types.attrs; - default = {}; - example = lib.literalExpression "{ servers = { staging = {}; production = {}; }; }"; - description = '' - Hierarchical groups that nodes can be a member of. - ''; - }; + modules = [ + { + imports = [./shared.nix]; - nodes = mkOption { - type = types.attrsOf (types.submoduleWith (import ./submodule.nix)); - # example = { ... }; # TODO - description = '' - Node (host systems) declarations. - ''; - }; - }; + options = { + groups = mkOption { + type = types.attrs; + default = {}; + example = lib.literalExpression "{ servers = { staging = {}; production = {}; }; }"; + description = '' + Hierarchical groups that nodes can be a member of. + ''; + }; + + nodes = mkOption { + type = types.attrsOf (types.submoduleWith { + inherit specialArgs; + modules = [(import ./submodule.nix)]; + }); + # example = { ... }; # TODO + description = '' + Node (host systems) declarations. + ''; + }; + }; + } + ]; }; }; } diff --git a/cerulean/snow/nodes/submodule.nix b/cerulean/snow/nodes/submodule.nix index 5d7ffe6..3f2e59e 100644 --- a/cerulean/snow/nodes/submodule.nix +++ b/cerulean/snow/nodes/submodule.nix @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. { - inputs, lib, + systems, ... }: { imports = [./shared.nix]; @@ -34,8 +34,8 @@ ''; }; - system = types.nullOr mkOption { - type = types.enum inputs.systems; + system = mkOption { + type = types.nullOr (types.enum systems); default = null; example = "x86_64-linux"; description = '' @@ -44,8 +44,9 @@ }; groups = mkOption { - type = types.functionTo types.list; - default = []; + # TODO: write a custom group type that validates better than types.attrs lol + type = types.functionTo (types.listOf types.attrs); + default = groups: []; example = lib.literalExpression "( groups: [ groups.servers groups.secure-boot ] )"; description = '' A function from the `groups` hierarchy to a list of groups this node inherits from. diff --git a/flake.nix b/flake.nix index 0e6d711..f5abab0 100644 --- a/flake.nix +++ b/flake.nix @@ -43,5 +43,6 @@ { inherit inputs self nt; inherit (nt) mix; + systems = import inputs.systems; }; } From be45d2a4d4b1c0e536b75eb0898698fefb5eb093 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sun, 22 Feb 2026 02:39:44 +1000 Subject: [PATCH 09/16] remove legacy nexus --- cerulean/default.nix | 6 +- cerulean/nexus/default.nix | 20 --- cerulean/nexus/nexus.nix | 297 ------------------------------------- cerulean/nexus/nodes.nix | 101 ------------- 4 files changed, 3 insertions(+), 421 deletions(-) delete mode 100644 cerulean/nexus/default.nix delete mode 100644 cerulean/nexus/nexus.nix delete mode 100644 cerulean/nexus/nodes.nix diff --git a/cerulean/default.nix b/cerulean/default.nix index 065621a..47fcdfd 100644 --- a/cerulean/default.nix +++ b/cerulean/default.nix @@ -17,15 +17,15 @@ ... } @ args: mix.newMixture args (mixture: { - includes.public = [ - ./nexus - ]; submods.public = [ ./snow ]; version = "0.2.3"; + # WARNING: legacy + mkFlake = mixture.snow.flake; + overlays = [ # build deploy-rs as a package not from the flake input, # hence we can rely on a nixpkg binary cache. diff --git a/cerulean/nexus/default.nix b/cerulean/nexus/default.nix deleted file mode 100644 index 7a756aa..0000000 --- a/cerulean/nexus/default.nix +++ /dev/null @@ -1,20 +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. -{mix, ...} @ args: -mix.newMixture args (mixture: { - includes.public = [ - ./nodes.nix - ./nexus.nix - ]; -}) diff --git a/cerulean/nexus/nexus.nix b/cerulean/nexus/nexus.nix deleted file mode 100644 index 6f79b26..0000000 --- a/cerulean/nexus/nexus.nix +++ /dev/null @@ -1,297 +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. -{ - self, - this, - nt, - inputs, - ... -}: let - inherit - (builtins) - all - attrNames - concatLists - concatStringsSep - elem - filter - getAttr - isAttrs - isFunction - isList - mapAttrs - pathExists - typeOf - ; - - inherit - (this) - mapNodes - ; - - inherit - (nt) - findImport - ; - - templateNexus = let - inherit - (nt.naive.terminal) - Terminal - ; - in { - base = null; - modules = []; - args = Terminal {}; - homeManager = null; - - groups = Terminal {}; - nodes = Terminal {}; - }; - - ROOT_GROUP_NAME = "all"; - - parseGroupDecl = groups: let - validGroup = g: - isAttrs g - || throw '' - Cerulean Nexus groups must be provided as attribute sets, got "${typeOf g}" instead! - Ensure all the group definitions are attribute sets under your call to `cerulean.mkNexus`. - NOTE: Groups can be accessed via `self.groups.PATH.TO.YOUR.GROUP` - ''; - delegate = parent: gName: g: let - result = - (g - // { - _name = gName; - _parent = parent; - }) - |> mapAttrs (name: value: - if elem name ["_name" "_parent"] - # ignore metadata fields - then value - else assert validGroup value; (delegate result name value)); - in - result; - in - assert validGroup groups; - delegate null ROOT_GROUP_NAME groups; - - parseNexus = nexus: - assert isAttrs nexus - || abort '' - Cerulean Nexus config must be provided as an attribute set, got "${typeOf nexus}" instead! - Ensure the `nexus` declaration is an attribute set under your call to `cerulean.mkNexus`. - ''; let - decl = nt.projectOnto templateNexus nexus; - in - # XXX: TODO: create a different version of nt.projectOnto that can actually - # XXX: TODO: handle applying a transformation to the result of each datapoint - decl - // { - groups = parseGroupDecl decl.groups; - }; - - parseDecl = outputsBuilder: let - decl = ( - if isFunction outputsBuilder - then outputsBuilder final # provide `self` - else - assert (isAttrs outputsBuilder) - || abort '' - Cerulean declaration must be provided as an attribute set, got "${typeOf outputsBuilder}" instead! - Ensure your declaration is an attribute set or function under your call to `cerulean.mkNexus`. - ''; outputsBuilder - ); - - final = - decl - // { - nexus = parseNexus (decl.nexus or {}); - }; - in - final; - - getGroupModules = root: nodeName: node: - assert isList node.groups - || throw '' - Cerulean Nexus node "${nodeName}" does not declare group membership as a list, got "${typeOf node.groups}" instead! - Ensure `nexus.nodes.${nodeName}.groups` is a list under your call to `cerulean.mkNexus`. - ''; - # ensure root group is always added - (node.groups - ++ [ - { - _parent = null; - _name = ROOT_GROUP_NAME; - } - ]) - # ensure all members are actually groups - |> map (group: let - got = - if ! isAttrs group - then toString group - else - group - |> attrNames - |> map (name: "${name} = <${typeOf (getAttr name group)}>;") - |> concatStringsSep " " - |> (x: "{ ${x} }"); - in - if group ? _name - then group - else - throw '' - Cerulean Nexus node "${nodeName}" is a member of an incorrectly structured group. - Got "${got}" of primitive type "${typeOf group}". - NOTE: Groups can be accessed via `self.groups.PATH.TO.YOUR.GROUP` - '') - # add all inherited groups via _parent - |> map (let - delegate = g: - if g._parent == null - then [g] - else [g] ++ delegate (g._parent); - in - delegate) - # flatten recursion result - |> concatLists - # find import location - |> map (group: findImport (root + "/groups/${group._name}")) - # filter by uniqueness - |> nt.prim.unique - # ignore missing groups - |> filter pathExists; -in { - mkNexus = root: outputsBuilder: let - decl = parseDecl outputsBuilder; - - inherit - (decl) - nexus - ; - customOutputs = removeAttrs decl ["nexus"]; - - outputs = rec { - nixosConfigurations = mapNodes nexus ( - { - base, - lib, - nodeName, - node, - ... - }: 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 homeManager; - specialArgs = userArgs // ceruleanArgs; - }; - }; - specialArgs = assert (userArgs - |> attrNames - |> all (argName: - ! ceruleanArgs ? argName - || abort '' - `specialArgs` are like super important to Cerulean my love... mapAttrs (nodeName: nodeAttrs: let - node = parseNode nodeName nodeAttrs; - - # use per-node base or default to nexus base - base = - if node.base != null - then node.base - else if nexus.base != null - then nexus.base - else - abort '' - Cerulean cannot construct nexus node "${nodeName}" without a base package source. - Ensure `nexus.nodes.*.base` or `nexus.base` is a flake reference to the github:NixOS/nixpkgs repository. - ''; - in - f { - inherit nodeName node base; - inherit (base) lib; - }); -} From 35571f6af1977b8461ba2ce9dc356b39227e1b63 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Sun, 22 Feb 2026 02:40:09 +1000 Subject: [PATCH 10/16] add missing deploy.rollback option --- cerulean/snow/nodes/submodule.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cerulean/snow/nodes/submodule.nix b/cerulean/snow/nodes/submodule.nix index 3f2e59e..340a395 100644 --- a/cerulean/snow/nodes/submodule.nix +++ b/cerulean/snow/nodes/submodule.nix @@ -96,6 +96,15 @@ ''; }; + rollback = mkOption { + type = types.bool; + default = true; + example = true; + description = '' + Enables both `autoRollback` and `magicRollback`. + ''; + }; + autoRollback = mkOption { type = types.bool; default = true; From 8928134f12c39bb32bed6d6e5f94df4774eea09a Mon Sep 17 00:00:00 2001 From: _cry64 Date: Tue, 24 Feb 2026 17:28:28 +1000 Subject: [PATCH 11/16] add magicRollback (tf did it go??) --- cerulean/snow/nodes/submodule.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cerulean/snow/nodes/submodule.nix b/cerulean/snow/nodes/submodule.nix index 340a395..ea30c4f 100644 --- a/cerulean/snow/nodes/submodule.nix +++ b/cerulean/snow/nodes/submodule.nix @@ -114,6 +114,15 @@ ''; }; + magicRollback = mkOption { + type = types.bool; + default = true; + example = true; + description = '' + TODO: im fucking lazy + ''; + }; + activationTimeout = mkOption { type = types.int; default = 500; From fe1537735d5ebd8432bace71242a257cd000c1a4 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 26 Feb 2026 14:52:20 +1000 Subject: [PATCH 12/16] fix rename sudo -> sudoCmd --- cerulean/snow/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index 7cd0b18..b1ea663 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -130,7 +130,7 @@ in (node.deploy) ssh user - sudo + sudoCmd interactiveSudo remoteBuild rollback @@ -149,7 +149,7 @@ in path = nixosFor node.system nixosConfigurations.${name}; user = user; - sudo = sudo; + sudo = sudoCmd; interactiveSudo = interactiveSudo; fastConnection = false; From e1f8c6cc3bf7bb3f48f635d6b0c3af59dd2430b1 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 26 Feb 2026 15:21:23 +1000 Subject: [PATCH 13/16] add sops-nix dependency --- cerulean/nixos/default.nix | 6 ++++-- cerulean/snow/default.nix | 2 -- flake.nix | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index 9e28aa5..d585cc5 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -13,12 +13,11 @@ # limitations under the License. { root, - lib, system, _cerulean, ... } @ args: { - imports = + imports = with _cerulean.inputs; [ # add support for `options.legacyImports` # ./legacy-imports.nix @@ -27,6 +26,9 @@ (import (root + "/nixpkgs.nix")) # options declarations (import ./nixpkgs.nix (args // {contextName = "hosts";})) + + sops-nix.nixosModules.sops + # microvm.nixosModules.microvm ] ++ ( if _cerulean.homeManager != null diff --git a/cerulean/snow/default.nix b/cerulean/snow/default.nix index b1ea663..048572b 100644 --- a/cerulean/snow/default.nix +++ b/cerulean/snow/default.nix @@ -112,8 +112,6 @@ in [ self.nixosModules.default (findImport (root + "/hosts/${name}")) - - # inputs.microvm.nixosModules.microvm ] ++ (groupModules root) ++ node.modules diff --git a/flake.nix b/flake.nix index f5abab0..80faf5c 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,11 @@ url = "github:microvm-nix/microvm.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { From 8508b61b9224f409dc85562da4260dfbf9ab52cf Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 26 Feb 2026 15:21:33 +1000 Subject: [PATCH 14/16] update CHANGELOG (todo) --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c7a9a3..dd559bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,3 +23,11 @@ Minor patches - cerulean no longer depends on `nixpkgs`, `base` package set should be set instead - rename `extraModules` -> `modules` - rename `specialArgs` -> `args` + +## v0.2.3-alpha +>[!TODO] +> I've been too focused on upcoming changes... + +## v0.2.4-alpha +- `homeManager` flake reference may now be specified in snowflake +- `` From 0651bd0118e73a5c8a9581dfe0313ecaa5ed1e0a Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 26 Feb 2026 20:43:04 +1000 Subject: [PATCH 15/16] default install sops --- cerulean/nixos/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cerulean/nixos/default.nix b/cerulean/nixos/default.nix index d585cc5..8d96f08 100644 --- a/cerulean/nixos/default.nix +++ b/cerulean/nixos/default.nix @@ -13,6 +13,7 @@ # limitations under the License. { root, + pkgs, system, _cerulean, ... @@ -36,7 +37,11 @@ else [] ); - environment.systemPackages = with _cerulean.inputs; [ - deploy-rs.packages.${system}.default - ]; + environment.systemPackages = + (with pkgs; [ + sops + ]) + ++ (with _cerulean.inputs; [ + deploy-rs.packages.${system}.default + ]); } From 9bab917d8cc3b16f3c73b1980fcb55a4b5ce5239 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Tue, 3 Mar 2026 11:45:15 +1000 Subject: [PATCH 16/16] ignore rust artefacts --- .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/