forked from fediversity/fediversity
Compare commits
2 commits
df67b13662
...
6c2022d064
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c2022d064 | |||
| f51462afc9 |
2 changed files with 102 additions and 19 deletions
|
|
@ -16,33 +16,50 @@ in
|
|||
test-eval = {
|
||||
expr =
|
||||
let
|
||||
example = eval {
|
||||
runtime-configurations.nixos =
|
||||
{ ... }:
|
||||
{
|
||||
system.stateVersion = "25.05";
|
||||
};
|
||||
runtime-environments.bar.nixos = { };
|
||||
applications.foo = {
|
||||
module =
|
||||
{ pkgs, ... }:
|
||||
example = eval (
|
||||
{ config, ... }:
|
||||
{
|
||||
runtime-configurations.single-ssh-host =
|
||||
{ ... }:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.hello
|
||||
];
|
||||
system.stateVersion = "25.05";
|
||||
};
|
||||
};
|
||||
};
|
||||
runtime-environments.bar = {
|
||||
single-ssh-host = {
|
||||
ssh = {
|
||||
host = "localhost";
|
||||
username = "root";
|
||||
authentication.password = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
applications.foo = {
|
||||
module =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.hello
|
||||
];
|
||||
};
|
||||
};
|
||||
deployments.baz = {
|
||||
module = { };
|
||||
runtime-environment = config.runtime-environments.bar;
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
has-runtime-configuration = lib.isAttrs example.runtime-configurations.nixos;
|
||||
has-runtime-environment = lib.isAttrs example.runtime-environments.bar.nixos.module;
|
||||
has-runtime-configuration = lib.isAttrs example.runtime-configurations.single-ssh-host;
|
||||
has-runtime-environment = lib.isAttrs example.runtime-environments.bar.single-ssh-host.module;
|
||||
has-application = lib.isAttrs example.applications.foo.module;
|
||||
has-deployment = lib.isAttrs example.deployments.baz.module;
|
||||
};
|
||||
expected = {
|
||||
has-runtime-configuration = true;
|
||||
has-runtime-environment = true;
|
||||
has-application = true;
|
||||
has-deployment = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ let
|
|||
attrTag
|
||||
deferredModule
|
||||
mergeTypes
|
||||
nullOr
|
||||
submoduleWith
|
||||
submodule
|
||||
str
|
||||
;
|
||||
runtime-configuration = mkOption {
|
||||
description = "The NixOS module of a run-time environment";
|
||||
|
|
@ -45,9 +47,49 @@ let
|
|||
)
|
||||
)
|
||||
{
|
||||
nixos = {
|
||||
description = "A NixOS instance to deploy to.";
|
||||
vm = {
|
||||
description = "A VM to deploy to.";
|
||||
type = submodule {
|
||||
options = {
|
||||
};
|
||||
};
|
||||
};
|
||||
single-ssh-host = {
|
||||
description = "A single host to deploy to by SSH.";
|
||||
type = submodule {
|
||||
options = {
|
||||
ssh = mkOption {
|
||||
description = "SSH connection info";
|
||||
type = submodule {
|
||||
options = {
|
||||
host = mkOption {
|
||||
description = "the host to access by SSH";
|
||||
type = str;
|
||||
};
|
||||
username = mkOption {
|
||||
description = "the SSH user to use";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
};
|
||||
authentication = mkOption {
|
||||
description = "authentication method";
|
||||
type = attrsOf (attrTag {
|
||||
private-key = mkOption {
|
||||
description = "path to the user's SSH private key";
|
||||
type = str;
|
||||
example = "/root/.ssh/id_ed25519";
|
||||
};
|
||||
password = mkOption {
|
||||
description = "SSH password";
|
||||
# TODO: mark as sensitive
|
||||
type = str;
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -65,6 +107,26 @@ let
|
|||
}
|
||||
];
|
||||
};
|
||||
deployment = submoduleWith {
|
||||
description = "A deployment of a configuration of applications to a run-time environment";
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
# the `applications` option consists of configuration for the above applications
|
||||
module = mkOption {
|
||||
description = ''
|
||||
Configuration to be deployed
|
||||
'';
|
||||
type = deferredModule;
|
||||
};
|
||||
runtime-environment = mkOption {
|
||||
description = "The run-time environment to deploy to";
|
||||
type = runtime-environment;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
|
@ -80,5 +142,9 @@ in
|
|||
description = "Collection of Fediversity applications";
|
||||
type = attrsOf application;
|
||||
};
|
||||
deployments = mkOption {
|
||||
description = "Deployment of a configuration of applications to a run-time environment";
|
||||
type = attrsOf deployment;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue