--- title: Declarative host management --- = Declarative host management This project uses a custom setup for declarative host management. It is a custom github:hercules-ci/flake-parts[opts=repo] module that allows you to easily initialize NixOS systems of multiple platforms (with multiple images output) while making it purely-built as much as possible. This custom flake-parts modules integrates the following projects: * It automatically adds github:serokell/deploy-rs[opts=repo] nodes ready to be deployed with `deploy` CLI tool. * Mandatory inclusion of github:nix-community/home-manager[opts=repo]. * Image output generation made easy with github:nix-community/nixos-generators[opts=repo]. Each of the declared hosts are then exported either as part of the `images` or `nixosConfigurations` (or both) flake output attribute. The `images` flake output attribute contains a per-system set of packages of the NixOS systems as the indicated package format. For example, you can build my personalized NixOS installer ISO with the following command. [source, shell, subs=attributes] ---- nix build {canonical-flake-url}#images.x86_64-linux.bootstrap-iso ---- This is an example of a declarative NixOS setup. The following configuration should have the following effects in the flake output: * Two additional NixOS configurations to be deployed at `nixosConfigurations.plover-{x86_64-linux,aarch64-linux}`. By default, declarative NixOS setups are not added automatically to `nixosConfigurations` output unless we have `configs..formats = null;` but we did configure `configs..deploy` so that makes it even. * Four additional derivations added in `images` flake output (since there's 2 formats and 2 platforms) at `images.{x86_64-linux,aarch64-linux}.plover-{do,gce}`. [#lst:images-metadata-example] [source, nix] ---- { setups.nixos.configs.plover = { systems = [ "x86_64-linux" "aarch64-linux" ]; formats = [ "do" "gce" ]; domain = "foodogsquared.one"; nixpkgs-branch = "nixos-unstable-small"; home-manager-branch = "home-manager-unstable"; modules = [ ({ config, lib, ... }: { services.foo.enable = true; }) ]; overlays = [ inputs.neovim-nightly-overlay.overlays.default ]; deploy = { fastConnection = true; autoRollback = true; magicRollback = true; remoteBuild = true; profiles = os: { system = { sshUser = "root"; user = "admin"; path = inputs.deploy.lib.${os.system}.activate.nixos os.config; }; }; }; }; } ----