diff --git a/deploy/colmena.nix b/deploy/colmena.nix index 42cc0e30..d8049dc7 100644 --- a/deploy/colmena.nix +++ b/deploy/colmena.nix @@ -6,7 +6,14 @@ let inherit (inputs.nixpkgs) lib; utils = import ../utils { inherit lib; }; - hostnames = utils.dirNames ../hosts; + # exclude hosts that need auto rollback (until `colmena` supports it) for + # now, we use `deploy-rs` (which has magic rollback) for those (also see ./deploy-rs.nix) + # + # see + # + hostnames = lib.filter ( + hostname: !((utils.hostMeta ../hosts/${hostname}).deploy.autoRollback or false) + ) (utils.dirNames ../hosts); mkNode = hostname: diff --git a/deploy/deploy-rs.nix b/deploy/deploy-rs.nix new file mode 100644 index 00000000..515585e0 --- /dev/null +++ b/deploy/deploy-rs.nix @@ -0,0 +1,34 @@ +{ + self, + inputs, +}: + +let + inherit (inputs.nixpkgs) lib; + utils = import ../utils { inherit lib; }; + + # only include hosts that need auto rollback (until `colmena` supports it) + # `colmena` is used for other hosts (see ./colmena.nix) + hostnames = lib.filter ( + hostname: (utils.hostMeta ../hosts/${hostname}).deploy.autoRollback or false + ) (utils.dirNames ../hosts); + + mkNode = + hostname: + let + meta = utils.hostMeta ../hosts/${hostname}; + in + { + inherit hostname; + sshUser = meta.host.username; + magicRollback = true; + autoRollback = true; + profiles.system = { + user = "root"; + path = inputs.deploy-rs.lib.${meta.system}.activate.nixos self.nixosConfigurations.${hostname}; + }; + }; +in +{ + nodes = lib.genAttrs hostnames mkNode; +} diff --git a/flake.lock b/flake.lock index f7e432b1..c78e4d92 100644 --- a/flake.lock +++ b/flake.lock @@ -79,11 +79,11 @@ "stable": "stable" }, "locked": { - "lastModified": 1762034856, - "narHash": "sha256-QVey3iP3UEoiFVXgypyjTvCrsIlA4ecx6Acaz5C8/PQ=", + "lastModified": 1782904768, + "narHash": "sha256-tu/otndlmVoSxoQVkNL5cvMFAMyekO2mCVYTl0DRlfs=", "owner": "zhaofengli", "repo": "colmena", - "rev": "349b035a5027f23d88eeb3bc41085d7ee29f18ed", + "rev": "1ebe1b5526099a3b108a599c59ce0e6422a1a663", "type": "github" }, "original": { @@ -92,25 +92,25 @@ "type": "github" } }, - "comin": { + "deploy-rs": { "inputs": { "flake-compat": "flake-compat_2", "nixpkgs": [ "nixpkgs" ], - "treefmt-nix": "treefmt-nix" + "utils": "utils" }, "locked": { - "lastModified": 1780200954, - "narHash": "sha256-3476T026t+XSpOvgBGzKSG6J4swuRLnPO9dR+OATtq8=", - "owner": "nlewo", - "repo": "comin", - "rev": "4f14d338d755239c27131cbf6b466be4bbb20f91", + "lastModified": 1781627888, + "narHash": "sha256-5yHuAh9k7rT7rtf3uRaXkiUyYvQE9oaCgzhprLm2mr8=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "6d3087eedff75a715b40c0e124ba15d2dd7bec28", "type": "github" }, "original": { - "owner": "nlewo", - "repo": "comin", + "owner": "serokell", + "repo": "deploy-rs", "type": "github" } }, @@ -176,11 +176,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { @@ -192,15 +192,15 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1765121682, - "narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=", - "owner": "NixOS", + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", "repo": "flake-compat", - "rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "edolstra", "repo": "flake-compat", "type": "github" } @@ -265,12 +265,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -281,7 +284,7 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems" + "systems": "systems_3" }, "locked": { "lastModified": 1731533236, @@ -316,17 +319,16 @@ "git-hooks": { "inputs": { "flake-compat": "flake-compat_3", - "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1778507602, - "narHash": "sha256-kTwur1wV+01SdqskVMSo6JMEpg71ps3HpbFY2GsflKs=", + "lastModified": 1782908218, + "narHash": "sha256-wLMOrPgVyeF3XmP+qfYcLqnVdTxikdcSvbIY7rA9jTA=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a", + "rev": "9f7e99119ece7705299595299f3b031f39356de1", "type": "github" }, "original": { @@ -335,27 +337,6 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "gnome-shell": { "flake": false, "locked": { @@ -396,7 +377,7 @@ "mcp-hub": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1755841689, @@ -420,11 +401,11 @@ ] }, "locked": { - "lastModified": 1729742964, - "narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=", + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", "owner": "nix-community", "repo": "nix-github-actions", - "rev": "e04df33f62cdcf93d73e9a04142464753a16db67", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", "type": "github" }, "original": { @@ -489,7 +470,7 @@ }, "nixos-hardware": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" }, "locked": { "lastModified": 1780065812, @@ -507,22 +488,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1770107345, - "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1767892417, "narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=", @@ -535,13 +500,13 @@ "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" } }, - "nixpkgs_3": { + "nixpkgs_2": { "locked": { - "lastModified": 1779560665, - "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", + "lastModified": 1782723713, + "narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", + "rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8", "type": "github" }, "original": { @@ -551,13 +516,13 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { - "lastModified": 1743689281, - "narHash": "sha256-y7Hg5lwWhEOgflEHRfzSH96BOt26LaYfrYWzZ+VoVdg=", - "owner": "NixOS", + "lastModified": 1779560665, + "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "2bfc080955153be0be56724be6fa5477b4eefabb", + "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", "type": "github" }, "original": { @@ -715,7 +680,7 @@ "root": { "inputs": { "colmena": "colmena", - "comin": "comin", + "deploy-rs": "deploy-rs", "disko": "disko", "firefox-addons": "firefox-addons", "git-hooks": "git-hooks", @@ -723,7 +688,7 @@ "nix-secrets": "nix-secrets", "nixgl": "nixgl", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nvim": "nvim", "sops-nix": "sops-nix", "stylix": "stylix" @@ -751,16 +716,16 @@ }, "stable": { "locked": { - "lastModified": 1750133334, - "narHash": "sha256-urV51uWH7fVnhIvsZIELIYalMYsyr2FCalvlRTzqWRw=", + "lastModified": 1782851755, + "narHash": "sha256-91ODtG9bUk4AMsgPfGlHzHxh+3r64DClTRxaiTHevIQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "36ab78dab7da2e4e27911007033713bab534187b", + "rev": "f3fb8f32d52b627190abb82438bdcc75a9c77b4e", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.05", + "ref": "release-26.05", "repo": "nixpkgs", "type": "github" } @@ -778,7 +743,7 @@ "nixpkgs" ], "nur": "nur", - "systems": "systems_2", + "systems": "systems_4", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", "tinted-tmux": "tinted-tmux", @@ -828,6 +793,36 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tinted-kitty": { "flake": false, "locked": { @@ -892,21 +887,21 @@ "type": "github" } }, - "treefmt-nix": { + "utils": { "inputs": { - "nixpkgs": "nixpkgs" + "systems": "systems_2" }, "locked": { - "lastModified": 1770228511, - "narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", - "repo": "treefmt-nix", - "rev": "337a4fe074be1042a35086f15481d763b8ddc0e7", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { "owner": "numtide", - "repo": "treefmt-nix", + "repo": "flake-utils", "type": "github" } } diff --git a/flake.nix b/flake.nix index 3b06463e..b07499a0 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,10 @@ url = "github:zhaofengli/colmena"; inputs.nixpkgs.follows = "nixpkgs"; }; + deploy-rs = { + url = "github:serokell/deploy-rs"; + inputs.nixpkgs.follows = "nixpkgs"; + }; comin = { url = "github:nlewo/comin"; inputs.nixpkgs.follows = "nixpkgs"; @@ -164,7 +168,14 @@ ; }; - checks.${system} = gitHooks.checks; + deploy = import ./deploy/deploy-rs.nix { + inherit + self + inputs + ; + }; + + checks.${system} = gitHooks.checks // inputs.deploy-rs.lib.${system}.deployChecks self.deploy; formatter.${system} = gitHooks.formatter; devShells.${system} = gitHooks.devShells; diff --git a/hosts/hecuba/meta.nix b/hosts/hecuba/meta.nix index 21735c53..635ecd81 100644 --- a/hosts/hecuba/meta.nix +++ b/hosts/hecuba/meta.nix @@ -2,6 +2,7 @@ system = "x86_64-linux"; role = "server"; tags = [ "lab" ]; + deploy.autoRollback = true; host = { username = "username"; };