Compare commits

...

13 commits

Author SHA1 Message Date
3e8c0c7738
runs-on: docker 2025-07-02 18:47:35 +02:00
6143e4545b
rm runner file 2025-07-02 18:47:35 +02:00
d062c5a21b
explicitly specify container image 2025-07-02 18:47:35 +02:00
abf62856d7
add label for new runner 2025-07-02 18:47:35 +02:00
14600ee06e
try out existing nix container made for gitea actions 2025-07-02 18:47:35 +02:00
0c53b55106
Switch all CI jobs to nixos label 2025-07-02 18:47:35 +02:00
13c92280ab Clean up lib in forgejo-ci and extend on the .ssh/config comment (#428)
Reviewed-on: Fediversity/Fediversity#428
Reviewed-by: kiara Grouwstra <kiara@procolix.eu>
Co-authored-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
Co-committed-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
2025-07-02 17:49:44 +02:00
871672d447 Add forgejo-ci machine to our infrastructure (#389)
picked up from https://git.fediversity.eu/Fediversity/Fediversity/compare/main...niols:forgejo-ci.

closes #356.

Co-authored-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
Reviewed-on: Fediversity/Fediversity#389
Reviewed-by: Nicolas Jeannerod <nicolas.jeannerod@moduscreate.com>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-02 17:43:09 +02:00
6da42936e7 add missing home-manager import to fedipanel VM (#425)
Reviewed-on: Fediversity/Fediversity#425
Reviewed-by: Nicolas Jeannerod <nicolas.jeannerod@moduscreate.com>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-07-02 17:32:38 +02:00
8df70a2ff0 classify recent flake-parts files 2025-07-02 13:25:23 +02:00
5a92c2c0bc docs: fix links to machines (#426)
Reviewed-on: Fediversity/Fediversity#426
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-02 13:16:38 +02:00
1c92009879
Do not force QEMU options onto machines 2025-07-01 23:55:33 +02:00
a791ad41ec Inject sources, secrets and keys via module system - avoid import ../ (#421)
Co-authored-by: Nicolas “Niols” Jeannerod <nicolas.jeannerod@moduscreate.com>
Reviewed-on: Fediversity/Fediversity#421
Reviewed-by: Nicolas Jeannerod <nicolas.jeannerod@moduscreate.com>
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-01 21:08:15 +02:00
29 changed files with 235 additions and 50 deletions

View file

@ -10,43 +10,57 @@ on:
jobs: jobs:
check-pre-commit: check-pre-commit:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix-build -A tests - run: nix-build -A tests
check-data-model: check-data-model:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix-shell --run 'nix-unit ./deployment/data-model-test.nix' - run: nix-shell --run 'nix-unit ./deployment/data-model-test.nix'
check-peertube: check-peertube:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix-build services -A tests.peertube - run: nix-build services -A tests.peertube
check-panel: check-panel:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix-build panel -A tests - run: nix-build panel -A tests
check-deployment-basic: check-deployment-basic:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.deployment-basic -L - run: nix build .#checks.x86_64-linux.deployment-basic -L
check-deployment-cli: check-deployment-cli:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.deployment-cli -L - run: nix build .#checks.x86_64-linux.deployment-cli -L
check-deployment-panel: check-deployment-panel:
runs-on: native runs-on: docker
container:
image: icewind1991/nix-runner
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.deployment-panel -L - run: nix build .#checks.x86_64-linux.deployment-panel -L

View file

@ -8,7 +8,7 @@ on:
jobs: jobs:
lockfile: lockfile:
runs-on: native runs-on: nix
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4

View file

@ -2,6 +2,7 @@
self, self,
inputs, inputs,
lib, lib,
sources,
... ...
}: }:
@ -27,7 +28,7 @@ in
../common/nixosTest.nix ../common/nixosTest.nix
./nixosTest.nix ./nixosTest.nix
]; ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit targetMachines pathToRoot pathFromRoot; inherit targetMachines pathToRoot pathFromRoot;
}; };
}; };
@ -44,7 +45,7 @@ in
inputs.nixops4-nixos.modules.nixops4Resource.nixos inputs.nixops4-nixos.modules.nixops4Resource.nixos
../common/targetResource.nix ../common/targetResource.nix
]; ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit nodeName pathToRoot pathFromRoot; inherit nodeName pathToRoot pathFromRoot;
nixos.module = nixos.module =
{ pkgs, ... }: { pkgs, ... }:

View file

@ -2,6 +2,7 @@
self, self,
inputs, inputs,
lib, lib,
sources,
... ...
}: }:
@ -30,7 +31,7 @@ in
../common/nixosTest.nix ../common/nixosTest.nix
./nixosTest.nix ./nixosTest.nix
]; ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit inherit
targetMachines targetMachines
pathToRoot pathToRoot
@ -44,7 +45,7 @@ in
let let
makeTargetResource = nodeName: { makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ]; imports = [ ../common/targetResource.nix ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit inherit
nodeName nodeName
pathToRoot pathToRoot

View file

@ -3,6 +3,7 @@
lib, lib,
pkgs, pkgs,
config, config,
sources,
... ...
}: }:
@ -14,8 +15,6 @@ let
types types
; ;
sources = import ../../../npins;
in in
{ {
_class = "nixos"; _class = "nixos";
@ -78,7 +77,7 @@ in
config.system.extraDependenciesFromModule config.system.extraDependenciesFromModule
{ {
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = config.acmeNodeIP; acmeNodeIP = config.acmeNodeIP;
} }

View file

@ -3,6 +3,7 @@
lib, lib,
config, config,
hostPkgs, hostPkgs,
sources,
... ...
}: }:
@ -61,7 +62,7 @@ in
{ {
deployer = { deployer = {
imports = [ ./deployerNode.nix ]; imports = [ ./deployerNode.nix ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = config.nodes.acme.networking.primaryIPAddress; acmeNodeIP = config.nodes.acme.networking.primaryIPAddress;
}; };
@ -88,7 +89,7 @@ in
genAttrs config.targetMachines (_: { genAttrs config.targetMachines (_: {
imports = [ ./targetNode.nix ]; imports = [ ./targetNode.nix ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
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;
}); });

View file

@ -2,6 +2,7 @@
inputs, inputs,
lib, lib,
config, config,
sources,
... ...
}: }:
@ -40,7 +41,7 @@ in
(lib.modules.importJSON (config.pathToCwd + "/${config.nodeName}-network.json")) (lib.modules.importJSON (config.pathToCwd + "/${config.nodeName}-network.json"))
]; ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
enableAcme = config.enableAcme; enableAcme = config.enableAcme;
acmeNodeIP = trim (readFile (config.pathToCwd + "/acme_server_ip")); acmeNodeIP = trim (readFile (config.pathToCwd + "/acme_server_ip"));

View file

@ -2,6 +2,7 @@
self, self,
inputs, inputs,
lib, lib,
sources,
... ...
}: }:
@ -33,7 +34,7 @@ in
../common/nixosTest.nix ../common/nixosTest.nix
./nixosTest.nix ./nixosTest.nix
]; ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit inherit
targetMachines targetMachines
pathToRoot pathToRoot
@ -47,7 +48,7 @@ in
let let
makeTargetResource = nodeName: { makeTargetResource = nodeName: {
imports = [ ../common/targetResource.nix ]; imports = [ ../common/targetResource.nix ];
_module.args.inputs = inputs; _module.args = { inherit inputs sources; };
inherit inherit
nodeName nodeName
pathToRoot pathToRoot

View file

@ -31,6 +31,9 @@
inherit nixpkgs; inherit nixpkgs;
}; };
self = self'; self = self';
specialArgs = {
inherit sources;
};
} }
( (
{ inputs, ... }: { inputs, ... }:
@ -48,6 +51,8 @@
./deployment/flake-part.nix ./deployment/flake-part.nix
./infra/flake-part.nix ./infra/flake-part.nix
./keys/flake-part.nix
./secrets/flake-part.nix
]; ];
perSystem = perSystem =

View file

@ -8,7 +8,6 @@ in
_class = "nixos"; _class = "nixos";
imports = [ imports = [
./hardware.nix
./networking.nix ./networking.nix
./users.nix ./users.nix
]; ];
@ -24,4 +23,9 @@ 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

@ -6,17 +6,10 @@
imports = [ (modulesPath + "/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

@ -2,6 +2,9 @@
inputs, inputs,
lib, lib,
config, config,
sources,
keys,
secrets,
... ...
}: }:
@ -9,12 +12,6 @@ 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
{ {
@ -36,8 +33,8 @@ in
## should go into the `./nixos` subdirectory. ## should go into the `./nixos` subdirectory.
nixos.module = { nixos.module = {
imports = [ imports = [
"${agenix}/modules/age.nix" "${sources.agenix}/modules/age.nix"
"${disko}/module.nix" "${sources.disko}/module.nix"
./options.nix ./options.nix
./nixos ./nixos
]; ];
@ -46,15 +43,15 @@ in
## configuration. ## configuration.
fediversityVm = config.fediversityVm; fediversityVm = config.fediversityVm;
## Read all the secrets, filter the ones that are supposed to be readable ## Read all the secrets, filter the ones that are supposed to be readable with
## with this host's public key, and add them correctly to the configuration ## public key, and create a mapping from `<name>.file` to the absolute path of
## as `age.secrets.<name>.file`. ## the secret's 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 = secretsPrefix + "/${name}"; ${removeSuffix ".age" name}.file = secrets.rootPath + "/${name}";
}) })
) secrets; ) secrets.mapping;
## 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.

View file

@ -1,6 +1,9 @@
{ {
inputs, inputs,
lib, lib,
sources,
keys,
secrets,
... ...
}: }:
@ -13,7 +16,6 @@ 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
@ -22,7 +24,14 @@ 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 = { inherit inputs; }; _module.args = {
inherit
inputs
sources
keys
secrets
;
};
imports = imports =
[ [
@ -31,11 +40,12 @@ let
++ ( ++ (
if isTestVm then if isTestVm then
[ [
./common/proxmox-qemu-vm.nix
../machines/operator/${vmName} ../machines/operator/${vmName}
{ {
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
(import ../keys).panel keys.panel
]; ];
} }
] ]

5
keys/flake-part.nix Normal file
View file

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

View file

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

View file

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

View file

@ -19,6 +19,7 @@
nixos.module = { nixos.module = {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./fedipanel.nix ./fedipanel.nix
]; ];
}; };

View file

@ -1,5 +1,6 @@
{ {
config, config,
sources,
... ...
}: }:
let let
@ -10,6 +11,7 @@ in
imports = [ imports = [
(import ../../../panel { }).module (import ../../../panel { }).module
(import "${sources.home-manager}/nixos")
]; ];
security.acme = { security.acme = {

View file

@ -0,0 +1,70 @@
{ 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."/" = {
device = "rpool/root";
fsType = "zfs";
};
fileSystems."/home" = {
device = "rpool/home";
fsType = "zfs";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/50B2-DD3F";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
};
}

View file

@ -0,0 +1,47 @@
{ 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

@ -14,6 +14,7 @@
{ lib, ... }: { lib, ... }:
{ {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./forgejo.nix ./forgejo.nix
]; ];

View file

@ -14,6 +14,7 @@
{ lib, ... }: { lib, ... }:
{ {
imports = [ imports = [
../../../infra/common/proxmox-qemu-vm.nix
./wiki.nix ./wiki.nix
]; ];

View file

@ -7,9 +7,10 @@ Currently, this repository keeps track of the following VMs:
Machine | Proxmox | Description Machine | Proxmox | Description
--------|---------|------------- --------|---------|-------------
[`fedi200`](./fedi200) | fediversity | Testing machine for Hans [`fedi200`](./dev/fedi200) | fediversity | Testing machine for Hans
[`fedi201`](./fedi201) | fediversity | FediPanel [`fedi201`](./dev/fedi201) | fediversity | FediPanel
[`vm02116`](./vm02116) | procolix | Forgejo [`vm02116`](./dev/vm02116) | procolix | Forgejo
[`vm02187`](./vm02187) | procolix | Wiki [`vm02187`](./dev/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,11 +32,12 @@ 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`](./%s) | %s | %s\n' "$machine" "$machine" "$proxmox" "$description" printf '[`%s`](./dev/%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

@ -96,6 +96,19 @@
"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": {

4
secrets/default.nix Normal file
View file

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

5
secrets/flake-part.nix Normal file
View file

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

Binary file not shown.

View file

@ -26,7 +26,7 @@ concatMapAttrs
{ {
forgejo-database-password = [ vm02116 ]; forgejo-database-password = [ vm02116 ];
forgejo-email-password = [ vm02116 ]; forgejo-email-password = [ vm02116 ];
forgejo-runner-token = [ ]; forgejo-runner-token = [ forgejo-ci ];
panel-secret-key = [ fedi201 ]; panel-secret-key = [ fedi201 ];
panel-ssh-key = [ fedi201 ]; panel-ssh-key = [ fedi201 ];
wiki-basicauth-htpasswd = [ vm02187 ]; wiki-basicauth-htpasswd = [ vm02187 ];