revert submodule wrapper to align with module functions already doing types #2

Closed
kiara wants to merge 37 commits from kiara/Fediversity:fix-submodule-type into main
2 changed files with 56 additions and 6 deletions
Showing only changes of commit f51462afc9 - Show all commits

View file

@ -17,12 +17,20 @@ in
expr =
let
example = eval {
runtime-configurations.nixos =
runtime-configurations.single-ssh-host =
{ ... }:
{
system.stateVersion = "25.05";
};
runtime-environments.bar.nixos = { };
runtime-environments.bar = {
single-ssh-host = {
ssh = {
host = "localhost";
username = "root";
authentication.password = "";
};
};
};
applications.foo = {
module =
{ pkgs, ... }:
@ -35,8 +43,8 @@ in
};
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;
};
expected = {

View file

@ -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;
};
});
};
};
};
};
};
};
};
}