Compare commits

..

76 commits

Author SHA1 Message Date
0560135cee
fix data model
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
2025-09-03 13:58:43 +02:00
502cbe8d6d
fix nixops4 for adjusted arguments 2025-09-03 13:22:14 +02:00
71ebf2e900
restore path-based behavior for non-data-model tests 2025-09-03 13:22:14 +02:00
fadf869ab2
switch reusable script to package, facilitating inspection and reuse 2025-09-03 13:22:14 +02:00
0f1859e15b
factor out ssh deployment to make for reusable invocation 2025-09-03 13:22:14 +02:00
b35e531f47
stablize pathToRoot by builtins.path 2025-09-03 13:19:15 +02:00
d678ec85f1
simplify deployment/nixos.nix 2025-09-03 13:19:15 +02:00
38795e1abd
split tests to allow running the faster ssh test separately 2025-09-03 13:19:15 +02:00
c20220f6c1
factor out data model 2025-09-03 13:19:15 +02:00
1bf28297c7
add nixops4 data model test 2025-09-03 13:19:15 +02:00
81b156f0af
adjust deployment type
this is a cop-out possible until
fricklerhandwerk/Fediversity#15.
after that, this will require actually figuring out how to get `options`
for `deployment.nix` - which may need `evalModules` with
`data-model.nix`.
2025-09-03 13:19:15 +02:00
ce0f00562a
restore data model with { resources } wrappers, this time working 2025-09-03 13:19:15 +02:00
e7422808f8
simpler data model, not sure it's desirable but at least it's consistent 2025-09-03 13:16:41 +02:00
88d813f126
actually rely on user package from data model 2025-09-03 13:10:14 +02:00
11e3c6794a
pass system 2025-09-03 13:10:14 +02:00
41c5e79e1f
update test 2025-09-03 13:10:14 +02:00
1b8b1c60a6
update deployment 2025-09-03 13:10:14 +02:00
cfd3095488
simplify auth to not accept password 2025-09-03 13:10:14 +02:00
0a8b357051
rename deployment to deployment-type, disambiguating from environments' deployment 2025-09-03 13:10:14 +02:00
1d4c40de8a
fix attrTag by adding mkOption 2025-09-03 13:07:28 +02:00
d2d1c86b00
wrap application resources to match the input of apply 2025-09-03 13:07:27 +02:00
f6a4838c9d
stylize user-specified names by quotes to clarify their status 2025-09-03 13:07:27 +02:00
d39cecdd41
fix a bug of mismatching names in data model test
matches the name of `shell` to `operator-environment`.
2025-09-03 13:07:27 +02:00
7f6aa72608
try and use deployment 2025-09-03 13:07:27 +02:00
2b4f9cbd19
spacing 2025-09-03 13:07:27 +02:00
4818d44051
simplify imputDerivations 2025-09-03 13:07:27 +02:00
a3fe1c2a8d
unimport qemu-guest 2025-09-03 13:07:27 +02:00
2505b1f851
simplify inputDerivations 2025-09-03 13:07:27 +02:00
e7f5714495
simplify deployment 2025-09-03 13:07:27 +02:00
828fe084bd
skip is-active sshd 2025-09-03 13:07:27 +02:00
234739ce27
- auto 2025-09-03 13:07:27 +02:00
5be47c82b4
move fail in 2025-09-03 13:07:27 +02:00
5e370afd0e
- BatchMode 2025-09-03 13:07:27 +02:00
c486c3e6ed
rm unused ssh settings 2025-09-03 13:07:27 +02:00
a548ef56e6
dedupe inputDerivations 2025-09-03 13:07:27 +02:00
1cbf286555
rm cowsay 2025-09-03 13:07:27 +02:00
cfd603f192
remove unused JSON-serialized args (sources) 2025-09-03 13:07:27 +02:00
5f909a2638
factor out to nixos.nix 2025-09-03 13:07:27 +02:00
c0d5e13aa6
rm users 2025-09-03 13:07:27 +02:00
9b87c5b89d
simplify grub 2025-09-03 13:07:27 +02:00
193d55b48b
rm users 2025-09-03 13:07:27 +02:00
2bf2fe32a7
reenable ipv6 2025-09-03 13:07:27 +02:00
ac5f01a66a
reenable firewall 2025-09-03 13:07:27 +02:00
5b4b674773
rm comments 2025-09-03 13:07:27 +02:00
f2d386e4d3
rm getty 2025-09-03 13:07:27 +02:00
efa11adfdb
mv attempts 2025-09-03 13:07:27 +02:00
3e9cf8a879
download-attempts: settle for just targetNode 2025-09-03 13:07:27 +02:00
ee393e8610
rm comment 2025-09-03 13:07:27 +02:00
db732a6344
restore imports 2025-09-03 13:07:27 +02:00
bd3b1c2e32
dedupe nixosTest.nix 2025-09-03 13:07:27 +02:00
8dd39f05d0
qemu guest 2025-09-03 13:07:27 +02:00
b5496b2be1
grub 2025-09-03 13:07:27 +02:00
15a7fe0c67
auto login 2025-09-03 13:07:27 +02:00
989dd1db51
networking 2025-09-03 13:07:27 +02:00
05bb9ce9fc
users 2025-09-03 13:07:27 +02:00
d9d8fe3025
handle test outcome 2025-09-03 13:07:27 +02:00
567b2fd0b7
specialArgs: sources 2025-09-03 13:07:27 +02:00
dc6478844a
nix in tests: download-attempts = 1 2025-09-03 13:07:27 +02:00
a16615e4e3
ensure inputs 2025-09-03 13:07:27 +02:00
9dc5069c9d
rm paste 2025-09-03 13:07:27 +02:00
8dfb10520e
move stuff not needed in test out 2025-09-03 13:07:27 +02:00
52b9d730b8
ensure availability of needed inputs 2025-09-03 13:07:27 +02:00
a0c1a86129
reduce download attempts in test 2025-09-03 13:07:27 +02:00
431966aede
settle for hello, ditching cowsay 2025-09-03 13:07:27 +02:00
d8cd1f9473
move imports from paste to targetNode to increase parity between paste and nixosTest 2025-09-03 13:07:27 +02:00
fdadbcc9c3
ditch superfluous substituters 2025-09-03 13:07:27 +02:00
8d17c84867
pasteable command for trying without rebuilding vm 2025-09-03 13:07:27 +02:00
fb2b79da88
add keys 2025-09-03 13:07:27 +02:00
d8fcae0ee9
wip: use ssh in test 2025-09-03 13:07:27 +02:00
ae958ce407
add deployment method: ssh 2025-09-03 13:07:27 +02:00
f429ed3656
un-nixops 2025-09-03 13:07:27 +02:00
843f4fe4ec
scaffold deployment/check/data-model from ./basic
modelify
2025-09-03 13:07:27 +02:00
09db4d6217 factor out function wrapper to module function (#503)
lifts the `{ input output }` function wrapper out of the user interface to `function.nix`, simplifying usage.

Reviewed-on: Fediversity/Fediversity#503
2025-09-03 13:06:04 +02:00
c3027eb7d1 move function submodule type (#501)
Reviewed-on: Fediversity/Fediversity#501
2025-09-03 12:52:57 +02:00
4049ca8156 allow different deployment types (#498)
Reviewed-on: Fediversity/Fediversity#498
2025-09-03 12:44:44 +02:00
40e8a0a3c5 CI: allow manual trigger (#495)
Reviewed-on: Fediversity/Fediversity#495
2025-09-03 12:43:25 +02:00
5 changed files with 72 additions and 32 deletions

View file

@ -1,4 +1,5 @@
on:
workflow_dispatch: # allows manual triggering
pull_request:
types:
- opened

View file

@ -105,8 +105,7 @@ let
options.enable = lib.mkEnableOption "Hello in the shell";
};
implementation = cfg: {
input = cfg;
output.resources = lib.optionalAttrs cfg.enable {
resources = lib.optionalAttrs cfg.enable {
hello.login-shell.packages.hello = pkgs.hello;
};
};
@ -142,8 +141,7 @@ let
deployment-name,
}:
{
input = required-resources;
output.ssh-host = {
ssh-host = {
nixos-configuration = mkNixosConfiguration environment required-resources;
system = targetSystem;
ssh = {
@ -166,8 +164,7 @@ let
...
}:
{
input = required-resources;
output.nixops4 =
nixops4 =
{ providers, ... }:
{
providers = {

View file

@ -98,9 +98,9 @@ in
{
options.enable = lib.mkEnableOption "Hello in the shell";
};
implementation = cfg: {
input = cfg;
output.resources = lib.optionalAttrs cfg.enable {
implementation =
cfg: {
resources = lib.optionalAttrs cfg.enable {
hello.login-shell.packages.hello = pkgs.hello;
};
};
@ -110,8 +110,7 @@ in
{
resources."operator-environment".login-shell.username = "operator";
implementation = requests: {
input = requests;
output.nixops4 =
nixops4 = (
{ providers, ... }:
{
providers = {
@ -134,7 +133,8 @@ in
};
};
};
};
}
);
};
};
};

View file

@ -29,7 +29,7 @@ let
lib.strings.toJSON v
);
functionType = import ./function.nix;
functionType = submodule ./function.nix;
application-resources = submodule {
options.resources = mkOption {
# TODO: maybe transpose, and group the resources by type instead
@ -223,18 +223,19 @@ in
};
resources = mkOption {
description = "Compute resources required by an application";
type = functionTo application.config.config-mapping.output-type;
type = application.config.config-mapping.function-type;
readOnly = true;
default = input: (application.config.implementation input).output;
default = application.config.config-mapping.apply;
};
# TODO(@fricklerhandwerk): this needs a better name, it's just the type
# TODO(@fricklerhandwerk): this needs a better name
config-mapping = mkOption {
description = "Function type for the mapping from application configuration to required resources";
type = submodule functionType;
type = functionType;
readOnly = true;
default = {
input-type = submodule application.config.module;
output-type = application-resources;
implementation = application.config.implementation;
};
};
};
@ -266,7 +267,7 @@ in
};
resource-mapping = mkOption {
description = "Function type for the mapping from resources to a deployment";
type = submodule functionType;
type = functionType;
readOnly = true;
default = {
input-type = submodule {
@ -280,6 +281,37 @@ in
};
};
output-type = deployment-type;
implementation = environment.config.implementation;
};
};
config-mapping = mkOption {
description = "Mapping from a configuration to a deployment";
type = functionType;
readOnly = true;
default = {
input-type = submodule {
options = {
deployment-name = mkOption {
type = types.str;
};
configuration = mkOption {
type = config.configuration;
};
};
};
output-type = deployment-type;
implementation =
{
deployment-name,
configuration,
}:
# TODO: check cfg.enable.true
let
required-resources = lib.mapAttrs (
name: application-settings: config.applications.${name}.resources application-settings
) configuration.applications;
in
environment.config.resource-mapping.apply { inherit required-resources deployment-name; };
};
};
# TODO(@fricklerhandwerk): maybe this should be a separate thing such as `fediversity-setup`,
@ -287,21 +319,9 @@ in
# then the deployments can simply be the result of the function application baked into this module.
deployment = mkOption {
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
type = functionTo (environment.config.resource-mapping.output-type);
type = environment.config.config-mapping.function-type;
readOnly = true;
default =
{
deployment-name,
configuration,
}:
# TODO: check cfg.enable.true
let
required-resources = lib.mapAttrs (
name: application-settings: config.applications.${name}.resources application-settings
) configuration.applications;
in
(environment.config.implementation { inherit required-resources deployment-name; }).output;
default = environment.config.config-mapping.apply;
};
};
})

View file

@ -19,6 +19,11 @@ in
type = optionType;
};
function-type = mkOption {
type = optionType;
readOnly = true;
default = functionTo config.output-type;
};
wrapper-type = mkOption {
type = optionType;
readOnly = true;
default = functionTo (submodule {
@ -32,5 +37,22 @@ in
};
});
};
implementation = mkOption {
type = config.function-type;
default = _: { };
};
wrapper = mkOption {
type = config.wrapper-type;
readOnly = true;
default = input: fn: {
inherit input;
output = config.implementation fn.config.input;
};
};
apply = mkOption {
type = config.function-type;
readOnly = true;
default = input: (config.wrapper input).output;
};
};
}