forked from fediversity/fediversity
Compare commits
17 commits
01c3a7b3c7
...
d59be61a1b
| Author | SHA1 | Date | |
|---|---|---|---|
| d59be61a1b | |||
| d7939e03aa | |||
| 7811cf9eeb | |||
| 1c92009879 | |||
| a791ad41ec | |||
| c1dc0fef01 | |||
| 5a3cbe4d83 | |||
| fd1d55df5f | |||
| 0c23115cff | |||
| 3f1c8a9bb7 | |||
| 737aecaba6 | |||
| d7dbdd923c | |||
| 1c44004cfe | |||
| ae444d5352 | |||
| e77fdd9eec | |||
| 1f1cf0d516 | |||
| f94eac698a |
35 changed files with 326 additions and 102 deletions
|
|
@ -25,13 +25,13 @@ jobs:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: cd services && nix-build -A tests.peertube
|
- run: nix-build services -A tests.peertube
|
||||||
|
|
||||||
check-panel:
|
check-panel:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: cd panel && nix-build -A tests
|
- run: nix-build panel -A tests
|
||||||
|
|
||||||
check-deployment-basic:
|
check-deployment-basic:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ name: update-dependencies
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: # allows manual triggering
|
workflow_dispatch: # allows manual triggering
|
||||||
schedule:
|
# FIXME: re-enable when manual run works
|
||||||
- cron: '0 0 1 * *' # monthly
|
# schedule:
|
||||||
|
# - cron: '0 0 1 * *' # monthly
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lockfile:
|
lockfile:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ let
|
||||||
gitignore
|
gitignore
|
||||||
;
|
;
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
|
inherit (import sources.flake-inputs) import-flake;
|
||||||
|
inherit ((import-flake { src = ./.; }).inputs) nixops4;
|
||||||
pre-commit-check =
|
pre-commit-check =
|
||||||
(import "${git-hooks}/nix" {
|
(import "${git-hooks}/nix" {
|
||||||
inherit nixpkgs system;
|
inherit nixpkgs system;
|
||||||
|
|
@ -56,8 +58,14 @@ in
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
pkgs.npins
|
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
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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, ... }:
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,6 @@ 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";
|
||||||
|
|
|
||||||
25
flake.nix
25
flake.nix
|
|
@ -11,7 +11,7 @@
|
||||||
let
|
let
|
||||||
sources = import ./npins;
|
sources = import ./npins;
|
||||||
inherit (import sources.flake-inputs) import-flake;
|
inherit (import sources.flake-inputs) import-flake;
|
||||||
inherit (sources) git-hooks agenix;
|
inherit (sources) git-hooks;
|
||||||
# XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
|
# XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
|
||||||
# XXX - this is just importing a flake
|
# XXX - this is just importing a flake
|
||||||
nixpkgs = import-flake { src = sources.nixpkgs; };
|
nixpkgs = import-flake { src = sources.nixpkgs; };
|
||||||
|
|
@ -31,6 +31,9 @@
|
||||||
inherit nixpkgs;
|
inherit nixpkgs;
|
||||||
};
|
};
|
||||||
self = self';
|
self = self';
|
||||||
|
specialArgs = {
|
||||||
|
inherit sources;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
|
|
@ -43,18 +46,19 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
(import "${git-hooks}/flake-module.nix")
|
"${git-hooks}/flake-module.nix"
|
||||||
inputs.nixops4.modules.flake.default
|
inputs.nixops4.modules.flake.default
|
||||||
|
|
||||||
./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 =
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
inputs',
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
|
@ -73,21 +77,6 @@
|
||||||
trim-trailing-whitespace.enable = true;
|
trim-trailing-whitespace.enable = true;
|
||||||
shellcheck.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" ];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ in
|
||||||
_class = "nixos";
|
_class = "nixos";
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
./hardware.nix
|
|
||||||
./networking.nix
|
./networking.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkDefault;
|
inherit (lib) mkDefault mkIf mkMerge;
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -13,53 +13,52 @@ in
|
||||||
settings.PasswordAuthentication = false;
|
settings.PasswordAuthentication = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
networking = mkMerge [
|
||||||
hostName = config.fediversityVm.name;
|
{
|
||||||
domain = config.fediversityVm.domain;
|
hostName = config.fediversityVm.name;
|
||||||
|
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;
|
||||||
|
|
||||||
interfaces = {
|
## Disable the default firewall and use nftables instead, with a custom
|
||||||
eth0 = {
|
## Procolix-made ruleset.
|
||||||
ipv4 = {
|
firewall.enable = false;
|
||||||
addresses = [
|
nftables = {
|
||||||
{
|
enable = true;
|
||||||
inherit (config.fediversityVm.ipv4) address prefixLength;
|
rulesetFile = ./nftables-ruleset.nft;
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
ipv6 = {
|
|
||||||
addresses = [
|
|
||||||
{
|
|
||||||
inherit (config.fediversityVm.ipv6) address prefixLength;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
defaultGateway = {
|
## IPv4
|
||||||
address = config.fediversityVm.ipv4.gateway;
|
(mkIf config.fediversityVm.ipv4.enable {
|
||||||
interface = "eth0";
|
interfaces.${config.fediversityVm.ipv4.interface}.ipv4.addresses = [
|
||||||
};
|
{ inherit (config.fediversityVm.ipv4) address prefixLength; }
|
||||||
defaultGateway6 = {
|
];
|
||||||
address = config.fediversityVm.ipv6.gateway;
|
defaultGateway = {
|
||||||
interface = "eth0";
|
address = config.fediversityVm.ipv4.gateway;
|
||||||
};
|
interface = config.fediversityVm.ipv4.interface;
|
||||||
|
};
|
||||||
|
nameservers = [
|
||||||
|
"95.215.185.6"
|
||||||
|
"95.215.185.7"
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
nameservers = [
|
## IPv6
|
||||||
"95.215.185.6"
|
(mkIf config.fediversityVm.ipv6.enable {
|
||||||
"95.215.185.7"
|
interfaces.${config.fediversityVm.ipv6.interface}.ipv6.addresses = [
|
||||||
"2a00:51c0::5fd7:b906"
|
{ inherit (config.fediversityVm.ipv6) address prefixLength; }
|
||||||
"2a00:51c0::5fd7:b907"
|
];
|
||||||
];
|
defaultGateway6 = {
|
||||||
|
address = config.fediversityVm.ipv6.gateway;
|
||||||
firewall.enable = false;
|
interface = config.fediversityVm.ipv6.interface;
|
||||||
nftables = {
|
};
|
||||||
enable = true;
|
nameservers = [
|
||||||
rulesetFile = ./nftables-ruleset.nft;
|
"2a00:51c0::5fd7:b906"
|
||||||
};
|
"2a00:51c0::5fd7:b907"
|
||||||
};
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_class = "nixops4Resource";
|
# `config` not set and imported from multiple places: no fixed module class
|
||||||
|
|
||||||
options.fediversityVm = {
|
options.fediversityVm = {
|
||||||
|
|
||||||
|
|
@ -91,6 +91,17 @@ 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
|
||||||
|
|
@ -116,6 +127,17 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@
|
||||||
availableKernelModules = [
|
availableKernelModules = [
|
||||||
"ata_piix"
|
"ata_piix"
|
||||||
"uhci_hcd"
|
"uhci_hcd"
|
||||||
"virtio_pci"
|
|
||||||
"virtio_scsi"
|
|
||||||
"sd_mod"
|
"sd_mod"
|
||||||
"sr_mod"
|
"sr_mod"
|
||||||
];
|
];
|
||||||
|
|
@ -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 = [
|
||||||
(import "${agenix}/modules/age.nix")
|
"${sources.agenix}/modules/age.nix"
|
||||||
(import "${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.
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -157,6 +167,10 @@ in
|
||||||
{
|
{
|
||||||
_class = "flake";
|
_class = "flake";
|
||||||
|
|
||||||
|
# NOTE: `forgejo-ci`, being a physical machine and not a Proxmox VM, gets
|
||||||
|
# custom treatment.
|
||||||
|
imports = [ ./forgejo-ci/flake-part.nix ];
|
||||||
|
|
||||||
## - 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.
|
||||||
|
|
|
||||||
58
infra/forgejo-ci/configuration.nix
Normal file
58
infra/forgejo-ci/configuration.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkDefault mkForce;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
_class = "nixos";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
../common/options.nix
|
||||||
|
../common/nixos
|
||||||
|
./forgejo-actions-runner.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
fediversityVm = {
|
||||||
|
# XXX this needs an SSH config entry to locate and access the machine
|
||||||
|
name = "forgejo-ci";
|
||||||
|
domain = "procolix.com";
|
||||||
|
|
||||||
|
ipv4 = {
|
||||||
|
interface = "enp1s0f0";
|
||||||
|
address = "192.168.201.65";
|
||||||
|
prefixLength = 24;
|
||||||
|
gateway = "192.168.201.1";
|
||||||
|
};
|
||||||
|
ipv6.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
nftables.enable = mkForce false;
|
||||||
|
hostId = "1d6ea552";
|
||||||
|
};
|
||||||
|
|
||||||
|
hardware.cpu.intel.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
58
infra/forgejo-ci/flake-part.nix
Normal file
58
infra/forgejo-ci/flake-part.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
sources,
|
||||||
|
keys,
|
||||||
|
secrets,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
## NOTE: Hackish solution mostly taken from `../common/resource.nix`.
|
||||||
|
## Eventually, `forgejo-ci` should move to a datacentre somewhere and this code
|
||||||
|
## should be integrated with the code for other machines (in particular VMs).
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) attrValues elem;
|
||||||
|
inherit (lib.attrsets) concatMapAttrs optionalAttrs;
|
||||||
|
inherit (lib.strings) removeSuffix;
|
||||||
|
|
||||||
|
hostPublicKey = keys.systems.forgejo-ci;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
_class = "flake";
|
||||||
|
|
||||||
|
nixops4Deployments.forgejo-ci =
|
||||||
|
{ providers, ... }:
|
||||||
|
{
|
||||||
|
providers.local = inputs.nixops4.modules.nixops4Provider.local;
|
||||||
|
|
||||||
|
resources.forgejo-ci = {
|
||||||
|
type = providers.local.exec;
|
||||||
|
imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ];
|
||||||
|
|
||||||
|
ssh = {
|
||||||
|
host = "forgejo-ci";
|
||||||
|
hostPublicKey = hostPublicKey;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs = inputs.nixpkgs;
|
||||||
|
|
||||||
|
nixos.module = {
|
||||||
|
imports = with sources; [
|
||||||
|
"${agenix}/modules/age.nix"
|
||||||
|
"${disko}/module.nix"
|
||||||
|
./configuration.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
age.secrets = concatMapAttrs (
|
||||||
|
name: secret:
|
||||||
|
optionalAttrs (elem hostPublicKey secret.publicKeys) ({
|
||||||
|
${removeSuffix ".age" name}.file = ../../secrets/${name};
|
||||||
|
})
|
||||||
|
) secrets;
|
||||||
|
|
||||||
|
users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
47
infra/forgejo-ci/forgejo-actions-runner.nix
Normal file
47
infra/forgejo-ci/forgejo-actions-runner.nix
Normal 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;
|
||||||
|
}
|
||||||
1
keys/flake-part.nix
Normal file
1
keys/flake-part.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ _module.args.keys = import ./.; }
|
||||||
1
keys/systems/forgejo-ci.pub
Normal file
1
keys/systems/forgejo-ci.pub
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFXQW5fxJoNY9wtTMsNExgbAbvyljIRGBLjY+USh/0A
|
||||||
|
|
@ -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
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
nixos.module = {
|
nixos.module = {
|
||||||
imports = [
|
imports = [
|
||||||
|
../../../infra/common/proxmox-qemu-vm.nix
|
||||||
./fedipanel.nix
|
./fedipanel.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
../../../infra/common/proxmox-qemu-vm.nix
|
||||||
./forgejo.nix
|
./forgejo.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
../../../infra/common/proxmox-qemu-vm.nix
|
||||||
./wiki.nix
|
./wiki.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,6 @@ Machine | Proxmox | Description
|
||||||
[`fedi201`](./fedi201) | fediversity | FediPanel
|
[`fedi201`](./fedi201) | fediversity | FediPanel
|
||||||
[`vm02116`](./vm02116) | procolix | Forgejo
|
[`vm02116`](./vm02116) | procolix | Forgejo
|
||||||
[`vm02187`](./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`.
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ for machine in $(echo "$vmOptions" | jq -r 'keys[]'); do
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ in
|
||||||
manage
|
manage
|
||||||
|
|
||||||
# NixOps4 and its dependencies
|
# NixOps4 and its dependencies
|
||||||
# FIXME: grab NixOps4 and add it here
|
pkgs.nixops4
|
||||||
pkgs.nix
|
pkgs.nix
|
||||||
pkgs.openssh
|
pkgs.openssh
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ 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 = {
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,17 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ 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 = {
|
||||||
|
|
|
||||||
4
secrets/default.nix
Normal file
4
secrets/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
mapping = import ./secrets.nix;
|
||||||
|
rootPath = ./.;
|
||||||
|
}
|
||||||
1
secrets/flake-part.nix
Normal file
1
secrets/flake-part.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ _module.args.secrets = import ./.; }
|
||||||
|
|
@ -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 ];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue