Compare commits

..

12 commits

Author SHA1 Message Date
5adaeb1420
actually pass a priority level fitting my description 2025-07-07 17:37:25 +02:00
f88a2af47b
use defaultOverridePriority over mkDefault to fix acme error without cashing with settings from tests 2025-07-07 17:03:00 +02:00
91149a080f
use mkDefault to prevent acme clash in tests 2025-07-07 17:03:00 +02:00
623783588d
reinstate acme settings needed by applications 2025-07-07 17:03:00 +02:00
5520fa721b gitea PR unpruned (#445)
see #65

Reviewed-on: Fediversity/Fediversity#445
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-07 13:38:09 +02:00
eabfc228c5 updater: try the first upstream commit without git remote prune (#444)
Reviewed-on: Fediversity/Fediversity#444
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-07 13:23:08 +02:00
3f923532a2 updater: fully qualify github domain in uses (#443)
part of #65.
succeeds #442.

Reviewed-on: Fediversity/Fediversity#443
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-07 12:50:55 +02:00
37d4fc5a42 un-qualify github.com domain in updater uses, which resolved to data.forgejo.org/github.com (#442)
attempt to address https://git.fediversity.eu/Fediversity/Fediversity/actions/runs/920.
part of #65.

Reviewed-on: Fediversity/Fediversity#442
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-07 12:47:06 +02:00
c7b05bb473 deduplicate import-flake, fixing test regression from git merge (#441)
Reviewed-on: Fediversity/Fediversity#441
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-07 10:58:10 +02:00
5345860006 data model: add run-time configuration (#437)
based on @fricklerhandwerk's work at https://git.fediversity.eu/fricklerhandwerk/Fediversity/compare/main...data-model-as-diagram part of #103.
supersedes #402.

on the application model, feedback on a [sample implementation](#2) welcome as well.

Reviewed-on: Fediversity/Fediversity#437
Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-06 21:42:25 +02:00
fbb0806072 in update workflow use PR action actually meant for gitea (#438)
see #65

Reviewed-on: Fediversity/Fediversity#438
Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-06 21:39:26 +02:00
b0848727fd clarify the use of isNormalUser (#436)
Reviewed-on: Fediversity/Fediversity#436
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-06 09:09:43 +02:00
6 changed files with 162 additions and 60 deletions

View file

@ -15,8 +15,9 @@ jobs:
- name: Update pins - name: Update pins
run: nix-shell --run "npins update" run: nix-shell --run "npins update"
- name: Create PR - name: Create PR
uses: peter-evans/create-pull-request@v7 uses: https://github.com/KiaraGrouwstra/gitea-create-pull-request@f9f80aa5134bc5c03c38f5aaa95053492885b397
with: with:
remote-instance-api-version: v1
token: "${{ secrets.DEPLOY_KEY }}" token: "${{ secrets.DEPLOY_KEY }}"
branch: npins-update branch: npins-update
commit-message: "npins: update sources" commit-message: "npins: update sources"

View file

@ -1,9 +1,13 @@
let let
inherit (import ../default.nix { }) pkgs; inherit (import ../default.nix { }) pkgs inputs;
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (lib) mkOption;
eval = eval =
module: module:
(lib.evalModules { (lib.evalModules {
specialArgs = {
inherit inputs;
};
modules = [ modules = [
module module
./data-model.nix ./data-model.nix
@ -16,32 +20,51 @@ in
test-eval = { test-eval = {
expr = expr =
let let
example = eval { fediversity = eval (
runtime-environments.bar.nixos = { { config, ... }:
module = {
{ ... }: config = {
{ applications.hello =
system.stateVersion = "25.05"; { ... }:
{
description = ''Command-line tool that will print "Hello, world!" on the terminal'';
module =
{ ... }:
{
options = {
enable = lib.mkEnableOption "Hello in the shell";
};
};
implementation =
cfg:
lib.optionalAttrs cfg.enable {
dummy.login-shell.packages.hello = pkgs.hello;
};
};
};
options = {
example-configuration = mkOption {
type = config.configuration;
readOnly = true;
default = {
enable = true;
applications.hello.enable = true;
};
}; };
}; };
applications.foo = { }
module = );
{ pkgs, ... }:
{
environment.systemPackages = [
pkgs.hello
];
};
};
};
in in
{ {
has-runtime = lib.isAttrs example.runtime-environments.bar.nixos.module; inherit (fediversity)
has-application = lib.isAttrs example.applications.foo.module; example-configuration
;
}; };
expected = { expected = {
has-runtime = true; example-configuration = {
has-application = true; enable = true;
applications.hello.enable = true;
};
}; };
}; };
} }

View file

@ -1,45 +1,89 @@
{ {
lib, lib,
config,
... ...
}: }:
let let
inherit (lib) types mkOption; inherit (lib) mkOption types;
inherit (lib.types)
attrsOf
attrTag
deferredModuleWith
submodule
optionType
functionTo
;
functionType = import ./function.nix;
application-resources = {
options.resources = mkOption {
# TODO: maybe transpose, and group the resources by type instead
type = attrsOf (
attrTag (lib.mapAttrs (_name: resource: mkOption { type = resource.request; }) config.resources)
);
};
};
in in
with types;
{ {
_class = "nixops4Deployment"; _class = "nixops4Deployment";
options = { options = {
runtime-environments = mkOption { applications = mkOption {
description = "Collection of runtime environments into which applications can be deployed"; description = "Collection of Fediversity applications";
type = attrsOf (attrTag { type = attrsOf (
nixos = mkOption { submodule (application: {
description = "A single NixOS machine"; _class = "fediversity-application";
type = submodule { options = {
options = { description = mkOption {
module = mkOption { description = "Description to be shown in the application overview";
description = "The NixOS module describing the base configuration for that machine"; type = types.str;
type = deferredModule; };
module = mkOption {
description = "Operator-facing configuration options for the application";
type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; };
};
implementation = mkOption {
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
type = application.config.config-mapping.function-type;
};
resources = mkOption {
description = "Compute resources required by an application";
type = functionTo application.config.config-mapping.output-type;
readOnly = true;
default = input: (application.config.implementation input).output;
};
config-mapping = mkOption {
description = "Function type for the mapping from application configuration to required resources";
type = submodule functionType;
readOnly = true;
default = {
input-type = application.config.module;
output-type = application-resources;
}; };
}; };
}; };
}; })
}); );
}; };
applications = mkOption { configuration = mkOption {
description = "Collection of Fediversity applications"; description = "Configuration type declaring options to be set by operators";
type = attrsOf (submoduleWith { type = optionType;
modules = [ readOnly = true;
{ default = submodule {
options = { options = {
module = mkOption { enable = lib.mkEnableOption {
description = "The NixOS module for that application, for configuring that application"; description = "your Fediversity configuration";
type = deferredModule; };
}; applications = lib.mapAttrs (
}; _name: application:
} mkOption {
]; description = application.description;
}); type = submodule application.module;
default = { };
}
) config.applications;
};
};
}; };
}; };
} }

37
deployment/function.nix Normal file
View file

@ -0,0 +1,37 @@
/**
Modular function type
*/
{ config, lib, ... }:
let
inherit (lib) mkOption types;
inherit (types)
deferredModule
submodule
functionTo
optionType
;
in
{
options = {
input-type = mkOption {
type = deferredModule;
};
output-type = mkOption {
type = deferredModule;
};
function-type = mkOption {
type = optionType;
readOnly = true;
default = functionTo (submodule {
options = {
input = mkOption {
type = submodule config.input-type;
};
output = mkOption {
type = submodule config.output-type;
};
};
});
};
};
}

View file

@ -202,11 +202,8 @@ in
}; };
}; };
users.users.${name} = { # needed to place a config file with home-manager
# TODO[Niols]: change to system user or document why we specifically users.users.${name}.isNormalUser = true;
# need a normal user.
isNormalUser = true;
};
users.groups.${name} = { }; users.groups.${name} = { };
systemd.services.${name} = { systemd.services.${name} = {

View file

@ -69,11 +69,11 @@ in
config = { config = {
## FIXME: This should clearly go somewhere else; and we should have a ## FIXME: This should clearly go somewhere else; and we should have a
## `staging` vs. `production` setting somewhere. ## `staging` vs. `production` setting somewhere.
# use a priority higher than mkDefault for panel deployment to work, security.acme = {
# yet lower than default so this will not clash with the setting in tests.
security.acme = lib.modules.mkOverride 900 {
acceptTerms = true; acceptTerms = true;
defaults.email = "something@fediversity.net"; # use a priority more urgent than mkDefault for panel deployment to work,
# yet looser than default so this will not clash with the setting in tests.
defaults.email = lib.modules.mkOverride 200 "something@fediversity.net";
# defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory"; # defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory";
}; };
}; };