[HACK] swap out nixops4 deployments for raw nixos modules

This commit is contained in:
Kiara Grouwstra 2025-07-21 22:11:17 +02:00
parent ccbe6d9e83
commit fdf03af711
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
2 changed files with 19 additions and 54 deletions

View file

@ -7,15 +7,12 @@ let
(lib.evalModules { (lib.evalModules {
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
# to be passed to nixops4Deployment
resourceProviderSystem = builtins.currentSystem;
}; };
modules = [ modules = [
module module
./data-model.nix ./data-model.nix
]; ];
}).config; }).config;
nixops4Deployment = import ./deployment.nix { inherit inputs; };
in in
{ {
test-eval = { test-eval = {
@ -129,28 +126,7 @@ in
{ {
_class = "fediversity-environment"; _class = "fediversity-environment";
resources.shell.login-shell.username = "operator"; resources.shell.login-shell.username = "operator";
implementation = implementation = requests: {
requests:
{ providers, ... }:
{
_class = "nixops4Deployment";
providers = {
inherit (inputs.nixops4.modules.nixops4Provider) local;
};
# this seems checked according to {providers,resources,resource}.nix,
# values will not eagerly get checked, matching `providers.nix`'s `lazyAttrsOf`,
# whereas allowed keys seem to match those defined in `resource.nix`.
# the content of `resources.the-machine` however, follows `nixops4-nixos`,
# which is not allowed through our `type` yet.
resources.the-machine = {
_class = "nixops4Resource";
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
];
nixos.module =
{ ... }:
{
_class = "nixos"; _class = "nixos";
users.users = ( users.users = (
config.resources.login-shell.policy.apply ( config.resources.login-shell.policy.apply (
@ -162,8 +138,7 @@ in
) requests ) requests
) )
); );
};
};
}; };
}; };
}; };
@ -178,10 +153,7 @@ in
}; };
}; };
example-deployment = mkOption { example-deployment = mkOption {
type = types.submoduleWith { type = types.raw;
class = "nixops4Deployment";
modules = [ nixops4Deployment ];
};
readOnly = true; readOnly = true;
default = config.environments.single-nixos-vm.deployment config.example-configuration; default = config.environments.single-nixos-vm.deployment config.example-configuration;
}; };

View file

@ -1,7 +1,6 @@
{ {
lib, lib,
config, config,
inputs,
... ...
}: }:
let let
@ -13,10 +12,10 @@ let
submoduleWith submoduleWith
optionType optionType
functionTo functionTo
raw
; ;
functionType = import ./function.nix; functionType = import ./function.nix;
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
configuration = mkOption { configuration = mkOption {
description = "Configuration type declaring options to be set by operators"; description = "Configuration type declaring options to be set by operators";
@ -146,10 +145,7 @@ in
}; };
implementation = mkOption { implementation = mkOption {
description = "Mapping of resources required by applications to available resources; the result can be deployed"; description = "Mapping of resources required by applications to available resources; the result can be deployed";
type = functionTo (submoduleWith { type = functionTo environment.config.resource-mapping.output-type;
class = "nixops4Deployment";
modules = [ environment.config.resource-mapping.output-type ];
});
}; };
resource-mapping = mkOption { resource-mapping = mkOption {
description = "Function type for the mapping from resources to a (NixOps4) deployment"; description = "Function type for the mapping from resources to a (NixOps4) deployment";
@ -160,15 +156,12 @@ in
readOnly = true; readOnly = true;
default = { default = {
input-type = configuration; input-type = configuration;
output-type = nixops4Deployment; output-type = raw;
}; };
}; };
deployment = mkOption { deployment = mkOption {
description = "Generate a deployment from a configuration"; description = "Generate a deployment from a configuration";
type = functionTo (submoduleWith { type = functionTo (submodule environment.config.resource-mapping.output-type);
class = "nixops4Deployment";
modules = [ environment.config.resource-mapping.output-type ];
});
readOnly = true; readOnly = true;
default = default =
cfg: cfg: