_module.args bad

This commit is contained in:
Peder Bergebakken Sundt 2025-03-20 13:30:55 +01:00
parent efb5d45317
commit da3f97b80d
47 changed files with 288 additions and 148 deletions

@ -1,111 +1,119 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
mkDomain = subname: "${subname}.${config.networking.fqdn}"; inherit (config.pbsds.nginx) mkDomain allSubdomains;
in in
{ {
# TODO: make these into nixos options with readonly=true options.pbsds.nginx.mkDomain = lib.mkOption {
_module.args.mkDomain = mkDomain; visible = false; internal = true; readOnly = true;
_module.args.allSubdomains = lib.pipe config.services.nginx.virtualHosts [ default = subname: "${subname}.${config.networking.fqdn}";
#(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases))
(lib.mapAttrsToList (domain: vhost: [ domain ]))
lib.flatten
(builtins.filter (domain: domain != "" && domain != "_"))
(lib.sort (x: y: x<y))
];
security.acme.acceptTerms = true;
security.acme.defaults.email = "pbsds+acme@hotmail.com"; # TODO: parametrize per host
#security.acme.defaults.renewInterval = "daily";
#security.acme.defaults.reloadServices
# https://www.xf.is/2020/06/30/list-of-free-acme-ssl-providers/
#security.acme.defaults.server = "https://acme-v02.api.letsencrypt.org/directory" # default
#security.acme.defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory"; # STAGING
#security.acme.defaults.server = "https://api.buypass.com/acme/directory"; # no wildcards, rate limit: 20 domains/week, 5 duplicate certs / week
#security.acme.defaults.server = "https://api.test4.buypass.no/acme/directory"; # STAGING. no wildcards, rate limit: 20 domains/week, 5 duplicate certs / week
# DNS-based ACME:
# - https://go-acme.github.io/lego/dns/domeneshop/
# - https://nixos.org/manual/nixos/stable/index.html#module-security-acme-config-dns-with-vhosts
#security.acme.defaults.dnsProvider = "domeneshop";
#security.acme.defaults.credentialsFile = "/var/lib/secrets/domeneshop.key"; # TODO: this file must be made by hand, containing env variables.
services.nginx.enable = true;
networking.firewall.allowedTCPPorts = [ 80 443 ];
# TODO:
#services.nginx.commonHttpConfig = ''
# proxy_hide_header X-Frame-Options;
#'';
# TODO: Somehow distribute and add this to all location."/".extraConfig
#default = {
# #useACMEHost = config.networking.fqdn;
# forceSSL = true; # addSSL = true;
# enableACME = true; #useACMEHost = acmeDomain;
#}
# TODO: Somehow distribute and add this to all location."/".extraConfig
#commonProxySettings = ''
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
#'';
services.nginx.recommendedGzipSettings = true;
services.nginx.recommendedOptimisation = true;
services.nginx.recommendedProxySettings = true;
services.nginx.recommendedTlsSettings = true;
# nginx return 444 for all nonexistent virtualhosts
services.nginx.virtualHosts."_" = {
addSSL = true;
sslCertificate = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem";
sslCertificateKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem";
extraConfig = "return 444;";
}; };
options.pbsds.nginx.allSubdomains = lib.mkOption {
/** / visible = false; internal = true; readOnly = true;
services.nginx.virtualHosts."" = { default = lib.pipe config.services.nginx.virtualHosts [
default = true; #(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases))
forceSSL = false; (lib.mapAttrsToList (domain: vhost: [ domain ]))
enableACME = false; lib.flatten
root = pkgs.writeTextDir "index.html" '' (builtins.filter (domain: domain != "" && domain != "_"))
<!DOCTYPE html> (lib.sort (x: y: x<y))
no
'';
};
/**/
# Website tunnel
# TODO: remove
/** /
services.nginx.virtualHosts.${config.networking.fqdn} = {
forceSSL = true; # addSSL = true;
enableACME = true;
#acmeRoot = null; # use DNS
default = true;
serverAliases = map mkDomain [
"www"
#"*" # requires DNS ACME
]; ];
# The alternative to ^ is: config.security.acme.certs."${acmeDomain}".extraDomainNames = [ (mkDomain "foo") ];
# TODO: 'nox' alias for everything
locations."/" = {
proxyPass = "http://pbuntu.pbsds.net";
proxyWebsockets = true;
};
}; };
#services.nginx.virtualHosts.${mkDomain "www"} = {
# addSSL = true;
# useACMEHost = acmeDomain; #enableACME = true;
# locations."/" = {
# proxyPass = "http://pbuntu.pbsds.net";
# proxyWebsockets = true;
# };
#};
/**/
config = {
security.acme.acceptTerms = true;
security.acme.defaults.email = "pbsds+acme@hotmail.com"; # TODO: parametrize per host
#security.acme.defaults.renewInterval = "daily";
#security.acme.defaults.reloadServices
# https://www.xf.is/2020/06/30/list-of-free-acme-ssl-providers/
#security.acme.defaults.server = "https://acme-v02.api.letsencrypt.org/directory" # default
#security.acme.defaults.server = "https://acme-staging-v02.api.letsencrypt.org/directory"; # STAGING
#security.acme.defaults.server = "https://api.buypass.com/acme/directory"; # no wildcards, rate limit: 20 domains/week, 5 duplicate certs / week
#security.acme.defaults.server = "https://api.test4.buypass.no/acme/directory"; # STAGING. no wildcards, rate limit: 20 domains/week, 5 duplicate certs / week
# DNS-based ACME:
# - https://go-acme.github.io/lego/dns/domeneshop/
# - https://nixos.org/manual/nixos/stable/index.html#module-security-acme-config-dns-with-vhosts
#security.acme.defaults.dnsProvider = "domeneshop";
#security.acme.defaults.credentialsFile = "/var/lib/secrets/domeneshop.key"; # TODO: this file must be made by hand, containing env variables.
services.nginx.enable = true;
networking.firewall.allowedTCPPorts = [ 80 443 ];
# TODO:
#services.nginx.commonHttpConfig = ''
# proxy_hide_header X-Frame-Options;
#'';
# TODO: Somehow distribute and add this to all location."/".extraConfig
#default = {
# #useACMEHost = config.networking.fqdn;
# forceSSL = true; # addSSL = true;
# enableACME = true; #useACMEHost = acmeDomain;
#}
# TODO: Somehow distribute and add this to all location."/".extraConfig
#commonProxySettings = ''
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
#'';
services.nginx.recommendedGzipSettings = true;
services.nginx.recommendedOptimisation = true;
services.nginx.recommendedProxySettings = true;
services.nginx.recommendedTlsSettings = true;
# nginx return 444 for all nonexistent virtualhosts
services.nginx.virtualHosts."_" = {
addSSL = true;
sslCertificate = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem";
sslCertificateKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem";
extraConfig = "return 444;";
};
/** /
services.nginx.virtualHosts."" = {
default = true;
forceSSL = false;
enableACME = false;
root = pkgs.writeTextDir "index.html" ''
<!DOCTYPE html>
no
'';
};
/**/
# Website tunnel
# TODO: remove
/** /
services.nginx.virtualHosts.${config.networking.fqdn} = {
forceSSL = true; # addSSL = true;
enableACME = true;
#acmeRoot = null; # use DNS
default = true;
serverAliases = map mkDomain [
"www"
#"*" # requires DNS ACME
];
# The alternative to ^ is: config.security.acme.certs."${acmeDomain}".extraDomainNames = [ (mkDomain "foo") ];
# TODO: 'nox' alias for everything
locations."/" = {
proxyPass = "http://pbuntu.pbsds.net";
proxyWebsockets = true;
};
};
#services.nginx.virtualHosts.${mkDomain "www"} = {
# addSSL = true;
# useACMEHost = acmeDomain; #enableACME = true;
# locations."/" = {
# proxyPass = "http://pbuntu.pbsds.net";
# proxyWebsockets = true;
# };
#};
/**/
};
} }

@ -1,6 +1,8 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let let
inherit (config.pbsds.nginx) mkDomain;
cfg = config.services.docs-to-host; cfg = config.services.docs-to-host;
# https://pagefind.app/docs/ui-usage/ # https://pagefind.app/docs/ui-usage/

@ -1,5 +1,7 @@
{ config, pkgs, lib, mkDomain, allSubdomains, ... }: { config, pkgs, lib, ... }:
let let
inherit (config.pbsds.nginx) mkDomain allSubdomains;
# TODO: support fully qualified urls as well # TODO: support fully qualified urls as well
# `null` means filter # `null` means filter
customDescriptions = rec { customDescriptions = rec {

@ -1,4 +1,8 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
# attic - multi-tenant nix binary cache # attic - multi-tenant nix binary cache
# https://docs.attic.rs/tutorial.html # https://docs.attic.rs/tutorial.html

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# CensorDodge # CensorDodge
# A lightweight and customisable web proxy # A lightweight and customisable web proxy

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
lib.mkIf pkgs.unstable.cinny.meta.available # no CVE's thank you lib.mkIf pkgs.unstable.cinny.meta.available # no CVE's thank you

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Convos # Convos
# The simplest way to use IRC in your browser # The simplest way to use IRC in your browser

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Cryptpad # Cryptpad

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Element-web # Element-web
# A glossy Matrix collaboration client for the web # A glossy Matrix collaboration client for the web

@ -3,7 +3,7 @@ let
cfg = config.services.flexget; cfg = config.services.flexget;
in in
# TODO: run in VM mode if we run transmission in the same VM # TODO: run in build-vm mode if we run transmission in the same machine
lib.mkIf (!config.virtualisation.isVmVariant) lib.mkIf (!config.virtualisation.isVmVariant)
{ {

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Galene # Galene
# Videoconferencing server that is easy to deploy, written in Go # Videoconferencing server that is easy to deploy, written in Go

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Gitea # Gitea
# Git with a cup of tea # Git with a cup of tea

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Graphana # Graphana
# Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB # Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# hedgedoc # hedgedoc
# Realtime collaborative markdown notes on all platforms # Realtime collaborative markdown notes on all platforms

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# home-assistant # home-assistant

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Hydra # Hydra
# Nix-based continuous build system # Nix-based continuous build system

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Invidious # Invidious
# An open source alternative front-end to YouTube # An open source alternative front-end to YouTube

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
# don't mount if local VM # don't mount if local VM
lib.mkIf (!config.virtualisation.isVmVariant) lib.mkIf (!config.virtualisation.isVmVariant)

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Jitsi meet # Jitsi meet

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Kukkee # Kukkee
# Self-hosted Doodle alternative: a meeting poll tool # Self-hosted Doodle alternative: a meeting poll tool

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# matrix-synapse # matrix-synapse
/**/ /**/

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Mattermost # Mattermost
# Open-source, self-hosted Slack-alternative # Open-source, self-hosted Slack-alternative

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
# don't mount if local VM # don't mount if local VM
lib.mkIf (!config.virtualisation.isVmVariant) lib.mkIf (!config.virtualisation.isVmVariant)

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Netdata # Netdata
# Real-time performance monitoring tool # Real-time performance monitoring tool

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Nitter # Nitter
# Alternative Twitter front-end # Alternative Twitter front-end

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# ntopng # ntopng
# High-speed web-based traffic analysis and flow collection tool # High-speed web-based traffic analysis and flow collection tool

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# OpenSpeedtTest # OpenSpeedtTest
# Pure HTML5 Network Performance Estimation Tool # Pure HTML5 Network Performance Estimation Tool

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# OwnCast # OwnCast

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# paperless-ngx # paperless-ngx
# A supercharged version of paperless: scan, index, and archive all of your physical documents # A supercharged version of paperless: scan, index, and archive all of your physical documents

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
# don't mount if local VM # don't mount if local VM
lib.mkIf (!config.virtualisation.isVmVariant) lib.mkIf (!config.virtualisation.isVmVariant)

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Polaris # Polaris
# Self-host your music collection, and access it from any computer and mobile device # Self-host your music collection, and access it from any computer and mobile device

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# redlib, previously libreddit # redlib, previously libreddit
# Private front-end for Reddit # Private front-end for Reddit

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
# don't mount if local VM # don't mount if local VM
lib.mkIf (!config.virtualisation.isVmVariant) lib.mkIf (!config.virtualisation.isVmVariant)

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Roundcube # Roundcube
# Open Source Webmail Software # Open Source Webmail Software

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Shlink # Shlink
# URL shortener with REST API and command line interface # URL shortener with REST API and command line interface

@ -1,7 +1,8 @@
# adapted from https://github.com/samrose/dotfiles-1/blob/8887ca3b01edecd83c2e95f01e42885ce26f76c5/nixos/eve/modules/snappymail.nix#L55 # adapted from https://github.com/samrose/dotfiles-1/blob/8887ca3b01edecd83c2e95f01e42885ce26f76c5/nixos/eve/modules/snappymail.nix#L55
{ pkgs, config, lib, mkDomain, ... }: { pkgs, config, lib, ... }:
let let
inherit (config.pbsds.nginx) mkDomain;
maxUploadSize = "256M"; maxUploadSize = "256M";
toKeyValue = lib.generators.toKeyValue { toKeyValue = lib.generators.toKeyValue {
mkKeyValue = lib.generators.mkKeyValueDefault {} " = "; mkKeyValue = lib.generators.mkKeyValueDefault {} " = ";

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# Sourcegraph # Sourcegraph
# Understand, fix, and automate across your codebase with this code intelligence platform # Understand, fix, and automate across your codebase with this code intelligence platform

@ -1,6 +1,9 @@
{ config, lib, mkDomain, inputs, ... }: { config, lib, inputs, ... }:
let let
inherit (config.pbsds.nginx) mkDomain;
myStickerPicker = inputs.maunium-stickerpicker-nix.createStickerPicker { myStickerPicker = inputs.maunium-stickerpicker-nix.createStickerPicker {
#homeserver = "https://matrix.pvv.ntnu.no"; #homeserver = "https://matrix.pvv.ntnu.no";
#userId = "@stickerbot:my.matrix.server"; #userId = "@stickerbot:my.matrix.server";

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# plex admin web ui # plex admin web ui

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# thelunge # thelunge
# The self-hosted Web IRC client # The self-hosted Web IRC client

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# trivial gradios # trivial gradios

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# vaultwarden # vaultwarden
# Unofficial Bitwarden compatible server written in Rust # Unofficial Bitwarden compatible server written in Rust

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# webdav # webdav

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
services.nginx.virtualHosts."kuklef.se" = { services.nginx.virtualHosts."kuklef.se" = {
forceSSL = true; # addSSL = true; forceSSL = true; # addSSL = true;

@ -1,4 +1,7 @@
{ config, pkgs, lib, mkDomain, ... }: { config, pkgs, lib, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# links.pbsds.net # links.pbsds.net

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# refleksjon.no # refleksjon.no

@ -1,4 +1,7 @@
{ config, pkgs, lib, inputs, mkDomain, ... }: { config, pkgs, lib, inputs, ... }:
let
inherit (config.pbsds.nginx) mkDomain;
in
{ {
# roroslyd.no # roroslyd.no