Clean up resource definition

This commit is contained in:
Nicolas Jeannerod 2025-01-31 14:03:37 +01:00
parent 232680c9bf
commit 1f2ea73e69
Signed by untrusted user: Niols
GPG key ID: 35DB9EC8886E1CB8

View file

@ -13,33 +13,37 @@ let
vmid:
{ providers, ... }:
let
vmmodule = import (./. + "/${vmid}");
vmConfig = import (./. + "/${vmid}");
in
{
type = providers.local.exec;
imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ];
ssh = {
# FIXME: The following assumes that `vmmodule` does not use arguments
# and does not get `proxolix.vm.ip4` from an import, etc. I have tried
# an approach with `lib.evalModules` but I cannot get it to work.
host = vmmodule.procolix.vm.ip4;
host = vmConfig.procolix.vm.ip4;
opts = "";
hostPublicKey = self.keys.systems.${vmid};
};
nixpkgs = inputs.nixpkgs;
nixos.module = {
imports = [
vmmodule
## NOTE: We import an attrset as a NixOS module, for convenience, so
## as to be able to use it in NixOps4 and to grab information from it
## (eg. the IP) without evaluating the whole configuration first.
vmConfig
./common
self.nixosModules.ageSecrets
{
fediversity.hostPublicKey = self.keys.systems.${vmid};
## FIXME: Remove direct root authentication once the NixOps4 NixOS
## provider supports users with password-less sudo.
users.users.root.openssh.authorizedKeys.keys = attrValues self.keys.contributors;
}
];
## Necessary to filter Age secrets.
fediversity.hostPublicKey = self.keys.systems.${vmid};
## FIXME: Remove direct root authentication once the NixOps4 NixOS
## provider supports users with password-less sudo.
users.users.root.openssh.authorizedKeys.keys = attrValues self.keys.contributors;
};
};