From ebbd0b5220db2d98f038e265b447ecfc73759176 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sun, 13 Nov 2022 13:49:54 +0800 Subject: [PATCH] config: add `deploy.nodes` to output Welp, now I'm using NixOS for my servers. One step closer to managing an entire cluster with this. --- flake.lock | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 26 ++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index b49dfafa..6f9c4844 100644 --- a/flake.lock +++ b/flake.lock @@ -49,6 +49,28 @@ "type": "github" } }, + "deploy": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1659725433, + "narHash": "sha256-1ZxuK67TL29YLw88vQ18Y2Y6iYg8Jb7I6/HVzmNB6nM=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "41f15759dd8b638e7b4f299730d94d5aa46ab7eb", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, "devshell": { "inputs": { "flake-utils": [ @@ -188,6 +210,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1648199409, + "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1650374568, @@ -380,7 +418,7 @@ }, "neovim-nightly-overlay": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "neovim-flake": "neovim-flake", "nixpkgs": [ "nixpkgs" @@ -447,7 +485,7 @@ "nixpkgs": [ "nixpkgs" ], - "utils": "utils" + "utils": "utils_2" }, "locked": { "lastModified": 1652641841, @@ -579,6 +617,7 @@ }, "root": { "inputs": { + "deploy": "deploy", "devshell": "devshell", "dotfiles": "dotfiles", "emacs-overlay": "emacs-overlay", @@ -664,6 +703,21 @@ } }, "utils": { + "locked": { + "lastModified": 1648297722, + "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { "locked": { "lastModified": 1652372896, "narHash": "sha256-lURGussfF3mGrFPQT3zgW7+RC0pBhbHzco0C7I+ilow=", diff --git a/flake.nix b/flake.nix index 270c1d75..f0127f56 100644 --- a/flake.nix +++ b/flake.nix @@ -71,6 +71,11 @@ # Generating an entire flavored themes with Nix? nix-colors.url = "github:misterio77/nix-colors"; + + # Deploying stuff with Nix. This is becoming a monorepo for everything I + # need and I'm liking it. + deploy.url = "github:serokell/deploy-rs"; + deploy.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = inputs@{ self, nixpkgs, ... }: @@ -384,5 +389,26 @@ # feel like it does. formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt); + + # nixops-lite... in here!?! We got it all, son! + # + # Take note for automatically imported nodes, various options should be + # overridden in the deploy utility considering that most have only + # certain values and likely not work if run with the intended value. + deploy.nodes = (lib'.mapAttrs' (name: value: + lib'.nameValuePair name { + hostname = name; + profiles.system = { + sshUser = "admin"; + user = "root"; + path = inputs.deploy.lib.${defaultSystem}.activate.nixos value; + }; + }) self.nixosConfigurations); + + # How to make yourself slightly saner than before. So far the main checks + # are for deploy nodes. + checks = lib'.mapAttrs + (system: deployLib: deployLib.deployChecks self.deploy) + inputs.deploy.lib; }; }