From ef345a7fcba192c7a47e449d10d8d5145befef50 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Tue, 10 Jun 2025 15:45:14 +0200 Subject: [PATCH] WIP: sketch domain data model --- deployment/application.nix | 50 ++++++++++++++++++++++++++++++ deployment/runtime-environment.nix | 41 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 deployment/application.nix create mode 100644 deployment/runtime-environment.nix diff --git a/deployment/application.nix b/deployment/application.nix new file mode 100644 index 00000000..c1a8cc9c --- /dev/null +++ b/deployment/application.nix @@ -0,0 +1,50 @@ +{ + lib, + ... +}: +let + inherit (lib) types mkOption; +in +{ + options = { + enable = lib.mkEnableOption "Fediversity configuration"; + applications = mkOption { + description = "Collection of NixOS modules, each implementing a Fediversity application"; + example.hello = { + enable = true; + module = {pkgs, ...}: { + environment.systemPackages = [ pkgs.hello ]; + }; + }; + type = with types; attrsOf (submoduleWith { + class = "nixos"; + description = "A Fediversity application"; + modules = [ + (application: { + options = { + enable = mkOption { + type = types.bool; + }; + module = mkOption { + default = "The NixOS module to compose into an operator's configuration" + type = types.deferredModule; + }; + components = mkOption { + type = with types; attrsOf (attrTag { + file-system-state = mkOption { + desciption = "files stored by the application"; + type = with types; attrsOf (submodule { + options.minSize = types.bytes; + }); + example = { + "/foo/bar/baz" = { minSize = 1024; }; + }; + }; + }); + }; + }; + }) + ]; + }); + }; +} diff --git a/deployment/runtime-environment.nix b/deployment/runtime-environment.nix new file mode 100644 index 00000000..e333af53 --- /dev/null +++ b/deployment/runtime-environment.nix @@ -0,0 +1,41 @@ +{ + lib, + ... +}: +let + inherit (lib) types mkOption; +in +{ + options = { + infrastructure = mkOption { + description = "Infrastructure for Fediversity applications to run on"; + type = + with types; + attrsOf (attrTag { + + single-nixos-machine-via-usb = mkOption { + type = + with types; + submodule { + # TODO: maybe steal some data structures from NixOS + options = { + hasNetwork = mkOption { + type = types.bool; + }; + disks = mkOption { + type = + with types; + attrsOf (submodule { + options.size = mkOption { + type = types.bytes; + }; + + }); + }; + }; + }; + }; + }); + }; + }; +}