Compare commits

..

No commits in common. "038a7974274e3e0a169516968cb935d4231e85e5" and "501c3466bc0d44fa49c07284765463f28ff5b4f3" have entirely different histories.

30 changed files with 766 additions and 819 deletions

View file

@ -1,8 +0,0 @@
# Run this command to always ignore formatting commits in `git blame`
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# Switch to nixpkgs-fmt formatting
fd138d45e6a2cad89fead6e9f246ba282070d6b7
# Switch to alejandra formatting
046a88905ddfa7f9edc3291c310dbb985dee34f9

View file

@ -1,9 +1,10 @@
{ config {
, pkgs config,
, lib pkgs,
, modulesPath lib,
, flake-inputs modulesPath,
, ... flake-inputs,
...
}: { }: {
imports = [ imports = [
flake-inputs.disko.nixosModules.disko flake-inputs.disko.nixosModules.disko

View file

@ -1,6 +1,5 @@
{ {
disko.devices.disk = disko.devices.disk = let
let
bootPartition = { bootPartition = {
size = "1M"; size = "1M";
type = "EF02"; type = "EF02";
@ -20,8 +19,7 @@
}; };
mountOptions = ["compress=zstd" "noatime"]; mountOptions = ["compress=zstd" "noatime"];
in in {
{
sda = { sda = {
type = "disk"; type = "disk";
device = "/dev/sda"; device = "/dev/sda";

View file

@ -1,6 +1,7 @@
{ config {
, lib config,
, ... lib,
...
}: { }: {
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -26,8 +27,7 @@
# Override the default, just keep fewer logs # Override the default, just keep fewer logs
nginx.rotate = 6; nginx.rotate = 6;
} }
// lib.mapAttrs' // lib.mapAttrs' (virtualHost: _:
(virtualHost: _:
lib.nameValuePair "/var/log/nginx/${virtualHost}/access.log" { lib.nameValuePair "/var/log/nginx/${virtualHost}/access.log" {
frequency = "daily"; frequency = "daily";
rotate = 2; rotate = 2;
@ -39,8 +39,7 @@
config.services.nginx.virtualHosts; config.services.nginx.virtualHosts;
systemd.tmpfiles.rules = systemd.tmpfiles.rules =
lib.mapAttrsToList lib.mapAttrsToList (
(
virtualHost: _: virtualHost: _:
# #
"d /var/log/nginx/${virtualHost} 0750 ${config.services.nginx.user} ${config.services.nginx.group}" "d /var/log/nginx/${virtualHost} 0750 ${config.services.nginx.user} ${config.services.nginx.group}"

View file

@ -1,6 +1,7 @@
{ pkgs {
, config pkgs,
, ... config,
...
}: { }: {
systemd.services.afvalcalendar = { systemd.services.afvalcalendar = {
description = "Enschede afvalcalendar -> ical converter"; description = "Enschede afvalcalendar -> ical converter";

View file

@ -1,9 +1,9 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
}: ...
let }: let
inherit (lib) types optional singleton; inherit (lib) types optional singleton;
mkShutdownScript = service: mkShutdownScript = service:
pkgs.writeShellScript "backup-${service}-shutdown" '' pkgs.writeShellScript "backup-${service}-shutdown" ''
@ -42,16 +42,16 @@ let
RESTIC_REPOSITORY = "rclone:storagebox:backups"; RESTIC_REPOSITORY = "rclone:storagebox:backups";
RCLONE_CONFIG = rcloneConfig; RCLONE_CONFIG = rcloneConfig;
}; };
in in {
{
options = { options = {
services.backups = lib.mkOption { services.backups = lib.mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Configure restic backups with a specific tag. Configure restic backups with a specific tag.
''; '';
type = types.attrsOf (types.submodule ({ config type = types.attrsOf (types.submodule ({
, name config,
, ... name,
...
}: { }: {
options = { options = {
user = lib.mkOption { user = lib.mkOption {
@ -164,8 +164,7 @@ in
}; };
}; };
} }
// lib.mapAttrs' // lib.mapAttrs' (name: backup:
(name: backup:
lib.nameValuePair "backup-${name}" { lib.nameValuePair "backup-${name}" {
# Don't want to restart mid-backup # Don't want to restart mid-backup
restartIfChanged = false; restartIfChanged = false;
@ -227,8 +226,7 @@ in
# of the backup jobs. # of the backup jobs.
}; };
} }
// lib.mapAttrs' // lib.mapAttrs' (name: backup:
(name: backup:
lib.nameValuePair "backup-${name}" { lib.nameValuePair "backup-${name}" {
wantedBy = ["timers.target"]; wantedBy = ["timers.target"];
timerConfig = { timerConfig = {

View file

@ -1,6 +1,7 @@
{ config {
, flake-inputs config,
, ... flake-inputs,
...
}: { }: {
imports = [ imports = [
flake-inputs.sonnenshift.nixosModules.default flake-inputs.sonnenshift.nixosModules.default

View file

@ -1,16 +1,15 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
}: ...
let }: let
inherit (lib.strings) concatMapStringsSep; inherit (lib.strings) concatMapStringsSep;
cfg = config.services.matrix-conduit; cfg = config.services.matrix-conduit;
domain = "matrix.${config.services.nginx.domain}"; domain = "matrix.${config.services.nginx.domain}";
turn-realm = "turn.${config.services.nginx.domain}"; turn-realm = "turn.${config.services.nginx.domain}";
in in {
{
services.matrix-conduit = { services.matrix-conduit = {
enable = true; enable = true;
settings.global = { settings.global = {
@ -18,12 +17,10 @@ in
server_name = domain; server_name = domain;
database_backend = "rocksdb"; database_backend = "rocksdb";
turn_uris = turn_uris = let
let
address = "${config.services.coturn.realm}:${toString config.services.coturn.listening-port}"; address = "${config.services.coturn.realm}:${toString config.services.coturn.listening-port}";
tls-address = "${config.services.coturn.realm}:${toString config.services.coturn.tls-listening-port}"; tls-address = "${config.services.coturn.realm}:${toString config.services.coturn.tls-listening-port}";
in in [
[
"turn:${address}?transport=udp" "turn:${address}?transport=udp"
"turn:${address}?transport=tcp" "turn:${address}?transport=tcp"
"turns:${tls-address}?transport=udp" "turns:${tls-address}?transport=udp"
@ -32,8 +29,7 @@ in
}; };
}; };
systemd.services.heisenbridge = systemd.services.heisenbridge = let
let
replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret"; replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret";
registrationFile = builtins.toFile "heisenbridge-registration.yaml" (builtins.toJSON { registrationFile = builtins.toFile "heisenbridge-registration.yaml" (builtins.toJSON {
id = "heisenbridge"; id = "heisenbridge";
@ -77,8 +73,7 @@ in
--owner @tlater:matrix.tlater.net \ --owner @tlater:matrix.tlater.net \
'http://localhost:${toString cfg.settings.global.port}' 'http://localhost:${toString cfg.settings.global.port}'
''; '';
in in {
{
description = "Matrix<->IRC bridge"; description = "Matrix<->IRC bridge";
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
after = ["conduit.service"]; after = ["conduit.service"];

View file

@ -1,12 +1,11 @@
{ lib
, config
, flake-inputs
, ...
}:
let
domain = "foundryvtt.${config.services.nginx.domain}";
in
{ {
lib,
config,
flake-inputs,
...
}: let
domain = "foundryvtt.${config.services.nginx.domain}";
in {
imports = [flake-inputs.foundryvtt.nixosModules.foundryvtt]; imports = [flake-inputs.foundryvtt.nixosModules.foundryvtt];
services.foundryvtt = { services.foundryvtt = {
@ -21,11 +20,9 @@ in
# running # running
systemd.services.foundryvtt.wantedBy = lib.mkForce []; systemd.services.foundryvtt.wantedBy = lib.mkForce [];
services.nginx.virtualHosts."${domain}" = services.nginx.virtualHosts."${domain}" = let
let
inherit (config.services.foundryvtt) port; inherit (config.services.foundryvtt) port;
in in {
{
forceSSL = true; forceSSL = true;
useACMEHost = "tlater.net"; useACMEHost = "tlater.net";
enableHSTS = true; enableHSTS = true;

View file

@ -1,12 +1,11 @@
{ pkgs
, config
, lib
, ...
}:
let
domain = "gitea.${config.services.nginx.domain}";
in
{ {
pkgs,
config,
lib,
...
}: let
domain = "gitea.${config.services.nginx.domain}";
in {
services.forgejo = { services.forgejo = {
enable = true; enable = true;
database.type = "postgres"; database.type = "postgres";
@ -28,23 +27,19 @@ in
}; };
}; };
systemd.services.forgejo.serviceConfig.ExecStartPre = systemd.services.forgejo.serviceConfig.ExecStartPre = let
let
replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret"; replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret";
secretPath = config.sops.secrets."forgejo/metrics-token".path; secretPath = config.sops.secrets."forgejo/metrics-token".path;
runConfig = "${config.services.forgejo.customDir}/conf/app.ini"; runConfig = "${config.services.forgejo.customDir}/conf/app.ini";
in in [
[
"+${replaceSecretBin} '#metricstoken#' '${secretPath}' '${runConfig}'" "+${replaceSecretBin} '#metricstoken#' '${secretPath}' '${runConfig}'"
]; ];
# Set up SSL # Set up SSL
services.nginx.virtualHosts."${domain}" = services.nginx.virtualHosts."${domain}" = let
let
httpAddress = config.services.forgejo.settings.server.HTTP_ADDR; httpAddress = config.services.forgejo.settings.server.HTTP_ADDR;
httpPort = config.services.forgejo.settings.server.HTTP_PORT; httpPort = config.services.forgejo.settings.server.HTTP_PORT;
in in {
{
forceSSL = true; forceSSL = true;
useACMEHost = "tlater.net"; useACMEHost = "tlater.net";
enableHSTS = true; enableHSTS = true;

View file

@ -1,26 +1,23 @@
{ config
, pkgs
, lib
, ...
}:
let
yaml = pkgs.formats.yaml { };
in
{ {
config,
pkgs,
lib,
...
}: let
yaml = pkgs.formats.yaml {};
in {
services.prometheus = { services.prometheus = {
exporters = { exporters = {
# Periodically check domain registration status # Periodically check domain registration status
domain = { domain = {
enable = true; enable = true;
listenAddress = "127.0.0.1"; listenAddress = "127.0.0.1";
extraFlags = extraFlags = let
let
conf.domains = [ conf.domains = [
"tlater.net" "tlater.net"
"tlater.com" "tlater.com"
]; ];
in in [
[
"--config=${yaml.generate "domains.yml" conf}" "--config=${yaml.generate "domains.yml" conf}"
]; ];
}; };
@ -52,8 +49,7 @@ in
group = "nginx"; group = "nginx";
settings.namespaces = settings.namespaces =
lib.mapAttrsToList lib.mapAttrsToList (name: virtualHost: {
(name: virtualHost: {
inherit name; inherit name;
metrics_override.prefix = "nginxlog"; metrics_override.prefix = "nginxlog";
namespace_label = "vhost"; namespace_label = "vhost";
@ -75,11 +71,9 @@ in
}; };
extraExporters = { extraExporters = {
fail2ban = fail2ban = let
let
cfg = config.services.prometheus.extraExporters.fail2ban; cfg = config.services.prometheus.extraExporters.fail2ban;
in in {
{
port = 9191; port = 9191;
serviceOpts = { serviceOpts = {
after = ["fail2ban.service"]; after = ["fail2ban.service"];

View file

@ -1,8 +1,6 @@
{ config, ... }: {config, ...}: let
let
domain = "metrics.${config.services.nginx.domain}"; domain = "metrics.${config.services.nginx.domain}";
in in {
{
services.grafana = { services.grafana = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,13 +1,12 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
}: ...
let }: let
inherit (lib) types mkOption mkDefault; inherit (lib) types mkOption mkDefault;
yaml = pkgs.formats.yaml {}; yaml = pkgs.formats.yaml {};
in in {
{
options = { options = {
services.prometheus = { services.prometheus = {
extraExporters = mkOption { extraExporters = mkOption {
@ -32,9 +31,10 @@ in
}; };
services.victoriametrics.scrapeConfigs = mkOption { services.victoriametrics.scrapeConfigs = mkOption {
type = types.attrsOf (types.submodule ({ name type = types.attrsOf (types.submodule ({
, self name,
, ... self,
...
}: { }: {
options = { options = {
job_name = mkOption { job_name = mkOption {
@ -89,8 +89,7 @@ in
config = { config = {
systemd.services = lib.mkMerge [ systemd.services = lib.mkMerge [
(lib.mapAttrs' (lib.mapAttrs' (name: exporter:
(name: exporter:
lib.nameValuePair "prometheus-${name}-exporter" (lib.mkMerge [ lib.nameValuePair "prometheus-${name}-exporter" (lib.mkMerge [
{ {
# Shamelessly copied from upstream because the upstream # Shamelessly copied from upstream because the upstream
@ -129,15 +128,12 @@ in
config.services.prometheus.extraExporters) config.services.prometheus.extraExporters)
{ {
vmagent-scrape-exporters = vmagent-scrape-exporters = let
let
listenAddress = config.services.victoriametrics.listenAddress; listenAddress = config.services.victoriametrics.listenAddress;
vmAddr = (lib.optionalString (lib.hasPrefix ":" listenAddress) "127.0.0.1") + listenAddress; vmAddr = (lib.optionalString (lib.hasPrefix ":" listenAddress) "127.0.0.1") + listenAddress;
promscrape = yaml.generate "prometheus.yml" { promscrape = yaml.generate "prometheus.yml" {
scrape_configs = lib.mapAttrsToList scrape_configs = lib.mapAttrsToList (_: scrape:
(_: scrape: lib.recursiveUpdate {
lib.recursiveUpdate
{
inherit (scrape) job_name; inherit (scrape) job_name;
static_configs = static_configs =
scrape.static_configs scrape.static_configs
@ -146,8 +142,7 @@ in
scrape.extraSettings) scrape.extraSettings)
config.services.victoriametrics.scrapeConfigs; config.services.victoriametrics.scrapeConfigs;
}; };
in in {
{
enable = true; enable = true;
path = [pkgs.victoriametrics]; path = [pkgs.victoriametrics];
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
@ -193,19 +188,15 @@ in
users.groups.metrics = {}; users.groups.metrics = {};
services.victoriametrics.scrapeConfigs = services.victoriametrics.scrapeConfigs = let
let
allExporters = allExporters =
lib.mapAttrs lib.mapAttrs (name: exporter: {
(name: exporter: {
inherit (exporter) listenAddress port; inherit (exporter) listenAddress port;
}) }) ((lib.filterAttrs (_: exporter: builtins.isAttrs exporter && exporter.enable)
((lib.filterAttrs (_: exporter: builtins.isAttrs exporter && exporter.enable)
config.services.prometheus.exporters) config.services.prometheus.exporters)
// config.services.prometheus.extraExporters); // config.services.prometheus.extraExporters);
in in
lib.mapAttrs lib.mapAttrs (_: exporter: {
(_: exporter: {
targets = ["${exporter.listenAddress}:${toString exporter.port}"]; targets = ["${exporter.listenAddress}:${toString exporter.port}"];
}) })
allExporters; allExporters;

View file

@ -1,15 +1,14 @@
{ pkgs {
, config pkgs,
, ... config,
}: ...
let }: let
# Update pending on rewrite of nextcloud news, though there is an # Update pending on rewrite of nextcloud news, though there is an
# alpha to switch to if it becomes necessary: # alpha to switch to if it becomes necessary:
# https://github.com/nextcloud/news/issues/2610 # https://github.com/nextcloud/news/issues/2610
nextcloud = pkgs.nextcloud27; nextcloud = pkgs.nextcloud27;
hostName = "nextcloud.${config.services.nginx.domain}"; hostName = "nextcloud.${config.services.nginx.domain}";
in in {
{
services.nextcloud = { services.nextcloud = {
inherit hostName; inherit hostName;

View file

@ -1,11 +1,10 @@
{ pkgs
, lib
, ...
}:
let
inherit (lib) concatStringsSep;
in
{ {
pkgs,
lib,
...
}: let
inherit (lib) concatStringsSep;
in {
# Sadly, steam-run requires some X libs # Sadly, steam-run requires some X libs
environment.noXlibs = false; environment.noXlibs = false;

View file

@ -1,8 +1,6 @@
{ config, ... }: {config, ...}: let
let
domain = config.services.nginx.domain; domain = config.services.nginx.domain;
in in {
{
services.tlaternet-webserver = { services.tlaternet-webserver = {
enable = true; enable = true;
listen = { listen = {
@ -12,11 +10,9 @@ in
}; };
# Set up SSL # Set up SSL
services.nginx.virtualHosts."${domain}" = services.nginx.virtualHosts."${domain}" = let
let
inherit (config.services.tlaternet-webserver.listen) addr port; inherit (config.services.tlaternet-webserver.listen) addr port;
in in {
{
serverAliases = ["www.${domain}"]; serverAliases = ["www.${domain}"];
forceSSL = true; forceSSL = true;

View file

@ -32,19 +32,17 @@
}; };
}; };
outputs = outputs = {
{ self self,
, nixpkgs nixpkgs,
, sops-nix sops-nix,
, nvfetcher nvfetcher,
, deploy-rs deploy-rs,
, ... ...
} @ inputs: } @ inputs: let
let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in in {
{
################## ##################
# Configurations # # Configurations #
################## ##################
@ -91,8 +89,7 @@
run-vm = { run-vm = {
type = "app"; type = "app";
program = program = let
let
vm = nixpkgs.lib.nixosSystem { vm = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs.flake-inputs = inputs; specialArgs.flake-inputs = inputs;
@ -105,31 +102,32 @@
in in
(pkgs.writeShellScript "" '' (pkgs.writeShellScript "" ''
${vm.config.system.build.vm.outPath}/bin/run-testvm-vm ${vm.config.system.build.vm.outPath}/bin/run-testvm-vm
'').outPath; '')
.outPath;
}; };
update-pkgs = { update-pkgs = {
type = "app"; type = "app";
program = program = let
let
nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher"; nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher";
in in
(pkgs.writeShellScript "update-pkgs" '' (pkgs.writeShellScript "update-pkgs" ''
cd "$(git rev-parse --show-toplevel)/pkgs" cd "$(git rev-parse --show-toplevel)/pkgs"
${nvfetcher-bin} -o _sources_pkgs -c nvfetcher.toml ${nvfetcher-bin} -o _sources_pkgs -c nvfetcher.toml
'').outPath; '')
.outPath;
}; };
update-nextcloud-apps = { update-nextcloud-apps = {
type = "app"; type = "app";
program = program = let
let
nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher"; nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher";
in in
(pkgs.writeShellScript "update-nextcloud-apps" '' (pkgs.writeShellScript "update-nextcloud-apps" ''
cd "$(git rev-parse --show-toplevel)/pkgs" cd "$(git rev-parse --show-toplevel)/pkgs"
${nvfetcher-bin} -o _sources_nextcloud -c nextcloud-apps.toml ${nvfetcher-bin} -o _sources_nextcloud -c nextcloud-apps.toml
'').outPath; '')
.outPath;
}; };
}; };
@ -146,8 +144,6 @@
sops-nix.packages.${system}.sops-init-gpg-key sops-nix.packages.${system}.sops-init-gpg-key
deploy-rs.packages.${system}.default deploy-rs.packages.${system}.default
nixpkgs-fmt
cargo cargo
clippy clippy
rustc rustc

View file

@ -1,7 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: { }: {
options = { options = {
services.nginx.domain = lib.mkOption { services.nginx.domain = lib.mkOption {
@ -9,12 +10,11 @@
description = "The base domain name to append to virtual domain names"; description = "The base domain name to append to virtual domain names";
}; };
services.nginx.virtualHosts = services.nginx.virtualHosts = let
let extraVirtualHostOptions = {
extraVirtualHostOptions = name,
{ name config,
, config ...
, ...
}: { }: {
options = { options = {
enableHSTS = lib.mkEnableOption "Enable HSTS"; enableHSTS = lib.mkEnableOption "Enable HSTS";
@ -47,12 +47,10 @@
config = { config = {
# Don't attempt to run acme if the domain name is not tlater.net # Don't attempt to run acme if the domain name is not tlater.net
systemd.services = systemd.services = let
let
confirm = ''[[ "tlater.net" = ${config.services.nginx.domain} ]]''; confirm = ''[[ "tlater.net" = ${config.services.nginx.domain} ]]'';
in in
lib.mapAttrs' lib.mapAttrs' (cert: _:
(cert: _:
lib.nameValuePair "acme-${cert}" { lib.nameValuePair "acme-${cert}" {
serviceConfig.ExecCondition = ''${pkgs.runtimeShell} -c '${confirm}' ''; serviceConfig.ExecCondition = ''${pkgs.runtimeShell} -c '${confirm}' '';
}) })

View file

@ -1,6 +1,7 @@
{ pkgs {
, rustPlatform pkgs,
, ... rustPlatform,
...
}: }:
rustPlatform.buildRustPackage { rustPlatform.buildRustPackage {
pname = "afvalcalendar"; pname = "afvalcalendar";

View file

@ -1,8 +1,7 @@
{ pkgs {
, lib pkgs,
, lib,
}: }: let
let
inherit (builtins) fromJSON mapAttrs readFile; inherit (builtins) fromJSON mapAttrs readFile;
inherit (pkgs) callPackage; inherit (pkgs) callPackage;
in in

View file

@ -1,6 +1,6 @@
{ fetchNextcloudApp {
, lib fetchNextcloudApp,
, lib,
}: source: }: source:
fetchNextcloudApp { fetchNextcloudApp {
url = source.src.url; url = source.src.url;

View file

@ -1,6 +1,6 @@
{ buildGoModule {
, sources buildGoModule,
, sources,
}: }:
buildGoModule { buildGoModule {
inherit (sources.prometheus-fail2ban-exporter) pname src version; inherit (sources.prometheus-fail2ban-exporter) pname src version;

View file

@ -1,12 +1,11 @@
{ stdenv {
, lib stdenv,
, makeWrapper lib,
, patchelf makeWrapper,
, steamPackages patchelf,
, replace-secret steamPackages,
, replace-secret,
}: }: let
let
# Use the directory in which starbound is installed so steamcmd # Use the directory in which starbound is installed so steamcmd
# doesn't have to be reinstalled constantly (we're using DynamicUser # doesn't have to be reinstalled constantly (we're using DynamicUser
# with StateDirectory to persist this). # with StateDirectory to persist this).