Compare commits

..

23 commits

Author SHA1 Message Date
e35dc5d3e5
[HACK] simplify out requests arg to make test pass 2025-07-19 18:11:40 +02:00
2a18d2e28b
model: [DUMMY] use mock deployment to temporarily simplify the problem 2025-07-19 18:06:36 +02:00
c42d3e87d5
add trivial unit test for deployment - now to find how to make it work! 2025-07-19 17:38:40 +02:00
ffe59ae210
pass resourceProviderSystem to nixops4Deployment 2025-07-19 16:17:23 +02:00
9e59b27411
model: add classes 2025-07-19 15:37:47 +02:00
015ea16475
model: deadnix 2025-07-19 12:15:52 +02:00
63c200f837
use submodule to turn module into type for functionTo 2025-07-18 22:17:52 +02:00
222fca8249
use mapAttrs right
`mapAttrs'` takes two args rather than a set, whereas if only the val
changes `mapAttrs (_: v: ...)` should do
2025-07-04 23:04:28 +02:00
4880766c59
test for configuration passes, test for deployment wip 2025-07-03 20:31:26 +02:00
d185d5f94f
fix typos, lint, format 2025-07-03 20:23:04 +02:00
ba047997f2 WIP: illustrate an entire NixOS configuration as a resource 2025-07-03 13:08:14 +02:00
0c592d81f3 WIP: (broken) implement test 2025-07-02 03:39:36 +02:00
f8d1be9f6e WIP: implement mappings 2025-07-02 01:20:35 +02:00
7a667c7517 WIP: start writing an evaluation test
turns out we also need a collection of configurations, obviously
next: figure out where to wire everything up to obtain a deployment
2025-07-01 23:59:16 +02:00
5c97e35970 WIP: add missing types 2025-07-01 22:07:42 +02:00
3ec853a32a WIP: implement data model as in diagram
this doesn't update the tests yet because we don't have all the data
types in place anyway yet, and I still need to come up with testable examples.
2025-07-01 17:55:46 +02:00
c764c0f7b6
better reflect naming from diagram configuration data flow 2025-06-30 14:20:21 +02:00
34529a7de4
data model: migration 2025-06-23 19:22:47 +02:00
6c2022d064
data model: deployment 2025-06-23 16:35:11 +02:00
f51462afc9
data model: runtime environment
allows declaring options so instantiations may configure required
settings
2025-06-23 16:35:04 +02:00
fefcd93bc1
grant run-time environments their own modules with their own description 2025-06-23 11:25:18 +02:00
c1f3aa6aed
have run-time environments use their corresponding run-time configurations 2025-06-23 09:34:59 +02:00
8b2ee21dbe
data model: add run-time configuration 2025-06-23 09:06:52 +02:00
111 changed files with 975 additions and 1184 deletions

View file

@ -1,24 +0,0 @@
name: deploy-infra
on:
workflow_dispatch: # allows manual triggering
push:
branches:
- main
jobs:
deploy:
runs-on: native
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up SSH key for age secrets and SSH
run: |
env
mkdir -p ~/.ssh
echo "${{ secrets.CD_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Deploy
run: nix-shell --run 'eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519 && SHELL=$(which bash) nixops4 apply -v default'

View file

@ -21,23 +21,17 @@ jobs:
- 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 ./deployment/data-model-test.nix'
check-mastodon:
runs-on: native
steps:
- uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.test-mastodon-service -L
check-peertube: check-peertube:
runs-on: native runs-on: native
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.test-peertube-service -L - run: cd services && nix-build -A tests.peertube
check-panel: check-panel:
runs-on: native runs-on: native
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix-build -A tests.panel - run: cd panel && nix-build -A tests
check-deployment-basic: check-deployment-basic:
runs-on: native runs-on: native

View file

@ -2,9 +2,8 @@ name: update-dependencies
on: on:
workflow_dispatch: # allows manual triggering workflow_dispatch: # allows manual triggering
# FIXME: re-enable when manual run works schedule:
# schedule: - cron: '0 0 1 * *' # monthly
# - cron: '0 0 1 * *' # monthly
jobs: jobs:
lockfile: lockfile:
@ -12,12 +11,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Update pins - name: Install npins
run: nix-shell --run "npins update" run: nix-shell --run "npins update"
- name: Create PR - name: Create PR
uses: https://github.com/KiaraGrouwstra/gitea-create-pull-request@f9f80aa5134bc5c03c38f5aaa95053492885b397 uses: peter-evans/create-pull-request@v7
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

@ -9,10 +9,9 @@ let
git-hooks git-hooks
gitignore gitignore
; ;
inherit (pkgs) lib;
inherit (import sources.flake-inputs) import-flake; inherit (import sources.flake-inputs) import-flake;
inherit ((import-flake { src = ./.; }).inputs) nixops4; inputs = (import-flake { src = ./.; }).inputs;
panel = import ./panel { inherit sources system; }; inherit (pkgs) lib;
pre-commit-check = pre-commit-check =
(import "${git-hooks}/nix" { (import "${git-hooks}/nix" {
inherit nixpkgs system; inherit nixpkgs system;
@ -58,26 +57,19 @@ in
}; };
in in
[ [
pkgs.npins
pkgs.nil
(pkgs.callPackage "${sources.agenix}/pkgs/agenix.nix" { })
pkgs.openssh
pkgs.httpie
pkgs.jq
pkgs.nix-unit pkgs.nix-unit
test-loop test-loop
nixops4.packages.${system}.default
]; ];
}; };
tests = { tests = {
inherit pre-commit-check; inherit pre-commit-check;
panel = panel.tests;
}; };
# re-export inputs so they can be overridden granularly # re-export inputs so they can be overridden granularly
# (they can't be accessed from the outside any other way) # (they can't be accessed from the outside any other way)
inherit inherit
inputs
sources sources
system system
pkgs pkgs

View file

@ -1,8 +0,0 @@
{
targetMachines = [
"hello"
"cowsay"
];
pathToRoot = ../../..;
pathFromRoot = ./.;
}

View file

@ -1,14 +0,0 @@
{
runNixOSTest,
inputs,
sources,
}:
runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args = { inherit inputs sources; };
inherit (import ./constants.nix) targetMachines pathToRoot pathFromRoot;
}

View file

@ -1,36 +0,0 @@
{
inputs,
sources,
lib,
providers,
...
}:
let
inherit (import ./constants.nix) targetMachines pathToRoot pathFromRoot;
in
{
providers = {
inherit (inputs.nixops4.modules.nixops4Provider) local;
};
resources = lib.genAttrs targetMachines (nodeName: {
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
../common/targetResource.nix
];
_module.args = { inherit inputs sources; };
inherit nodeName pathToRoot pathFromRoot;
nixos.module =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.${nodeName} ];
};
});
}

View file

@ -0,0 +1,54 @@
{
self,
inputs,
lib,
...
}:
let
inherit (lib) genAttrs;
targetMachines = [
"hello"
"cowsay"
];
pathToRoot = /. + (builtins.unsafeDiscardStringContext self);
pathFromRoot = ./.;
in
{
perSystem =
{ pkgs, ... }:
{
checks.deployment-basic = pkgs.testers.runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args.inputs = inputs;
inherit targetMachines pathToRoot pathFromRoot;
};
};
nixops4Deployments.check-deployment-basic =
{ providers, ... }:
{
providers = {
inherit (inputs.nixops4.modules.nixops4Provider) local;
};
resources = genAttrs targetMachines (nodeName: {
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
../common/targetResource.nix
];
_module.args.inputs = inputs;
inherit nodeName pathToRoot pathFromRoot;
nixos.module =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.${nodeName} ];
};
});
};
}

View file

@ -1,22 +0,0 @@
{
inputs = {
nixops4.follows = "nixops4-nixos/nixops4";
nixops4-nixos.url = "github:nixops4/nixops4-nixos";
};
outputs =
inputs:
import ./mkFlake.nix inputs (
{ inputs, sources, ... }:
{
imports = [
inputs.nixops4.modules.flake.default
];
nixops4Deployments.check-deployment-basic = {
imports = [ ./deployment/check/basic/deployment.nix ];
_module.args = { inherit inputs sources; };
};
}
);
}

View file

@ -1,15 +1,8 @@
{ inputs, lib, ... }: { inputs, ... }:
{ {
_class = "nixosTest";
name = "deployment-basic"; name = "deployment-basic";
sourceFileset = lib.fileset.unions [
./constants.nix
./deployment.nix
];
nodes.deployer = nodes.deployer =
{ pkgs, ... }: { pkgs, ... }:
{ {

View file

@ -1,11 +0,0 @@
{
targetMachines = [
"garage"
"mastodon"
"peertube"
"pixelfed"
];
pathToRoot = ../../..;
pathFromRoot = ./.;
enableAcme = true;
}

View file

@ -1,19 +0,0 @@
{
runNixOSTest,
inputs,
sources,
}:
runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args = { inherit inputs sources; };
inherit (import ./constants.nix)
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
}

View file

@ -1,59 +0,0 @@
{
inputs,
sources,
lib,
}:
let
inherit (builtins) fromJSON readFile listToAttrs;
inherit (import ./constants.nix)
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ];
_module.args = { inherit inputs sources; };
inherit
nodeName
pathToRoot
pathFromRoot
enableAcme
;
};
## The deployment function - what we are here to test!
##
## TODO: Modularise `deployment/default.nix` to get rid of the nested
## function calls.
makeTestDeployment =
args:
(import ../..)
{
inherit lib;
inherit (inputs) nixops4 nixops4-nixos;
fediversity = import ../../../services/fediversity;
}
(listToAttrs (
map (nodeName: {
name = "${nodeName}ConfigurationResource";
value = makeTargetResource nodeName;
}) targetMachines
))
(fromJSON (readFile ../../configuration.sample.json) // args);
in
{
check-deployment-cli-nothing = makeTestDeployment { };
check-deployment-cli-mastodon-pixelfed = makeTestDeployment {
mastodon.enable = true;
pixelfed.enable = true;
};
check-deployment-cli-peertube = makeTestDeployment {
peertube.enable = true;
};
}

View file

@ -0,0 +1,87 @@
{
self,
inputs,
lib,
...
}:
let
inherit (builtins) fromJSON readFile listToAttrs;
targetMachines = [
"garage"
"mastodon"
"peertube"
"pixelfed"
];
pathToRoot = /. + (builtins.unsafeDiscardStringContext self);
pathFromRoot = ./.;
enableAcme = true;
in
{
perSystem =
{ pkgs, ... }:
{
checks.deployment-cli = pkgs.testers.runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args.inputs = inputs;
inherit
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
};
};
nixops4Deployments =
let
makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ];
_module.args.inputs = inputs;
inherit
nodeName
pathToRoot
pathFromRoot
enableAcme
;
};
## The deployment function - what we are here to test!
##
## TODO: Modularise `deployment/default.nix` to get rid of the nested
## function calls.
makeTestDeployment =
args:
(import ../..)
{
inherit lib;
inherit (inputs) nixops4 nixops4-nixos;
fediversity = import ../../../services/fediversity;
}
(listToAttrs (
map (nodeName: {
name = "${nodeName}ConfigurationResource";
value = makeTargetResource nodeName;
}) targetMachines
))
(fromJSON (readFile ../../configuration.sample.json) // args);
in
{
check-deployment-cli-nothing = makeTestDeployment { };
check-deployment-cli-mastodon-pixelfed = makeTestDeployment {
mastodon.enable = true;
pixelfed.enable = true;
};
check-deployment-cli-peertube = makeTestDeployment {
peertube.enable = true;
};
};
}

View file

@ -1,26 +0,0 @@
{
inputs = {
nixops4.follows = "nixops4-nixos/nixops4";
nixops4-nixos.url = "github:nixops4/nixops4-nixos";
};
outputs =
inputs:
import ./mkFlake.nix inputs (
{
inputs,
sources,
lib,
...
}:
{
imports = [
inputs.nixops4.modules.flake.default
];
nixops4Deployments = import ./deployment/check/cli/deployments.nix {
inherit inputs sources lib;
};
}
);
}

View file

@ -1,9 +1,4 @@
{ { inputs, hostPkgs, ... }:
inputs,
hostPkgs,
lib,
...
}:
let let
## Some places need a dummy file that will in fact never be used. We create ## Some places need a dummy file that will in fact never be used. We create
@ -12,25 +7,8 @@ let
in in
{ {
_class = "nixosTest";
name = "deployment-cli"; name = "deployment-cli";
sourceFileset = lib.fileset.unions [
./constants.nix
./deployments.nix
# REVIEW: I would like to be able to grab all of `/deployment` minus
# `/deployment/check`, but I can't because there is a bunch of other files
# in `/deployment`. Maybe we can think of a reorg making things more robust
# here? (comment also in panel test)
../../default.nix
../../options.nix
../../configuration.sample.json
../../../services/fediversity
];
nodes.deployer = nodes.deployer =
{ pkgs, ... }: { pkgs, ... }:
{ {

View file

@ -3,7 +3,6 @@
lib, lib,
pkgs, pkgs,
config, config,
sources,
... ...
}: }:
@ -15,10 +14,10 @@ let
types types
; ;
sources = import ../../../npins;
in in
{ {
_class = "nixos";
imports = [ ./sharedOptions.nix ]; imports = [ ./sharedOptions.nix ];
options.system.extraDependenciesFromModule = mkOption { options.system.extraDependenciesFromModule = mkOption {
@ -54,13 +53,13 @@ in
system.extraDependencies = system.extraDependencies =
[ [
inputs.nixops4 "${inputs.flake-parts}"
inputs.nixops4-nixos "${inputs.flake-parts.inputs.nixpkgs-lib}"
inputs.nixpkgs "${inputs.nixops4}"
"${inputs.nixops4-nixos}"
"${inputs.nixpkgs}"
sources.flake-parts "${sources.flake-inputs}"
sources.flake-inputs
sources.git-hooks
pkgs.stdenv pkgs.stdenv
pkgs.stdenvNoCC pkgs.stdenvNoCC
@ -77,7 +76,7 @@ in
config.system.extraDependenciesFromModule config.system.extraDependenciesFromModule
{ {
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";
_module.args = { inherit inputs sources; }; _module.args.inputs = inputs;
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = config.acmeNodeIP; acmeNodeIP = config.acmeNodeIP;
} }

View file

@ -3,7 +3,6 @@
lib, lib,
config, config,
hostPkgs, hostPkgs,
sources,
... ...
}: }:
@ -13,7 +12,6 @@ let
toJSON toJSON
; ;
inherit (lib) inherit (lib)
types
fileset fileset
mkOption mkOption
genAttrs genAttrs
@ -28,6 +26,14 @@ let
forConcat = xs: f: concatStringsSep "\n" (map f xs); forConcat = xs: f: concatStringsSep "\n" (map f xs);
## The whole repository, with the flake at its root.
## FIXME: We could probably have fileset be the union of ./. with flake.nix
## and flake.lock - I doubt we need anything else.
src = fileset.toSource {
fileset = config.pathToRoot;
root = config.pathToRoot;
};
## We will need to override some inputs by the empty flake, so we make one. ## We will need to override some inputs by the empty flake, so we make one.
emptyFlake = runCommandNoCC "empty-flake" { } '' emptyFlake = runCommandNoCC "empty-flake" { } ''
mkdir $out mkdir $out
@ -36,8 +42,6 @@ let
in in
{ {
_class = "nixosTest";
imports = [ imports = [
./sharedOptions.nix ./sharedOptions.nix
]; ];
@ -46,46 +50,16 @@ in
## FIXME: I wish I could just use `testScript` but with something like ## FIXME: I wish I could just use `testScript` but with something like
## `mkOrder` to put this module's string before something else. ## `mkOrder` to put this module's string before something else.
extraTestScript = mkOption { }; extraTestScript = mkOption { };
sourceFileset = mkOption {
## REVIEW: Upstream to nixpkgs?
type = types.mkOptionType {
name = "fileset";
description = "fileset";
descriptionClass = "noun";
check = (x: (builtins.tryEval (fileset.unions [ x ])).success);
merge = (_: defs: fileset.unions (map (x: x.value) defs));
};
description = ''
A fileset that will be copied to the deployer node in the current
working directory. This should contain all the files that are
necessary to run that particular test, such as the NixOS
modules necessary to evaluate a deployment.
'';
};
}; };
config = { config = {
sourceFileset = fileset.unions [
# NOTE: not the flake itself; it will be overridden.
../../../mkFlake.nix
../../../flake.lock
../../../npins
./sharedOptions.nix
./targetNode.nix
./targetResource.nix
(config.pathToCwd + "/flake-under-test.nix")
];
acmeNodeIP = config.nodes.acme.networking.primaryIPAddress; acmeNodeIP = config.nodes.acme.networking.primaryIPAddress;
nodes = nodes =
{ {
deployer = { deployer = {
imports = [ ./deployerNode.nix ]; imports = [ ./deployerNode.nix ];
_module.args = { inherit inputs sources; }; _module.args.inputs = inputs;
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = config.nodes.acme.networking.primaryIPAddress; acmeNodeIP = config.nodes.acme.networking.primaryIPAddress;
}; };
@ -112,7 +86,7 @@ in
genAttrs config.targetMachines (_: { genAttrs config.targetMachines (_: {
imports = [ ./targetNode.nix ]; imports = [ ./targetNode.nix ];
_module.args = { inherit inputs sources; }; _module.args.inputs = inputs;
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null; acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null;
}); });
@ -126,16 +100,8 @@ in
${n}.wait_for_unit("multi-user.target") ${n}.wait_for_unit("multi-user.target")
'')} '')}
## A subset of the repository that is necessary for this test. It will be
## copied inside the test. The smaller this set, the faster our CI, because we
## won't need to re-run when things change outside of it.
with subtest("Unpacking"): with subtest("Unpacking"):
deployer.succeed("cp -r --no-preserve=mode ${ deployer.succeed("cp -r --no-preserve=mode ${src}/* .")
fileset.toSource {
root = ../../..;
fileset = config.sourceFileset;
}
}/* .")
with subtest("Configure the network"): with subtest("Configure the network"):
${forConcat config.targetMachines ( ${forConcat config.targetMachines (
@ -165,16 +131,11 @@ in
## NOTE: This is super slow. It could probably be optimised in Nix, for ## NOTE: This is super slow. It could probably be optimised in Nix, for
## instance by allowing to grab things directly from the host's store. ## instance by allowing to grab things directly from the host's store.
## with subtest("Override the lock"):
## NOTE: We use the repository as-is (cf `src` above), overriding only
## `flake.nix` by our `flake-under-test.nix`. We also override the flake
## lock file to use locally available inputs, as we cannot download them.
##
with subtest("Override the flake and its lock"):
deployer.succeed("cp ${config.pathFromRoot}/flake-under-test.nix flake.nix")
deployer.succeed(""" deployer.succeed("""
nix flake lock --extra-experimental-features 'flakes nix-command' \ nix flake lock --extra-experimental-features 'flakes nix-command' \
--offline -v \ --offline -v \
--override-input flake-parts ${inputs.flake-parts} \
--override-input nixops4 ${inputs.nixops4.packages.${system}.flake-in-a-bottle} \ --override-input nixops4 ${inputs.nixops4.packages.${system}.flake-in-a-bottle} \
\ \
--override-input nixops4-nixos ${inputs.nixops4-nixos} \ --override-input nixops4-nixos ${inputs.nixops4-nixos} \
@ -186,6 +147,9 @@ in
inputs.nixops4-nixos.inputs.nixops4.packages.${system}.flake-in-a-bottle inputs.nixops4-nixos.inputs.nixops4.packages.${system}.flake-in-a-bottle
} \ } \
--override-input nixops4-nixos/git-hooks-nix ${emptyFlake} \ --override-input nixops4-nixos/git-hooks-nix ${emptyFlake} \
\
--override-input nixpkgs ${inputs.nixpkgs} \
--override-input git-hooks ${inputs.git-hooks} \
; ;
""") """)

View file

@ -11,7 +11,6 @@ let
inherit (lib) mkOption types; inherit (lib) mkOption types;
in in
# `config` not set and imported from multiple places: no fixed module class
{ {
options = { options = {
targetMachines = mkOption { targetMachines = mkOption {

View file

@ -12,8 +12,6 @@ let
in in
{ {
_class = "nixos";
imports = [ imports = [
(modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/qemu-guest.nix")
(modulesPath + "/../lib/testing/nixos-test-base.nix") (modulesPath + "/../lib/testing/nixos-test-base.nix")

View file

@ -2,7 +2,6 @@
inputs, inputs,
lib, lib,
config, config,
sources,
... ...
}: }:
@ -13,8 +12,6 @@ let
in in
{ {
_class = "nixops4Resource";
imports = [ ./sharedOptions.nix ]; imports = [ ./sharedOptions.nix ];
options = { options = {
@ -41,7 +38,7 @@ in
(lib.modules.importJSON (config.pathToCwd + "/${config.nodeName}-network.json")) (lib.modules.importJSON (config.pathToCwd + "/${config.nodeName}-network.json"))
]; ];
_module.args = { inherit inputs sources; }; _module.args.inputs = inputs;
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = trim (readFile (config.pathToCwd + "/acme_server_ip")); acmeNodeIP = trim (readFile (config.pathToCwd + "/acme_server_ip"));

View file

@ -1,11 +0,0 @@
{
targetMachines = [
"garage"
"mastodon"
"peertube"
"pixelfed"
];
pathToRoot = ../../..;
pathFromRoot = ./.;
enableAcme = true;
}

View file

@ -1,19 +0,0 @@
{
runNixOSTest,
inputs,
sources,
}:
runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args = { inherit inputs sources; };
inherit (import ./constants.nix)
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
}

View file

@ -1,58 +0,0 @@
{
inputs,
sources,
lib,
}:
let
inherit (builtins) fromJSON listToAttrs;
inherit (import ./constants.nix)
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ];
_module.args = { inherit inputs sources; };
inherit
nodeName
pathToRoot
pathFromRoot
enableAcme
;
};
## The deployment function - what we are here to test!
##
## TODO: Modularise `deployment/default.nix` to get rid of the nested
## function calls.
makeTestDeployment =
args:
(import ../..)
{
inherit lib;
inherit (inputs) nixops4 nixops4-nixos;
fediversity = import ../../../services/fediversity;
}
(listToAttrs (
map (nodeName: {
name = "${nodeName}ConfigurationResource";
value = makeTargetResource nodeName;
}) targetMachines
))
args;
in
makeTestDeployment (
fromJSON (
let
env = builtins.getEnv "DEPLOYMENT";
in
if env == "" then
throw "The DEPLOYMENT environment needs to be set. You do not want to use this deployment unless in the `deployment-panel` NixOS test."
else
env
)
)

View file

@ -0,0 +1,91 @@
{
self,
inputs,
lib,
...
}:
let
inherit (builtins)
fromJSON
listToAttrs
;
targetMachines = [
"garage"
"mastodon"
"peertube"
"pixelfed"
];
pathToRoot = /. + (builtins.unsafeDiscardStringContext self);
pathFromRoot = ./.;
enableAcme = true;
in
{
perSystem =
{ pkgs, ... }:
{
checks.deployment-panel = pkgs.testers.runNixOSTest {
imports = [
../common/nixosTest.nix
./nixosTest.nix
];
_module.args.inputs = inputs;
inherit
targetMachines
pathToRoot
pathFromRoot
enableAcme
;
};
};
nixops4Deployments =
let
makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ];
_module.args.inputs = inputs;
inherit
nodeName
pathToRoot
pathFromRoot
enableAcme
;
};
## The deployment function - what we are here to test!
##
## TODO: Modularise `deployment/default.nix` to get rid of the nested
## function calls.
makeTestDeployment =
args:
(import ../..)
{
inherit lib;
inherit (inputs) nixops4 nixops4-nixos;
fediversity = import ../../../services/fediversity;
}
(listToAttrs (
map (nodeName: {
name = "${nodeName}ConfigurationResource";
value = makeTargetResource nodeName;
}) targetMachines
))
args;
in
{
check-deployment-panel = makeTestDeployment (
fromJSON (
let
env = builtins.getEnv "DEPLOYMENT";
in
if env == "" then
throw "The DEPLOYMENT environment needs to be set. You do not want to use this deployment unless in the `deployment-panel` NixOS test."
else
env
)
);
};
}

View file

@ -1,26 +0,0 @@
{
inputs = {
nixops4.follows = "nixops4-nixos/nixops4";
nixops4-nixos.url = "github:nixops4/nixops4-nixos";
};
outputs =
inputs:
import ./mkFlake.nix inputs (
{
inputs,
sources,
lib,
...
}:
{
imports = [
inputs.nixops4.modules.flake.default
];
nixops4Deployments.check-deployment-panel = import ./deployment/check/panel/deployment.nix {
inherit inputs sources lib;
};
}
);
}

View file

@ -121,24 +121,8 @@ let
in in
{ {
_class = "nixosTest";
name = "deployment-panel"; name = "deployment-panel";
sourceFileset = lib.fileset.unions [
./constants.nix
./deployment.nix
# REVIEW: I would like to be able to grab all of `/deployment` minus
# `/deployment/check`, but I can't because there is a bunch of other files
# in `/deployment`. Maybe we can think of a reorg making things more robust
# here? (comment also in CLI test)
../../default.nix
../../options.nix
../../../services/fediversity
];
## The panel's module sets `nixpkgs.overlays` which clashes with ## The panel's module sets `nixpkgs.overlays` which clashes with
## `pkgsReadOnly`. We disable it here. ## `pkgsReadOnly`. We disable it here.
node.pkgsReadOnly = false; node.pkgsReadOnly = false;
@ -169,6 +153,7 @@ in
SECRET_KEY = dummyFile; SECRET_KEY = dummyFile;
}; };
port = panelPort; port = panelPort;
nixops4Package = inputs.nixops4.packages.${pkgs.system}.default;
deployment = { deployment = {
flake = "/run/fedipanel/flake"; flake = "/run/fedipanel/flake";

View file

@ -1,36 +1,119 @@
let let
inherit (import ../default.nix { }) pkgs inputs; inherit (import ../default.nix { }) pkgs inputs;
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (lib) mkOption; inherit (lib) mkOption types;
eval = eval =
module: module:
(lib.evalModules { (lib.evalModules {
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
# to be passed to nixops4Deployment
resourceProviderSystem = builtins.currentSystem;
}; };
modules = [ modules = [
module module
./data-model.nix ./data-model.nix
]; ];
}).config; }).config;
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
in in
{ {
_class = "nix-unit";
test-eval = { test-eval = {
expr = expr =
let let
fediversity = eval ( fediversity = eval (
{ config, ... }: { config, ... }:
{ {
_class = "fediversity-settings";
config = { config = {
resources.nixos-configuration = {
description = "An entire NixOS configuration";
request =
{ ... }:
{
_class = "fediversity-resource-request";
options.config = mkOption {
description = "Any options from NixOS";
};
};
policy =
{ config, ... }:
{
_class = "fediversity-resource-policy";
options = {
extra-config = mkOption {
description = "Any options from NixOS";
};
apply = mkOption {
type = with types; functionTo raw;
default = requests: lib.mkMerge (requests ++ [ config.extra-config ]);
};
};
};
};
resources.login-shell = {
_class = "fediversity-resource";
description = "The operator needs to be able to log into the shell";
request =
{ ... }:
{
_class = "fediversity-resource-request";
options = {
wheel = mkOption {
description = "Whether the login user needs root permissions";
type = types.bool;
default = false;
};
packages = mkOption {
description = "Packages that need to be available in the user environment";
type = with types; attrsOf package;
};
};
};
policy =
{ config, ... }:
{
_class = "fediversity-resource-policy";
options = {
username = mkOption {
description = "Username for the operator";
type = types.str; # TODO: use the proper constraints from NixOS
};
wheel = mkOption {
description = "Whether to allow login with root permissions";
type = types.bool;
default = false;
};
apply = mkOption {
type = with types; functionTo raw; # TODO: splice out the user type from NixOS
default =
requests:
let
# Filter out requests that need wheel if policy doesn't allow it
validRequests = lib.filterAttrs (_name: req: !req.wheel || config.wheel) requests;
in
lib.optionalAttrs (validRequests != { }) {
${config.username} = {
isNormalUser = true;
packages = with lib; concatMapAttrs (_name: request: attrValues request.packages) validRequests;
extraGroups = lib.optional config.wheel "wheel";
};
};
};
};
};
};
applications.hello = applications.hello =
{ ... }: { ... }:
{ {
_class = "fediversity-application";
description = ''Command-line tool that will print "Hello, world!" on the terminal''; description = ''Command-line tool that will print "Hello, world!" on the terminal'';
module = module =
{ ... }: { ... }:
{ {
_class = "fediversity-application-config";
options = { options = {
enable = lib.mkEnableOption "Hello in the shell"; enable = lib.mkEnableOption "Hello in the shell";
}; };
@ -38,19 +121,60 @@ in
implementation = implementation =
cfg: cfg:
lib.optionalAttrs cfg.enable { lib.optionalAttrs cfg.enable {
_class = "fediversity-application-requirements";
dummy.login-shell.packages.hello = pkgs.hello; dummy.login-shell.packages.hello = pkgs.hello;
}; };
}; };
environments.single-nixos-vm =
{ config, ... }:
{
_class = "fediversity-environment";
resources.shell.login-shell.username = "operator";
implementation =
{ ... }:
# { providers, ... }:
{
# _class = "nixops4Deployment";
# providers = {
# inherit (inputs.nixops4.modules.nixops4Provider) local;
# };
resources.the-machine = {
_class = "nixops4Resource";
# type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
];
nixos.module =
{ ... }:
{
_class = "nixos";
users.users = config.resources.shell.login-shell.apply (
# lib.filterAttrs (_name: value: value ? login-shell) requests
lib.filterAttrs (_name: value: value ? login-shell) { }
);
};
};
};
};
}; };
options = { options = {
example-configuration = mkOption { example-configuration = mkOption {
type = config.configuration; type = config.configuration;
readOnly = true; readOnly = true;
default = { default = {
_class = "fediversity-configuration";
enable = true; enable = true;
applications.hello.enable = true; applications.hello.enable = true;
}; };
}; };
example-deployment = mkOption {
type = types.submoduleWith {
class = "nixops4Deployment";
modules = [ nixops4Deployment ];
};
readOnly = true;
default = config.environments.single-nixos-vm.deployment config.example-configuration;
};
}; };
} }
); );
@ -59,12 +183,14 @@ in
inherit (fediversity) inherit (fediversity)
example-configuration example-configuration
; ;
has-deployment = lib.isAttrs fediversity.example-deployment.resources.the-machine;
}; };
expected = { expected = {
example-configuration = { example-configuration = {
enable = true; enable = true;
applications.hello.enable = true; applications.hello.enable = true;
}; };
has-deployment = true;
}; };
}; };
} }

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
config, config,
inputs,
... ...
}: }:
let let
@ -9,13 +10,14 @@ let
attrsOf attrsOf
attrTag attrTag
deferredModuleWith deferredModuleWith
submodule submoduleWith
optionType optionType
functionTo functionTo
; ;
functionType = import ./function.nix; functionType = import ./function.nix;
application-resources = { application-requirements = {
_class = "fediversity-application-requirements";
options.resources = mkOption { options.resources = mkOption {
# TODO: maybe transpose, and group the resources by type instead # TODO: maybe transpose, and group the resources by type instead
type = attrsOf ( type = attrsOf (
@ -23,66 +25,174 @@ let
); );
}; };
}; };
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
in in
{ {
_class = "nixops4Deployment"; _class = "fediversity-settings";
options = { options = {
resources = mkOption {
description = "Collection of deployment resources that can be required by applications and policed by hosting providers";
type = attrsOf (submoduleWith {
class = "fediversity-resource";
modules = [
(
{ ... }:
{
options = {
description = mkOption {
description = "Description of the resource to help application module authors and hosting providers to work with it";
type = types.str;
};
request = mkOption {
description = "Options for declaring resource requirements by an application, a description of how the resource is consumed or accessed";
type = deferredModuleWith { staticModules = [ { _class = "fediversity-resource-request"; } ]; };
};
policy = mkOption {
description = "Options for configuring the resource policy for the hosting provider, a description of how the resource is made available";
type = submoduleWith {
class = "fediversity-resource-policy";
modules = [
{
options.apply = mkOption {
description = "Apply the policy to a request";
};
}
];
};
};
};
}
)
];
});
};
applications = mkOption { applications = mkOption {
description = "Collection of Fediversity applications"; description = "Collection of Fediversity applications";
type = attrsOf ( type = attrsOf (submoduleWith {
submodule (application: { class = "fediversity-application";
_class = "fediversity-application"; modules = [
options = { (application: {
description = mkOption { options = {
description = "Description to be shown in the application overview"; description = mkOption {
type = types.str; description = "Description to be shown in the application overview";
}; type = types.str;
module = mkOption { };
description = "Operator-facing configuration options for the application"; module = mkOption {
type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; }; 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"; implementation = mkOption {
type = application.config.config-mapping.function-type; 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"; resources = mkOption {
type = functionTo application.config.config-mapping.output-type; description = "Compute resources required by an application";
readOnly = true; type = functionTo application.config.config-mapping.output-type;
default = input: (application.config.implementation input).output; readOnly = true;
}; default = input: (application.config.implementation input).output;
config-mapping = mkOption { };
description = "Function type for the mapping from application configuration to required resources"; config-mapping = mkOption {
type = submodule functionType; description = "Function type for the mapping from application configuration to required resources";
readOnly = true; type = submoduleWith {
default = { class = "module-function";
input-type = application.config.module; modules = [ functionType ];
output-type = application-resources; };
readOnly = true;
default = {
input-type = application.config.module;
output-type = application-requirements;
};
}; };
}; };
}; })
}) ];
); });
};
environments = mkOption {
description = "Run-time environments for Fediversity applications to be deployed to";
type = attrsOf (submoduleWith {
class = "fediversity-environment";
modules = [
(environment: {
options = {
resources = mkOption {
description = ''
Resources made available by the hosting provider, and their policies.
Setting this is optional, but provides a place to declare that information for programmatic use in the resource mapping.
'';
# TODO: maybe transpose, and group the resources by type instead
type = attrsOf (
attrTag (
lib.mapAttrs (
_name: resource:
mkOption {
type = submoduleWith {
class = "fediversity-resource-policy";
modules = [ resource.policy ];
};
}
) config.resources
)
);
};
implementation = mkOption {
description = "Mapping of resources required by applications to available resources; the result can be deployed";
# type = environment.config.resource-mapping.output-type;
};
resource-mapping = mkOption {
description = "Function type for the mapping from resources to a (NixOps4) deployment";
type = submoduleWith {
class = "module-function";
modules = [ functionType ];
};
readOnly = true;
default = {
input-type = application-requirements;
output-type = nixops4Deployment;
};
};
deployment = mkOption {
description = "Generate a deployment from a configuration";
type = functionTo (submoduleWith {
class = "nixops4Deployment";
modules = [ environment.config.resource-mapping.output-type ];
});
readOnly = true;
default = _cfg: environment.config.implementation;
};
};
})
];
});
}; };
configuration = mkOption { configuration = mkOption {
description = "Configuration type declaring options to be set by operators"; description = "Configuration type declaring options to be set by operators";
type = optionType; type = optionType;
readOnly = true; readOnly = true;
default = submodule { default = submoduleWith {
options = { class = "fediversity-configuration";
enable = lib.mkEnableOption { modules = [
description = "your Fediversity configuration"; {
}; options = {
applications = lib.mapAttrs ( enable = lib.mkEnableOption {
_name: application: description = "your Fediversity configuration";
mkOption { };
description = application.description; applications = lib.mapAttrs (
type = submodule application.module; _name: application:
default = { }; mkOption {
} description = application.description;
) config.applications; type = submoduleWith {
}; class = "fediversity-application-config";
modules = [ application.module ];
};
default = { };
}
) config.applications;
};
}
];
}; };
}; };
}; };

View file

@ -65,8 +65,6 @@ let
cfg = config.deployment; cfg = config.deployment;
in in
{ {
_class = "nixops4Deployment";
options = { options = {
deployment = lib.mkOption { deployment = lib.mkOption {
description = '' description = ''

34
deployment/deployment.nix Normal file
View file

@ -0,0 +1,34 @@
{
lib,
# inputs,
...
}:
# let
# nixops4 = inputs.nixops4.outPath;
# in
# inputs.nixops4.modules.nixops4Deployment.default
# import inputs.nixops4.modules.nixops4Deployment.default
# resources: import inputs.nixops4.modules.nixops4Deployment.default {
# inherit lib config resources;
# # config = {
# # type providers provider inputs outputsSkeleton resourceType
# # };
# }
# {
# imports = [
# "${nixops4}/nix/deployment/providers.nix"
# "${nixops4}/nix/deployment/resources.nix"
# ];
# };
# "${nixops4}/nix/deployment/resources.nix"
{
options.resources = lib.mkOption {
type = lib.types.attrs;
};
}

View file

@ -1,26 +1,7 @@
{ inputs, sources, ... }:
{ {
_class = "flake"; imports = [
./check/basic/flake-part.nix
perSystem = ./check/cli/flake-part.nix
{ pkgs, ... }: ./check/panel/flake-part.nix
{ ];
checks = {
deployment-basic = import ./check/basic {
inherit (pkgs.testers) runNixOSTest;
inherit inputs sources;
};
deployment-cli = import ./check/cli {
inherit (pkgs.testers) runNixOSTest;
inherit inputs sources;
};
deployment-panel = import ./check/panel {
inherit (pkgs.testers) runNixOSTest;
inherit inputs sources;
};
};
};
} }

View file

@ -13,6 +13,7 @@ let
in in
{ {
options = { options = {
_class = "module-function";
input-type = mkOption { input-type = mkOption {
type = deferredModule; type = deferredModule;
}; };

View file

@ -17,8 +17,6 @@ let
inherit (lib) types mkOption; inherit (lib) types mkOption;
in in
{ {
_class = "nixops4Deployment";
options = { options = {
enable = lib.mkEnableOption "Fediversity configuration"; enable = lib.mkEnableOption "Fediversity configuration";
domain = mkOption { domain = mkOption {

121
flake.lock generated
View file

@ -59,6 +59,22 @@
} }
}, },
"flake-compat_2": { "flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1733328505, "lastModified": 1733328505,
@ -74,7 +90,7 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_3": { "flake-compat_4": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1696426674, "lastModified": 1696426674,
@ -127,6 +143,24 @@
} }
}, },
"flake-parts_3": { "flake-parts_3": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_3"
},
"locked": {
"lastModified": 1738453229,
"narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_4": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"nixops4-nixos", "nixops4-nixos",
@ -167,12 +201,32 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks-nix": { "git-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": {
"lastModified": 1742649964,
"narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"git-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore_2",
"nixpkgs": "nixpkgs_2"
},
"locked": { "locked": {
"lastModified": 1737465171, "lastModified": 1737465171,
"narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=",
@ -227,6 +281,27 @@
} }
}, },
"gitignore": { "gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gitignore_2": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixops4-nixos", "nixops4-nixos",
@ -266,8 +341,8 @@
}, },
"nix": { "nix": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_3",
"flake-parts": "flake-parts_3", "flake-parts": "flake-parts_4",
"git-hooks-nix": "git-hooks-nix_2", "git-hooks-nix": "git-hooks-nix_2",
"nixfmt": "nixfmt", "nixfmt": "nixfmt",
"nixpkgs": [ "nixpkgs": [
@ -341,10 +416,10 @@
}, },
"nixops4": { "nixops4": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_3",
"nix": "nix", "nix": "nix",
"nix-cargo-integration": "nix-cargo-integration", "nix-cargo-integration": "nix-cargo-integration",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_3",
"nixpkgs-old": "nixpkgs-old" "nixpkgs-old": "nixpkgs-old"
}, },
"locked": { "locked": {
@ -363,7 +438,7 @@
}, },
"nixops4-nixos": { "nixops4-nixos": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts_2",
"git-hooks-nix": "git-hooks-nix", "git-hooks-nix": "git-hooks-nix",
"nixops4": "nixops4", "nixops4": "nixops4",
"nixops4-nixos": [ "nixops4-nixos": [
@ -445,6 +520,18 @@
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
} }
}, },
"nixpkgs-lib_3": {
"locked": {
"lastModified": 1738452942,
"narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
}
},
"nixpkgs-old": { "nixpkgs-old": {
"locked": { "locked": {
"lastModified": 1735563628, "lastModified": 1735563628,
@ -478,6 +565,22 @@
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1730768919,
"narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1738410390, "lastModified": 1738410390,
"narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=",
@ -518,7 +621,7 @@
}, },
"purescript-overlay": { "purescript-overlay": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_3", "flake-compat": "flake-compat_4",
"nixpkgs": [ "nixpkgs": [
"nixops4-nixos", "nixops4-nixos",
"nixops4", "nixops4",
@ -561,6 +664,8 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"nixops4": [ "nixops4": [
"nixops4-nixos", "nixops4-nixos",
"nixops4" "nixops4"

126
flake.nix
View file

@ -1,52 +1,94 @@
{ {
inputs = { inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks.url = "github:cachix/git-hooks.nix";
nixops4.follows = "nixops4-nixos/nixops4"; nixops4.follows = "nixops4-nixos/nixops4";
nixops4-nixos.url = "github:nixops4/nixops4-nixos"; nixops4-nixos.url = "github:nixops4/nixops4-nixos";
}; };
outputs = outputs =
inputs: inputs@{ self, flake-parts, ... }:
import ./mkFlake.nix inputs ( let
{ inputs, sources, ... }: sources = import ./npins;
inherit (import sources.flake-inputs) import-flake;
inherit (sources) git-hooks agenix;
# XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
# XXX - this is just importing a flake
nixpkgs = import-flake { src = sources.nixpkgs; };
# XXX - this overrides the inputs attached to `self`
inputs' = self.inputs // {
nixpkgs = nixpkgs;
};
self' = self // {
inputs = inputs';
};
in
# XXX - finally we override the overall set of `inputs` -- we need both:
# `flake-parts obtains `nixpkgs` from `self.inputs` and not from `inputs`.
flake-parts.lib.mkFlake
{ {
imports = [ inputs = inputs // {
"${sources.git-hooks}/flake-module.nix" inherit nixpkgs;
inputs.nixops4.modules.flake.default };
self = self';
./deployment/flake-part.nix
./infra/flake-part.nix
./keys/flake-part.nix
./secrets/flake-part.nix
./services/tests/flake-part.nix
];
perSystem =
{
pkgs,
lib,
system,
...
}:
{
checks = {
panel = (import ./. { inherit sources system; }).tests.panel.basic;
};
formatter = pkgs.nixfmt-rfc-style;
pre-commit.settings.hooks =
let
## Add a directory here if pre-commit hooks shouldn't apply to it.
optout = [ "npins" ];
excludes = map (dir: "^${dir}/") optout;
addExcludes = lib.mapAttrs (_: c: c // { inherit excludes; });
in
addExcludes {
nixfmt-rfc-style.enable = true;
deadnix.enable = true;
trim-trailing-whitespace.enable = true;
shellcheck.enable = true;
};
};
} }
); (
{ inputs, ... }:
{
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
imports = [
(import "${git-hooks}/flake-module.nix")
inputs.nixops4.modules.flake.default
./deployment/flake-part.nix
./infra/flake-part.nix
];
perSystem =
{
pkgs,
lib,
inputs',
...
}:
{
formatter = pkgs.nixfmt-rfc-style;
pre-commit.settings.hooks =
let
## Add a directory here if pre-commit hooks shouldn't apply to it.
optout = [ "npins" ];
excludes = map (dir: "^${dir}/") optout;
addExcludes = lib.mapAttrs (_: c: c // { inherit excludes; });
in
addExcludes {
nixfmt-rfc-style.enable = true;
deadnix.enable = true;
trim-trailing-whitespace.enable = true;
shellcheck.enable = true;
};
devShells.default = pkgs.mkShell {
packages = [
pkgs.npins
pkgs.nil
(pkgs.callPackage "${agenix}/pkgs/agenix.nix" { })
pkgs.openssh
pkgs.httpie
pkgs.jq
# exposing this env var as a hack to pass info in from form
(inputs'.nixops4.packages.default.overrideAttrs {
impureEnvVars = [ "DEPLOYMENT" ];
})
];
};
};
}
);
} }

View file

@ -1,13 +1,14 @@
# Infra # Infra
This directory contains the definition of [the VMs](../machines/machines.md) that host our This directory contains the definition of [the VMs](machines.md) that host our
infrastructure. infrastructure.
## Provisioning VMs with an initial configuration ## Provisioning VMs with an initial configuration
> NOTE[Niols]: This is still very manual and clunky. Two things will happen: NOTE[Niols]: This is very manual and clunky. Two things will happen. In the near
> 1. In the near future, I will improve the provisioning script to make this a bit less clunky. future, I will improve the provisioning script to make this a bit less clunky.
> 2. In the far future, NixOps4 will be able to communicate with Proxmox directly and everything will become much cleaner. In the far future, NixOps4 will be able to communicate with Proxmox directly and
everything will become much cleaner.
1. Choose names for your VMs. It is recommended to choose `fediXXX`, with `XXX` 1. Choose names for your VMs. It is recommended to choose `fediXXX`, with `XXX`
above 100. For instance, `fedi117`. above 100. For instance, `fedi117`.
@ -24,7 +25,8 @@ infrastructure.
Those files need to exist during provisioning, but their content matters only Those files need to exist during provisioning, but their content matters only
when updating the machines' configuration. when updating the machines' configuration.
> FIXME: Remove this step by making the provisioning script not fail with the public key does not exist yet. FIXME: Remove this step by making the provisioning script not fail with the
public key does not exist yet.
3. Run the provisioning script: 3. Run the provisioning script:
``` ```
@ -42,7 +44,7 @@ infrastructure.
ssh fedi117.abundos.eu 'sudo cat /etc/ssh/ssh_host_ed25519_key.pub' > keys/systems/fedi117.pub ssh fedi117.abundos.eu 'sudo cat /etc/ssh/ssh_host_ed25519_key.pub' > keys/systems/fedi117.pub
``` ```
> FIXME: Make the provisioning script do that for us. FIXME: Make the provisioning script do that for us.
7. Regenerate the list of machines: 7. Regenerate the list of machines:
``` ```
@ -54,7 +56,7 @@ infrastructure.
just enough for it to boot and be reachable. Go on to the next section to just enough for it to boot and be reachable. Go on to the next section to
update the machine and put an actual configuration. update the machine and put an actual configuration.
> FIXME: Figure out why the full configuration isn't on the machine at this FIXME: Figure out why the full configuration isn't on the machine at this
point and fix it. point and fix it.
## Updating existing VM configurations ## Updating existing VM configurations

View file

@ -5,9 +5,8 @@ let
in in
{ {
_class = "nixos";
imports = [ imports = [
./hardware.nix
./networking.nix ./networking.nix
./users.nix ./users.nix
]; ];
@ -23,9 +22,4 @@ in
nix.extraOptions = '' nix.extraOptions = ''
experimental-features = nix-command flakes experimental-features = nix-command flakes
''; '';
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
} }

View file

@ -1,16 +1,20 @@
{ sources, ... }: { modulesPath, ... }:
{
_class = "nixos";
imports = [ {
"${sources.nixpkgs}/nixos/modules/profiles/qemu-guest.nix" imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
];
boot = { boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
initrd = { initrd = {
availableKernelModules = [ availableKernelModules = [
"ata_piix" "ata_piix"
"uhci_hcd" "uhci_hcd"
"virtio_pci"
"virtio_scsi"
"sd_mod" "sd_mod"
"sr_mod" "sr_mod"
]; ];

View file

@ -1,64 +1,63 @@
{ config, lib, ... }: { config, lib, ... }:
let let
inherit (lib) mkDefault mkIf mkMerge; inherit (lib) mkDefault;
in in
{ {
_class = "nixos";
config = { config = {
services.openssh = { services.openssh = {
enable = true; enable = true;
settings.PasswordAuthentication = false; settings.PasswordAuthentication = false;
}; };
networking = mkMerge [ networking = {
{ hostName = config.fediversityVm.name;
hostName = config.fediversityVm.name; domain = config.fediversityVm.domain;
domain = config.fediversityVm.domain;
## REVIEW: Do we actually need that, considering that we have static IPs? ## REVIEW: Do we actually need that, considering that we have static IPs?
useDHCP = mkDefault true; useDHCP = mkDefault true;
## Disable the default firewall and use nftables instead, with a custom interfaces = {
## Procolix-made ruleset. eth0 = {
firewall.enable = false; ipv4 = {
nftables = { addresses = [
enable = true; {
rulesetFile = ./nftables-ruleset.nft; inherit (config.fediversityVm.ipv4) address prefixLength;
}
];
};
ipv6 = {
addresses = [
{
inherit (config.fediversityVm.ipv6) address prefixLength;
}
];
};
}; };
} };
## IPv4 defaultGateway = {
(mkIf config.fediversityVm.ipv4.enable { address = config.fediversityVm.ipv4.gateway;
interfaces.${config.fediversityVm.ipv4.interface}.ipv4.addresses = [ interface = "eth0";
{ inherit (config.fediversityVm.ipv4) address prefixLength; } };
]; defaultGateway6 = {
defaultGateway = { address = config.fediversityVm.ipv6.gateway;
address = config.fediversityVm.ipv4.gateway; interface = "eth0";
interface = config.fediversityVm.ipv4.interface; };
};
nameservers = [
"95.215.185.6"
"95.215.185.7"
];
})
## IPv6 nameservers = [
(mkIf config.fediversityVm.ipv6.enable { "95.215.185.6"
interfaces.${config.fediversityVm.ipv6.interface}.ipv6.addresses = [ "95.215.185.7"
{ inherit (config.fediversityVm.ipv6) address prefixLength; } "2a00:51c0::5fd7:b906"
]; "2a00:51c0::5fd7:b907"
defaultGateway6 = { ];
address = config.fediversityVm.ipv6.gateway;
interface = config.fediversityVm.ipv6.interface; firewall.enable = false;
}; nftables = {
nameservers = [ enable = true;
"2a00:51c0::5fd7:b906" rulesetFile = ./nftables-ruleset.nft;
"2a00:51c0::5fd7:b907" };
]; };
})
];
}; };
} }

View file

@ -1,13 +1,5 @@
{ {
config,
...
}:
{
_class = "nixos";
users.users = { users.users = {
root.openssh.authorizedKeys.keys = config.users.users.procolix.openssh.authorizedKeys.keys;
procolix = { procolix = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];

View file

@ -6,8 +6,6 @@ let
in in
{ {
# `config` not set and imported from multiple places: no fixed module class
options.fediversityVm = { options.fediversityVm = {
########################################################################## ##########################################################################
@ -91,17 +89,6 @@ in
}; };
ipv4 = { ipv4 = {
enable = mkOption {
default = true;
};
interface = mkOption {
description = ''
The interface that carries the machine's IPv4 network.
'';
default = "eth0";
};
address = mkOption { address = mkOption {
description = '' description = ''
The IP address of the machine, version 4. It will be injected as a The IP address of the machine, version 4. It will be injected as a
@ -127,17 +114,6 @@ in
}; };
ipv6 = { ipv6 = {
enable = mkOption {
default = true;
};
interface = mkOption {
description = ''
The interface that carries the machine's IPv6 network.
'';
default = "eth0";
};
address = mkOption { address = mkOption {
description = '' description = ''
The IP address of the machine, version 6. It will be injected as a The IP address of the machine, version 6. It will be injected as a

View file

@ -2,9 +2,6 @@
inputs, inputs,
lib, lib,
config, config,
sources,
keys,
secrets,
... ...
}: }:
@ -12,11 +9,15 @@ let
inherit (lib) attrValues elem mkDefault; inherit (lib) attrValues elem mkDefault;
inherit (lib.attrsets) concatMapAttrs optionalAttrs; inherit (lib.attrsets) concatMapAttrs optionalAttrs;
inherit (lib.strings) removeSuffix; inherit (lib.strings) removeSuffix;
sources = import ../../npins;
inherit (sources) agenix disko;
secretsPrefix = ../../secrets;
secrets = import (secretsPrefix + "/secrets.nix");
keys = import ../../keys;
in in
{ {
_class = "nixops4Resource";
imports = [ ./options.nix ]; imports = [ ./options.nix ];
fediversityVm.hostPublicKey = mkDefault keys.systems.${config.fediversityVm.name}; fediversityVm.hostPublicKey = mkDefault keys.systems.${config.fediversityVm.name};
@ -33,8 +34,8 @@ in
## should go into the `./nixos` subdirectory. ## should go into the `./nixos` subdirectory.
nixos.module = { nixos.module = {
imports = [ imports = [
"${sources.agenix}/modules/age.nix" (import "${agenix}/modules/age.nix")
"${sources.disko}/module.nix" (import "${disko}/module.nix")
./options.nix ./options.nix
./nixos ./nixos
]; ];
@ -43,23 +44,21 @@ in
## configuration. ## configuration.
fediversityVm = config.fediversityVm; fediversityVm = config.fediversityVm;
## Read all the secrets, filter the ones that are supposed to be readable with ## Read all the secrets, filter the ones that are supposed to be readable
## public key, and create a mapping from `<name>.file` to the absolute path of ## with this host's public key, and add them correctly to the configuration
## the secret's file. ## as `age.secrets.<name>.file`.
age.secrets = concatMapAttrs ( age.secrets = concatMapAttrs (
name: secret: name: secret:
optionalAttrs (elem config.fediversityVm.hostPublicKey secret.publicKeys) { optionalAttrs (elem config.fediversityVm.hostPublicKey secret.publicKeys) ({
${removeSuffix ".age" name}.file = secrets.rootPath + "/${name}"; ${removeSuffix ".age" name}.file = secretsPrefix + "/${name}";
} })
) secrets.mapping; ) secrets;
## FIXME: Remove direct root authentication once the NixOps4 NixOS provider ## FIXME: Remove direct root authentication once the NixOps4 NixOS provider
## supports users with password-less sudo. ## supports users with password-less sudo.
users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors ++ [ users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors ++ [
# allow our panel vm access to the test machines # allow our panel vm access to the test machines
keys.panel keys.panel
# allow continuous deployment access
keys.cd
]; ];
}; };

View file

@ -1,9 +1,6 @@
{ {
inputs, inputs,
lib, lib,
sources,
keys,
secrets,
... ...
}: }:
@ -16,6 +13,7 @@ let
filterAttrs filterAttrs
; ;
inherit (lib.attrsets) genAttrs; inherit (lib.attrsets) genAttrs;
sources = import ../../npins;
## Given a machine's name and whether it is a test VM, make a resource module, ## Given a machine's name and whether it is a test VM, make a resource module,
## except for its missing provider. (Depending on the use of that resource, we ## except for its missing provider. (Depending on the use of that resource, we
@ -24,21 +22,7 @@ let
{ vmName, isTestVm }: { vmName, isTestVm }:
{ {
# TODO(@fricklerhandwerk): this is terrible but IMO we should just ditch flake-parts and have our own data model for how the project is organised internally # TODO(@fricklerhandwerk): this is terrible but IMO we should just ditch flake-parts and have our own data model for how the project is organised internally
_module.args = { _module.args = { inherit inputs; };
inherit
inputs
keys
secrets
;
};
nixos.module.imports = [
./common/proxmox-qemu-vm.nix
];
nixos.specialArgs = {
inherit sources;
};
imports = imports =
[ [
@ -51,7 +35,7 @@ let
{ {
nixos.module.users.users.root.openssh.authorizedKeys.keys = [ nixos.module.users.users.root.openssh.authorizedKeys.keys = [
# allow our panel vm access to the test machines # allow our panel vm access to the test machines
keys.panel (import ../keys).panel
]; ];
} }
] ]
@ -69,33 +53,17 @@ let
vmNames: vmNames:
{ providers, ... }: { providers, ... }:
{ {
# XXX: this type merge is for adding `specialArgs` to resource modules providers.local = inputs.nixops4.modules.nixops4Provider.local;
options.resources = mkOption { resources = genAttrs vmNames (vmName: {
type = type = providers.local.exec;
with lib.types; imports = [
lazyAttrsOf (submoduleWith { inputs.nixops4-nixos.modules.nixops4Resource.nixos
class = "nixops4Resource"; (makeResourceModule {
modules = [ ]; inherit vmName;
# TODO(@fricklerhandwerk): we may want to pass through all of `specialArgs` isTestVm = false;
# once we're sure it's sane. leaving it here for better control during refactoring. })
specialArgs = { ];
inherit sources; });
};
});
};
config = {
providers.local = inputs.nixops4.modules.nixops4Provider.local;
resources = genAttrs vmNames (vmName: {
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
(makeResourceModule {
inherit vmName;
isTestVm = false;
})
];
});
};
}; };
makeDeployment' = vmName: makeDeployment [ vmName ]; makeDeployment' = vmName: makeDeployment [ vmName ];
@ -187,8 +155,6 @@ let
in in
{ {
_class = "flake";
## - Each normal or test machine gets a NixOS configuration. ## - Each normal or test machine gets a NixOS configuration.
## - Each normal or test machine gets a VM options entry. ## - Each normal or test machine gets a VM options entry.
## - Each normal machine gets a deployment. ## - Each normal machine gets a deployment.

View file

@ -15,6 +15,7 @@ let
installer = installer =
{ {
config,
pkgs, pkgs,
lib, lib,
... ...

View file

@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMlsYTtMx3hFO8B5B8iHaXL2JKj9izHeC+/AMhIWXBPs cd-age

View file

@ -35,5 +35,4 @@ in
contributors = collectKeys ./contributors; contributors = collectKeys ./contributors;
systems = collectKeys ./systems; systems = collectKeys ./systems;
panel = removeTrailingWhitespace (readFile ./panel-ssh-key.pub); panel = removeTrailingWhitespace (readFile ./panel-ssh-key.pub);
cd = removeTrailingWhitespace (readFile ./cd-ssh-key.pub);
} }

View file

@ -1,5 +0,0 @@
{
_class = "flake";
_module.args.keys = import ./.;
}

View file

@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFXQW5fxJoNY9wtTMsNExgbAbvyljIRGBLjY+USh/0A

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 200; vmId = 200;
proxmox = "fediversity"; proxmox = "fediversity";
@ -16,10 +14,4 @@
gateway = "2a00:51c0:13:1305::1"; gateway = "2a00:51c0:13:1305::1";
}; };
}; };
nixos.module = {
imports = [
../../../infra/common/proxmox-qemu-vm.nix
];
};
} }

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 201; vmId = 201;
proxmox = "fediversity"; proxmox = "fediversity";
@ -19,7 +17,6 @@
nixos.module = { nixos.module = {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./fedipanel.nix ./fedipanel.nix
]; ];
}; };

View file

@ -1,17 +1,13 @@
{ {
config, config,
sources,
... ...
}: }:
let let
name = "panel"; name = "panel";
in in
{ {
_class = "nixos";
imports = [ imports = [
(import ../../../panel { }).module (import ../../../panel { }).module
"${sources.home-manager}/nixos"
]; ];
security.acme = { security.acme = {

View file

@ -1,70 +0,0 @@
{ lib, ... }:
let
inherit (lib) mkDefault mkForce;
in
{
_class = "nixops4Resource";
# NOTE: This needs an SSH config entry `forgejo-ci` to locate and access the
# machine. This is because different people access the machine in different
# way (eg. via a proxy vs. via Procolix's VPN). This might look like:
#
# Host forgejo-ci
# HostName 45.142.234.216
# HostKeyAlias forgejo-ci
#
# The `HostKeyAlias` statement is crucial. Without it, deployment will fail
# with the SSH error “Host key verification failed”.
ssh.host = mkForce "forgejo-ci";
fediversityVm = {
domain = "procolix.com";
ipv4 = {
interface = "enp1s0f0";
address = "192.168.201.65";
prefixLength = 24;
gateway = "192.168.201.1";
};
ipv6.enable = false;
};
nixos.module =
{ config, ... }:
{
_class = "nixos";
imports = [
./forgejo-actions-runner.nix
];
hardware.cpu.intel.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
networking = {
nftables.enable = mkForce false;
hostId = "1d6ea552";
};
## NOTE: This is a physical machine, so is not covered by disko
fileSystems."/" = lib.mkForce {
device = "rpool/root";
fsType = "zfs";
};
fileSystems."/home" = {
device = "rpool/home";
fsType = "zfs";
};
fileSystems."/boot" = lib.mkForce {
device = "/dev/disk/by-uuid/50B2-DD3F";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
};
}

View file

@ -1,47 +0,0 @@
{ pkgs, config, ... }:
{
_class = "nixos";
services.gitea-actions-runner = {
package = pkgs.forgejo-actions-runner;
instances.default = {
enable = true;
name = config.networking.fqdn;
url = "https://git.fediversity.eu";
tokenFile = config.age.secrets.forgejo-runner-token.path;
settings = {
log.level = "info";
runner = {
file = ".runner";
# Take only 1 job at a time to avoid clashing NixOS tests, see #362
capacity = 1;
timeout = "3h";
insecure = false;
fetch_timeout = "5s";
fetch_interval = "2s";
};
};
## This runner supports Docker (with a default Ubuntu image) and native
## modes. In native mode, it contains a few default packages.
labels = [
"docker:docker://node:16-bullseye"
"native:host"
];
hostPackages = with pkgs; [
bash
git
nix
nodejs
];
};
};
## For the Docker mode of the runner.
virtualisation.docker.enable = true;
}

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 2116; vmId = 2116;
proxmox = "procolix"; proxmox = "procolix";
@ -14,7 +12,6 @@
{ lib, ... }: { lib, ... }:
{ {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./forgejo.nix ./forgejo.nix
]; ];

View file

@ -5,8 +5,6 @@ let
in in
{ {
_class = "nixos";
services.forgejo = { services.forgejo = {
enable = true; enable = true;

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 2187; vmId = 2187;
proxmox = "procolix"; proxmox = "procolix";
@ -14,7 +12,6 @@
{ lib, ... }: { lib, ... }:
{ {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./wiki.nix ./wiki.nix
]; ];

View file

@ -1,8 +1,6 @@
{ config, ... }: { config, ... }:
{ {
_class = "nixos";
services.phpfpm.pools.mediawiki.phpOptions = '' services.phpfpm.pools.mediawiki.phpOptions = ''
upload_max_filesize = 1024M; upload_max_filesize = 1024M;
post_max_size = 1024M; post_max_size = 1024M;

View file

@ -7,10 +7,9 @@ Currently, this repository keeps track of the following VMs:
Machine | Proxmox | Description Machine | Proxmox | Description
--------|---------|------------- --------|---------|-------------
[`fedi200`](./dev/fedi200) | fediversity | Testing machine for Hans [`fedi200`](./fedi200) | fediversity | Testing machine for Hans
[`fedi201`](./dev/fedi201) | fediversity | FediPanel [`fedi201`](./fedi201) | fediversity | FediPanel
[`vm02116`](./dev/vm02116) | procolix | Forgejo [`vm02116`](./vm02116) | procolix | Forgejo
[`vm02187`](./dev/vm02187) | procolix | Wiki [`vm02187`](./vm02187) | procolix | Wiki
| `forgejo-ci` | n/a (physical) | Forgejo actions runner |
This table excludes all machines with names starting with `test`. This table excludes all machines with names starting with `test`.

View file

@ -32,12 +32,11 @@ for machine in $(echo "$vmOptions" | jq -r 'keys[]'); do
description=$(echo "$vmOptions" | jq -r ".$machine.description" | head -n 1) description=$(echo "$vmOptions" | jq -r ".$machine.description" | head -n 1)
# shellcheck disable=SC2016 # shellcheck disable=SC2016
printf '[`%s`](./dev/%s) | %s | %s\n' "$machine" "$machine" "$proxmox" "$description" printf '[`%s`](./%s) | %s | %s\n' "$machine" "$machine" "$proxmox" "$description"
fi fi
done done
cat <<\EOF cat <<\EOF
| `forgejo-ci` | n/a (physical) | Forgejo actions runner |
This table excludes all machines with names starting with `test`. This table excludes all machines with names starting with `test`.
EOF EOF

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7001; vmId = 7001;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7002; vmId = 7002;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7003; vmId = 7003;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7004; vmId = 7004;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7005; vmId = 7005;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7006; vmId = 7006;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7011; vmId = 7011;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7012; vmId = 7012;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7013; vmId = 7013;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,6 +1,4 @@
{ {
_class = "nixops4Resource";
fediversityVm = { fediversityVm = {
vmId = 7014; vmId = 7014;
proxmox = "fediversity"; proxmox = "fediversity";

View file

@ -1,54 +0,0 @@
## This file contains a tweak of flake-parts's `mkFlake` function to splice in
## sources taken from npins.
## NOTE: Much of the logic in this file feels like it should be not super
## specific to fediversity. Could it make sense to extract the core of this to
## another place it feels closer to in spirit, such as @fricklerhandwerk's
## flake-inputs (which this code already depends on anyway, and which already
## contained two distinct helpers for migrating away from flakes)? cf
## https://git.fediversity.eu/Fediversity/Fediversity/pulls/447#issuecomment-8671
inputs@{ self, ... }:
let
sources = import ./npins;
inherit (import sources.flake-inputs) import-flake;
# XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
# XXX - this is just importing a flake
nixpkgs = import-flake { src = sources.nixpkgs; };
# XXX - this overrides the inputs attached to `self`
inputs' = self.inputs // {
nixpkgs = nixpkgs;
};
self' = self // {
inputs = inputs';
};
flake-parts-lib = import "${sources.flake-parts}/lib.nix" { inherit (nixpkgs) lib; };
in
flakeModule:
flake-parts-lib.mkFlake
{
# XXX - finally we override the overall set of `inputs` -- we need both:
# `flake-parts obtains `nixpkgs` from `self.inputs` and not from `inputs`.
inputs = inputs // {
inherit nixpkgs;
};
self = self';
specialArgs = {
inherit sources;
};
}
{
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
imports = [ flakeModule ];
}

View file

@ -96,19 +96,6 @@
"url": "https://github.com/hercules-ci/gitignore.nix/archive/637db329424fd7e46cf4185293b9cc8c88c95394.tar.gz", "url": "https://github.com/hercules-ci/gitignore.nix/archive/637db329424fd7e46cf4185293b9cc8c88c95394.tar.gz",
"hash": "02wxkdpbhlm3yk5mhkhsp3kwakc16xpmsf2baw57nz1dg459qv8w" "hash": "02wxkdpbhlm3yk5mhkhsp3kwakc16xpmsf2baw57nz1dg459qv8w"
}, },
"home-manager": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "nix-community",
"repo": "home-manager"
},
"branch": "master",
"submodules": false,
"revision": "863842639722dd12ae9e37ca83bcb61a63b36f6c",
"url": "https://github.com/nix-community/home-manager/archive/863842639722dd12ae9e37ca83bcb61a63b36f6c.tar.gz",
"hash": "0rw9n8d4v87pzlmw7ws15f0sldb51fd9528skpbzmrzl4pinsgij"
},
"htmx": { "htmx": {
"type": "GitRelease", "type": "GitRelease",
"repository": { "repository": {

View file

@ -22,12 +22,12 @@ in
manage manage
# NixOps4 and its dependencies # NixOps4 and its dependencies
pkgs.nixops4 # FIXME: grab NixOps4 and add it here
pkgs.nix pkgs.nix
pkgs.openssh pkgs.openssh
]; ];
env = { env = {
DEPLOYMENT_FLAKE = toString ../.; DEPLOYMENT_FLAKE = ../.;
DEPLOYMENT_NAME = "test"; DEPLOYMENT_NAME = "test";
NPINS_DIRECTORY = toString ../npins; NPINS_DIRECTORY = toString ../npins;
CREDENTIALS_DIRECTORY = toString ./.credentials; CREDENTIALS_DIRECTORY = toString ./.credentials;
@ -45,7 +45,7 @@ in
''; '';
}; };
module = ./nix/configuration.nix; module = import ./nix/configuration.nix;
tests = pkgs.callPackage ./nix/tests.nix { }; tests = pkgs.callPackage ./nix/tests.nix { };
# re-export inputs so they can be overridden granularly # re-export inputs so they can be overridden granularly

View file

@ -76,8 +76,6 @@ in
# https://git.dgnum.eu/mdebray/djangonix/ # https://git.dgnum.eu/mdebray/djangonix/
# unlicensed at the time of writing, but surely worth taking some inspiration from... # unlicensed at the time of writing, but surely worth taking some inspiration from...
{ {
_class = "nixos";
options.services.${name} = { options.services.${name} = {
enable = mkEnableOption "Service configuration for `${name}`"; enable = mkEnableOption "Service configuration for `${name}`";
production = mkOption { production = mkOption {
@ -147,7 +145,6 @@ in
NixOps4 from the package's npins-based code, we will have to do with NixOps4 from the package's npins-based code, we will have to do with
this workaround. this workaround.
''; '';
default = pkgs.nixops4;
}; };
deployment = { deployment = {
@ -202,8 +199,11 @@ in
}; };
}; };
# needed to place a config file with home-manager users.users.${name} = {
users.users.${name}.isNormalUser = true; # TODO[Niols]: change to system user or document why we specifically
# need a normal user.
isNormalUser = true;
};
users.groups.${name} = { }; users.groups.${name} = { };
systemd.services.${name} = { systemd.services.${name} = {

View file

@ -8,17 +8,4 @@ let
in in
{ {
python3 = prev.lib.attrsets.recursiveUpdate prev.python3 { pkgs = extraPython3Packages; }; python3 = prev.lib.attrsets.recursiveUpdate prev.python3 { pkgs = extraPython3Packages; };
nixops4 =
let
sources = import ../../npins;
inherit (import sources.flake-inputs) import-flake;
inherit
(import-flake {
src = ../../.;
})
inputs
;
inherit (inputs) nixops4;
in
nixops4.packages.${prev.system}.default;
} }

View file

@ -60,8 +60,6 @@ let
]; ];
in in
python3.pkgs.buildPythonPackage { python3.pkgs.buildPythonPackage {
_class = "package";
pname = name; pname = name;
inherit (pyproject.project) version; inherit (pyproject.project) version;
pyproject = true; pyproject = true;

View file

@ -8,8 +8,6 @@
}: }:
buildPythonPackage rec { buildPythonPackage rec {
_class = "package";
pname = "django-pydantic-field"; pname = "django-pydantic-field";
version = "v0.3.12"; version = "v0.3.12";
pyproject = true; pyproject = true;

View file

@ -10,8 +10,6 @@
}: }:
buildPythonPackage rec { buildPythonPackage rec {
_class = "package";
pname = "drf-pydantic"; pname = "drf-pydantic";
version = "v2.7.1"; version = "v2.7.1";
pyproject = true; pyproject = true;

View file

@ -13,6 +13,7 @@ let
secrets = { secrets = {
SECRET_KEY = pkgs.writeText "SECRET_KEY" "secret"; SECRET_KEY = pkgs.writeText "SECRET_KEY" "secret";
}; };
nixops4Package = pkgs.hello; # FIXME: actually pass NixOps4
}; };
virtualisation = { virtualisation = {

View file

@ -1,4 +0,0 @@
{
mapping = import ./secrets.nix;
rootPath = ./.;
}

View file

@ -1,5 +0,0 @@
{
_class = "flake";
_module.args.secrets = import ./.;
}

View file

@ -1,19 +1,17 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 Jpc21A bBCQmvfRUwJuIXbpVJ092XUBVszGrb6gILGbgV9j9BY -> ssh-ed25519 Jpc21A 9edPaA2tT4SeYNTPzF0E157daC2o+JH/WQQCT+vLbFg
7DEGwhqdfqMs5cxXtlMkSTPjw4qhczBgW0dmoJ6dh6g C48EtLdhB75TTzfEZTw1DypicHiVlSmFzjfbqfO9N/8
-> ssh-ed25519 BAs8QA oiVedFC6UklEFCJUybGr93+XrddyCtV4r4TnE4nhpWI -> ssh-ed25519 BAs8QA T+kXpZg1v0XRkub5DWir7vYwO7KaOJLZBNYxxXiBUCw
xasnkP4NCl9TuYSE1u0Xi0b/PiwcrfHCz2QMnpTjLcU zBRwMTDpyI7twEwUGsmJYyYPw9btBx5Kakj1yT+XY8U
-> ssh-ed25519 ofQnlg LrMcWdaEUVyIgd/KznwJW/2sucIu5MuxDEcEJAmf8mA -> ssh-ed25519 ofQnlg 4UoEDY/tdKz8LrX1BkBU1/cn+vSaYLUl7xX9YmzANBY
p6pQoisuXre2J4r6ArV6C6lKO2J/aNdBFhqLPBoZ2wA 8CACq1n3AJgD9IyPN23iRvThqsfQFF5+jmkKnhun24U
-> ssh-ed25519 COspvA q2OGeVofPKyGCpr4Mf9VoaRvZCWTRl8n2mvkQOdTnyQ -> ssh-ed25519 COspvA HxcbkqHL+LpVmwb+Fo5JuUU+C+Pxzdxtb0yZHixwuzM
M+ffAGecJG/94k/Z5DdokltrZppS2IcxkZa8JKHwIMs 7FIhxdbjHJlgQQgjrHHUK5cecqs5aT7X3I8TWf8c2gc
-> ssh-ed25519 2XrTgw Bsz/G4QderToPSfMKOR6s5yWb0xCGUlsjGJxJYQNBRc -> ssh-ed25519 2XrTgw R6Ia8MVIZKPnNZ0rspZ34EqoY8fOLeB9H7vnvNBLg1g
JYrXZb8qj1Yi9u5bnI/WzuNxy7gyFLCTIUaGNmcOYnk 55NUqz5Yygt6FKJ3bR5iHxQp8G7S2gyFwrJNX1Pb/2Y
-> ssh-ed25519 awJeHA KKJMQSt0PvC6P+T/kxQv96tSBdLQLiY2f8q35IwGm28 -> ssh-ed25519 awJeHA hJdTuAScoewVMt7HWiisSkL0zSeClFzYzzKL84G893o
p7Cf2HLlPl0qmsO6Hh5zwVgKkEs3A6fdSBndMKsacbk ou780VLrW1s4d6L+lEVu3kXaGn4dvtFPA31supwEL50
-> ssh-ed25519 Fa25Dw 3m/qyannP4gjXxkUuO0LQRU8Z8HXOg4WReMDd7786y8 -> ssh-ed25519 Fa25Dw mJcqnXA3fQeoKrG7RJ7nVeLxPvrxqbj+lJdx6jQ9IR8
dNMyiBGeJDrBScE9TEyZZ7+MGMG6FLuoRTK82EVeX1w f5Q7mrQSSDsm1Z/uSAnvx66mgnRC3XaBLQrVL9f/Ijs
-> ssh-ed25519 i+ecmQ oCs4Ep2K75yjmUOh1ox4F25tGq+O/mZ2/c2E8+IRlEc --- W/KmboXTLV12X6WtVQKHNe+ZHvS2q9EHUZwofSgJSE8
0Wc9gDxhvHK5tEVM5kJ0mQXc3kp7tJ2JNHg54N0+tJ8 ^kûÚ h©0ÔkÇ ¢¸_Ç·ûQÞm7\òÖ}÷Áë?½qø<ÿm
--- mXrqbcHxjjkS5MrQaCVm4hTsAUEENAWlIYtiYx6rtas
ž`€úì}öÙ7Ù>­iŒbàéëÕè/& ɪŠwŽ„ì7àí[ã±Hˆc“

Binary file not shown.

View file

@ -1,19 +1,15 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 Jpc21A gkSA9BJIPUm4iQdvK8OzozIPomCha7BObc7PBpwSBhc -> ssh-ed25519 Jpc21A N/T7HaInZ13IlJfzeli5nRz5pdBQETO6D1P8X42IHRw
QsxIoX8KXbTQPwHcANNotxje8eI51h4NmnMpcOBW2Rk q431ZtsodQ9NgcWTjmS0Kx4ATwVFp2nkm+MHe7aXTZU
-> ssh-ed25519 BAs8QA 909RuMasqJSYIDWxUf282xkp6vIrmouv/UbGFLw2WXw -> ssh-ed25519 BAs8QA +VUHgmz2oNG6L1FgZy3uGVMs6qUGirFHK8Ts2ghNLHs
a7gid67fIVfuRfLsKJPb9f0oH0ZsZsfahJqD22z5Aco sjQu78xqM6KLmRiYd2o2uK/PjYLnyZihzVoCV7qKBX4
-> ssh-ed25519 ofQnlg Lx2N7tSXh6eOwcXWDiU27W4D2NEH6xj3W0t72hkNBG8 -> ssh-ed25519 ofQnlg cBfd95Ir33ggt1J1P2TkFRULr2uYPVuyrQ5XpjBxEW0
O4/RVwxUSgXgLEMBpmaJ3H49qXulSB5EebpHakcN1rA TWFVHboXr95cFm5yjQ7gn7hjbSmVBfB/9dldsoga/9Q
-> ssh-ed25519 COspvA zQ855/8dQm+r2/GnoEFwy7ls3UDaVVaL988Rnsgs5Fs -> ssh-ed25519 COspvA RMW9FlDmiQUu7cg0fKir55VqrDRCoYVVZMOcMHyrMj8
gl/sC2jLUCDQfsIOy6G67XObfW/io/JwCKBaqTgpzXk qeXkWdKFJN7APgYh7AjyJLeQI2CAEaGAcXiVaBaOJwY
-> ssh-ed25519 2XrTgw ic13iHGBiNgco5PemRhzKNGdVILW0d6DpW1f/SvizSg -> ssh-ed25519 2XrTgw BRobowRWZ9giVL2dFyGvzzF7gyWUQd1ounMQBtsM/lM
D72w8Dgott/agkWJrybDbxBKJ3NKi7Xz2N6YO0nrTa8 dFyli2skTgzVWGVolLG2GuGNh/Xu3IaJsznOkcWqKGc
-> ssh-ed25519 awJeHA 143iH2pm6z9AF8fqdRbcw3c5+crLkk3HH0+wEZelu0A -> ssh-ed25519 awJeHA Cu7fiv+SL71oho/xoJMw/Lztf4WkNKmImVS/8xyLiTo
j6gK7R7AnI8JzWy7+3Wm00vmaU9/Th2BtNWs90q2r0k 3sB/t0squi1crjHFBaN6btrvGUeWaKfmGa7yxREvy2o
-> ssh-ed25519 8FIE3Q jL6tkwWOvL82zFr+kmyX3WNlFMOLsJav4Rpy7A66Hx4 --- SqPDTJ/XV26nNG1ib5phNNRdQi5+Wk0cxhqUr1ygjGw
gE8+tgytH+y8HTKbeBsQeKKnqfmvl5O38diRsjipTDc Æt”OÊá<C3A1>âåYöª¶^´×U<C397>j†ë!Y.<2E>^<5E>}Xúôæ¡3¿ÖŽ"kE×í šú¾s¥,0l+¾ýn‡;fW®
-> ssh-ed25519 i+ecmQ AukyGGsUOnTj/h7sxxrldeskrMC2Wn4UL+E+HBIs9R0
S2EwHq05mSOqTAih7nkj31NU9GitxMdSm+/BlLOQsis
--- jW2fMlcUYlscw0dAkR5T+yfilTWOiODJmuqzFypcjUU
õ˜µ 0Ïfø‰œ]Á€âXøè:HœPZðGk<47>ÜþÊÕxmÿÀ©KP$z<>ŒŸð¯ÃRCš5Üå˜FH\ A 2Z&ì—Óð±¯lü`p

Binary file not shown.

Binary file not shown.

View file

@ -7,12 +7,11 @@ let
keys = import ../keys; keys = import ../keys;
contributors = attrValues keys.contributors; contributors = attrValues keys.contributors;
cd = [ keys.cd ];
in in
concatMapAttrs concatMapAttrs
(name: systems: { (name: systems: {
"${name}.age".publicKeys = contributors ++ systems ++ cd; "${name}.age".publicKeys = contributors ++ systems;
}) })
( (
@ -27,7 +26,7 @@ concatMapAttrs
{ {
forgejo-database-password = [ vm02116 ]; forgejo-database-password = [ vm02116 ];
forgejo-email-password = [ vm02116 ]; forgejo-email-password = [ vm02116 ];
forgejo-runner-token = [ forgejo-ci ]; forgejo-runner-token = [ ];
panel-secret-key = [ fedi201 ]; panel-secret-key = [ fedi201 ];
panel-ssh-key = [ fedi201 ]; panel-ssh-key = [ fedi201 ];
wiki-basicauth-htpasswd = [ vm02187 ]; wiki-basicauth-htpasswd = [ vm02187 ];

View file

@ -1,19 +1,18 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 Jpc21A NStZFZPTHMhVCnQ5Zkbl39vWztrxfsSXok24/e8H7QQ -> ssh-ed25519 Jpc21A EuMYAiZX+4A12eu19mIY7u+WYF7NJ9qJosQSVlxR6n8
JjHP6Cus76PGYYxpbnc2cSZ79zvdD8LISYDPbvXsnqU bK5CMXAmP23t1p9bgmqoVg4Qcu2qYKGc4t36v8e9eow
-> ssh-ed25519 BAs8QA iocHfHjWlEUsbtibqEbYDceAqURr2vjxuYapqon9hyU -> ssh-ed25519 BAs8QA IwRyitDNTzUPzQAUbDNEKjFiF8WPD/OyztOZQeoTEzw
ljL+olZdhWtHeV3uh3pOu22+sY13wPn2vKQDduPSqVs OwiTWvk4NmUgExav0uH6HlThDNU5hsKXfR6KHsFOV3I
-> ssh-ed25519 ofQnlg 9YVfMKyoP3+xtzg/ok2I9yf3YdIYoBpUJa/3d2N/8lI -> ssh-ed25519 ofQnlg 3TcMbLX1JsQL8+Gqy7IFZwykZr2BspvPCuZT1SHtnQQ
2yUalyj7O3c1YDA2xTb9QNYrFBDHwcyGBX3mydv0ifI Ci5OeBj2aiC8ut9jIEUMt3qfYH+cJrnVud6AH54Ndn8
-> ssh-ed25519 COspvA cOSNsZXBbhQ/B49fq3KwcY6siVrTz48doTrta/0d/Hw -> ssh-ed25519 COspvA 0t9f3Wu3ILv4QTJhwT619y+7XFrryCLbpIZC6aE+qQI
jcRtVxA/tVFM9btPAPI6zKk8BwAVlaQlvHC203MpmIQ oPQP48F6oO/tkqLZDdjkGtIap7KHiAknbpTNL6/yLaU
-> ssh-ed25519 2XrTgw d3EKtYkxjeJZ8kt3ofIklGmRwUCgTIB/WVVlvxggGRk -> ssh-ed25519 2XrTgw YOZsaYQH9vMH0QqSXGh8GyhRV4MbcBGPFfFaKpo3Ckk
IhcrpWN9xFsKRw9iCfYMONPOU7TpTt4kTBNwMDtk7zo kUShJbADA+6bpx2adxvzlI/0jSM5bIBfZfdSE/7Vm5Y
-> ssh-ed25519 awJeHA Ei64e3+FJDM6S8NP+YfEWEg9t72qTXZ0IdZE8dYQPm4 -> ssh-ed25519 awJeHA dF3m0hQWX9c0EezDr56Kt/F4d1Uim7NwvIX6zRws0Eo
ggRc86sXin06eXJkLbK8CdJFDa1237WMfSgwNd5ngmM pst243yrARODwrnyz8cJAzgDxdPOUsRbs7yPZePABFs
-> ssh-ed25519 dgBsjw 9etK6tNrFlWVAKTz5U0TitkiGYLKTad3QiRWVpLPrwM -> ssh-ed25519 dgBsjw PUYHcP/tgNnKyvlIoJRcNcW3zabVV1iHXIWfKqgW9xc
xHLzFnRtcvpVZYZrxWz5q4uadhHrHVlfqjteOWfIccE tXNjSuVH/g/oN5o75FPkFFpviF7SeFSN9kbqURvgMDE
-> ssh-ed25519 i+ecmQ SDTnYBLMOaH173B/wqaOifE6a90gSesRqMHmX7/iZFk --- wHgBAN9c6F6T5hFJGo8uH8zqDkQDwx3/jVNKUtQ3arE
kS9tuKnMXCXNUnoZ06DisOOyZHe/mZl4a0JRA+eynE8 «Ñ¢Á
--- C0R5WxDDCqQGxyvFoeNX838az0bjp55PGh//1NFG4LE ò@µú¡fÃ`m;ÕcæäU²€ùò£Íd…eSèyfv¿»¡€J?ø `œfj£Äa}lÃó ¿Úxç²BÇt2èfìôm08ÓoÝtRál9˜èx¤¢ŒÅžæ÷
ŠÉY—±³<EFBFBD>„ÏKRÇËej±éŒ7xÑí Óì¾7jÏ-œJý«[ÀF?Ÿ=-wXMC~)èŃ<E280BA>Éõb«ëƒCÜ4ÌÖÞOwý~¿š8ñv—ÙÜžèX»ØÆƒí!5¦

Binary file not shown.

Binary file not shown.

View file

@ -21,11 +21,11 @@ For those that know it, we could say that the current module is an analogous of
## Content of this directory ## Content of this directory
- [fediversity](./fediversity) contains the definition of the services. Look in - [fediversity][./fediversity] contains the definition of the services. Look in
particular at its `default.nix` that contains the definition of the options. particular at its `default.nix` that contains the definition of the options.
- [vm](./vm) contains options specific to making the service run in local QEMU - [vm][./vm] contains options specific to making the service run in local QEMU
VMs. These modules will for instance override the defaults to disable SSL, and VMs. These modules will for instance override the defaults to disable SSL, and
they will add virtualisation options to forward ports, for instance. they will add virtualisation options to forward ports, for instance.
- [tests](./tests) contain full NixOS tests of the services. - [tests][./tests] contain full NixOS tests of the services.

13
services/default.nix Normal file
View file

@ -0,0 +1,13 @@
{
system ? builtins.currentSystem,
sources ? import ../npins,
pkgs ? import sources.nixpkgs { inherit system; },
...
}:
{
tests = {
mastodon = pkgs.nixosTest ./tests/mastodon.nix;
pixelfed-garage = pkgs.nixosTest ./tests/pixelfed-garage.nix;
peertube = pkgs.nixosTest ./tests/peertube.nix;
};
}

View file

@ -6,8 +6,6 @@ let
in in
{ {
_class = "nixos";
imports = [ imports = [
./garage ./garage
./mastodon ./mastodon
@ -49,7 +47,7 @@ in
displayName = mkOption { displayName = mkOption {
type = types.str; type = types.str;
description = "Name of the initial user, for humans"; description = "Name of the initial user, for humans";
default = config.fediversity.temp.initialUser.username; default = config.fediversity.temp.initialUser.name;
}; };
email = mkOption { email = mkOption {
type = types.str; type = types.str;
@ -65,16 +63,4 @@ in
}; };
}; };
}; };
config = {
## FIXME: This should clearly go somewhere else; and we should have a
## `staging` vs. `production` setting somewhere.
security.acme = {
acceptTerms = true;
# 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";
};
};
} }

View file

@ -97,8 +97,6 @@ let
in in
{ {
_class = "nixos";
imports = [ ./options.nix ]; imports = [ ./options.nix ];
config = mkIf config.fediversity.garage.enable { config = mkIf config.fediversity.garage.enable {

View file

@ -5,8 +5,6 @@ let
in in
{ {
_class = "nixos";
options.fediversity.garage = { options.fediversity.garage = {
enable = mkEnableOption "Enable a Garage server on the machine"; enable = mkEnableOption "Enable a Garage server on the machine";

View file

@ -11,8 +11,6 @@ let
in in
{ {
_class = "nixos";
imports = [ ./options.nix ]; imports = [ ./options.nix ];
config = mkMerge [ config = mkMerge [

View file

@ -1,8 +1,6 @@
{ config, lib, ... }: { config, lib, ... }:
{ {
_class = "nixos";
options.fediversity.mastodon = options.fediversity.mastodon =
(import ../sharedOptions.nix { (import ../sharedOptions.nix {
inherit config lib; inherit config lib;

View file

@ -5,8 +5,6 @@ let
in in
{ {
_class = "nixos";
imports = [ ./options.nix ]; imports = [ ./options.nix ];
config = mkMerge [ config = mkMerge [

View file

@ -6,8 +6,6 @@ let
in in
{ {
_class = "nixos";
options.fediversity.peertube = options.fediversity.peertube =
(import ../sharedOptions.nix { (import ../sharedOptions.nix {
inherit config lib; inherit config lib;

View file

@ -15,8 +15,6 @@ let
in in
{ {
_class = "nixos";
imports = [ ./options.nix ]; imports = [ ./options.nix ];
config = mkMerge [ config = mkMerge [

Some files were not shown because too many files have changed in this diff Show more