forked from fediversity/fediversity
add data model entity: application
This commit is contained in:
parent
611c961dcf
commit
71b5201527
4 changed files with 89 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: nix-shell --run 'nix-unit ./deployment/data-model-test.nix'
|
- run: nix-shell --run 'nix-unit ./test.nix'
|
||||||
|
|
||||||
check-peertube:
|
check-peertube:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ in
|
||||||
pkgs.nix-unit
|
pkgs.nix-unit
|
||||||
];
|
];
|
||||||
text = ''
|
text = ''
|
||||||
watchexec -w ${builtins.toString ./.} -- nix-unit ${builtins.toString ./deployment/data-model-test.nix} "$@"
|
watchexec -w ${builtins.toString ./.} -- nix-unit ${builtins.toString ./test.nix} "$@"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
||||||
42
deployment/application.nix
Normal file
42
deployment/application.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) types mkOption;
|
||||||
|
in
|
||||||
|
with types;
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
runtime-environments = mkOption {
|
||||||
|
type = attrsOf (attrTag {
|
||||||
|
nixos = mkOption {
|
||||||
|
type = submodule {
|
||||||
|
options = {
|
||||||
|
module = mkOption {
|
||||||
|
description = "The NixOS module of the run-time environment";
|
||||||
|
type = deferredModule;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
applications = mkOption {
|
||||||
|
description = "Collection of NixOS modules, each implementing a Fediversity application";
|
||||||
|
type = attrsOf (submoduleWith {
|
||||||
|
description = "A Fediversity application";
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
module = mkOption {
|
||||||
|
description = "The NixOS module to compose into an operator's configuration";
|
||||||
|
type = deferredModule;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
45
test.nix
Normal file
45
test.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
let
|
||||||
|
inherit (import ./default.nix { }) pkgs;
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
eval =
|
||||||
|
module:
|
||||||
|
(lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
module
|
||||||
|
./deployment/application.nix
|
||||||
|
];
|
||||||
|
}).config;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
test-foo = {
|
||||||
|
expr =
|
||||||
|
let
|
||||||
|
example = eval {
|
||||||
|
runtime-environments.bar.nixos = {
|
||||||
|
module =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
system.stateVersion = "25.05";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
applications.foo = {
|
||||||
|
module =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.hello
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
has-runtime = example.runtime-environments.bar.nixos ? module;
|
||||||
|
has-application = example.applications.foo ? module;
|
||||||
|
};
|
||||||
|
expected = {
|
||||||
|
has-runtime = true;
|
||||||
|
has-application = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue