forked from aylac.top/nixcfg
this repo has no description

put all public services in containers. the postgresql databases might've gotten less secure tho because now there's no passwords for them i couldn't figure out how...

Changed files
+226 -141
modules
nixos
profiles
backups
services
forgejo
glance
miniflux
ntfy
pds
postgresql
+3 -3
flake.lock
···
"secrets": {
"flake": false,
"locked": {
-
"lastModified": 1756147116,
-
"narHash": "sha256-g5F0PnFqq+8VNIoYhxtl+Xokwfw2ErNUUoCyu+dMDdo=",
+
"lastModified": 1756518813,
+
"narHash": "sha256-tuhglLbJSQzfWeOYYMnbx4XhwFQp8cF1GdtmznPiKTQ=",
"owner": "ayla6",
"repo": "secrets",
-
"rev": "ef47bc3a658c30bf331035e1380384edcca4f46f",
+
"rev": "646cbc68c306569c502e78a31be22e6c2919b5ae",
"type": "github"
},
"original": {
+18 -9
modules/nixos/profiles/backups/default.nix
···
repo = repoKey;
service = service.name;
};
-
systemdService = service.name;
-
backupMode = service.backupMode or "stop"; # "stop", "notify", "none"
+
systemdService =
+
if service.containerised or false
+
then "container@" + service.name
+
else service.name;
+
backupMode = service.backupMode or "stop"; # "stop", "notify", "quiet"
commands =
if backupMode == "stop"
···
paths = [config.services.couchdb.databaseDir];
}
{
+
# damn this is ugly
name = "forgejo";
-
enable = config.services.forgejo.enable && config.services.forgejo.settings.storage.STORAGE_TYPE != "minio";
-
paths = [config.services.forgejo.stateDir];
+
containerised = true;
+
inherit (config.containers.forgejo.config.services.forgejo) enable;
+
paths = ["/var/lib/nixos-containers/forgejo${config.containers.forgejo.config.services.forgejo.stateDir}"];
backupMode = "none";
}
# {
···
paths = [config.services.ombi.dataDir];
}
{
+
# damn this is ugly
name = "pds";
-
inherit (config.services.bluesky-pds) enable;
-
paths = [config.services.bluesky-pds.settings.PDS_DATA_DIRECTORY];
+
containerised = true;
+
inherit (config.containers.pds.config.services.bluesky-pds) enable;
+
paths = ["/var/lib/nixos-containers/pds${config.containers.pds.config.services.bluesky-pds.settings.PDS_DATA_DIRECTORY}"];
}
{
name = "plex";
···
};
}
{
+
# damn this is ugly
name = "postgresql";
-
inherit (config.services.postgresql) enable;
-
paths = [config.services.postgresql.dataDir];
-
backupMode = "none";
+
containerised = true;
+
inherit (config.containers.postgresql.config.services.postgresql) enable;
+
paths = ["/var/lib/nixos-containers/postgresql${config.containers.postgresql.config.services.postgresql.dataDir}"];
+
backupMode = "quiet";
}
{
name = "prowlarr";
+1
modules/nixos/services/default.nix
···
./nitter
./ntfy
./pds
+
./postgresql
./qbittorrent
./radicale
./redlib
+93 -89
modules/nixos/services/forgejo/default.nix
···
+
# damn this is really messy
{
config,
lib,
pkgs,
-
self,
...
}: let
name = "forgejo";
···
network = config.mySnippets.aylac-top;
service = network.networkMap.${name};
in {
-
options.myNixOS.services.forgejo = {
+
options.myNixOS.services.${name} = {
enable = lib.mkEnableOption "forgejo git forge";
db = lib.mkOption {
···
};
config = lib.mkIf cfg.enable {
-
age.secrets.forgejo.file = "${self.inputs.secrets}/postgres/forgejo.age";
+
services.cloudflared.tunnels."${network.cloudflareTunnel}".ingress = lib.mkIf cfg.autoProxy {
+
"${service.vHost}" = "http://${service.hostName}:${toString service.port}";
+
};
-
services = {
-
cloudflared.tunnels."${network.cloudflareTunnel}".ingress = lib.mkIf cfg.autoProxy {
-
"${service.vHost}" = "http://${service.hostName}:${toString service.port}";
-
};
+
myNixOS.services.postgresql = lib.mkIf (cfg.db == "postgresql") {
+
enable = true;
+
databases = ["forgejo"];
+
};
-
postgresql = lib.mkIf (cfg.db
-
== "postgresql") {
-
enable = true;
-
package = pkgs.postgresql_16;
-
ensureDatabases = ["forgejo"];
+
containers.forgejo = {
+
autoStart = true;
-
ensureUsers = [
-
{
-
name = "forgejo";
-
ensureDBOwnership = true;
-
}
-
];
-
};
+
config = {
+
services = {
+
postgresql.enable = lib.mkForce false;
-
forgejo = {
-
enable = true;
+
forgejo = {
+
enable = true;
-
database = lib.mkIf (cfg.db
-
== "postgresql") {
-
createDatabase = true;
-
host = "127.0.0.1";
-
name = "forgejo";
-
passwordFile = config.age.secrets.forgejo.path;
-
type = "postgres";
-
user = "forgejo";
-
};
+
database = lib.mkIf (cfg.db
+
== "postgresql") {
+
host = "127.0.0.1";
+
name = "forgejo";
+
type = "postgres";
+
user = "forgejo";
+
socket = null;
+
};
-
lfs.enable = true;
-
package = pkgs.forgejo;
+
lfs.enable = true;
+
package = pkgs.forgejo;
-
settings = {
-
actions = {
-
ARTIFACT_RETENTION_DAYS = 15;
-
DEFAULT_ACTIONS_URL = "https://github.com";
-
ENABLED = false;
-
};
+
settings = {
+
actions = {
+
ARTIFACT_RETENTION_DAYS = 15;
+
DEFAULT_ACTIONS_URL = "https://github.com";
+
ENABLED = false;
+
};
-
cron = {
-
ENABLED = true;
-
RUN_AT_START = false;
-
};
+
cron = {
+
ENABLED = true;
+
RUN_AT_START = false;
+
};
-
DEFAULT.APP_NAME = "git.aylac.top";
-
federation.ENABLED = true;
-
indexer.REPO_INDEXER_ENABLED = true;
+
DEFAULT.APP_NAME = "git.aylac.top";
+
federation.ENABLED = true;
+
indexer.REPO_INDEXER_ENABLED = true;
-
log = {
-
ENABLE_SSH_LOG = true;
-
LEVEL = "Debug";
-
};
+
log = {
+
ENABLE_SSH_LOG = true;
+
LEVEL = "Debug";
+
};
-
mailer = {
-
ENABLED = false;
-
};
+
mailer = {
+
ENABLED = false;
+
};
-
migrations = {
-
ALLOW_LOCALNETWORKS = true;
-
};
+
migrations = {
+
ALLOW_LOCALNETWORKS = true;
+
};
-
picture = {
-
AVATAR_MAX_FILE_SIZE = 5242880;
-
ENABLE_FEDERATED_AVATAR = true;
-
};
+
picture = {
+
AVATAR_MAX_FILE_SIZE = 5242880;
+
ENABLE_FEDERATED_AVATAR = true;
+
};
-
repository = {
-
DEFAULT_BRANCH = "main";
-
ENABLE_PUSH_CREATE_ORG = true;
-
ENABLE_PUSH_CREATE_USER = true;
-
PREFERRED_LICENSES = "GPL-3.0";
-
};
+
repository = {
+
DEFAULT_BRANCH = "main";
+
ENABLE_PUSH_CREATE_ORG = true;
+
ENABLE_PUSH_CREATE_USER = true;
+
PREFERRED_LICENSES = "GPL-3.0";
+
};
-
security.PASSWORD_CHECK_PWN = true;
+
security.PASSWORD_CHECK_PWN = true;
-
server = {
-
DOMAIN = service.vHost;
-
HTTP_PORT = service.port;
-
LANDING_PAGE = "explore";
-
LFS_START_SERVER = true;
-
ROOT_URL = "https://${service.vHost}/";
-
DISABLE_SSH = true;
-
};
+
server = {
+
DOMAIN = service.vHost;
+
HTTP_PORT = service.port;
+
LANDING_PAGE = "explore";
+
LFS_START_SERVER = true;
+
ROOT_URL = "https://${service.vHost}/";
+
DISABLE_SSH = true;
+
};
-
service = {
-
ALLOW_ONLY_INTERNAL_REGISTRATION = true;
-
DISABLE_REGISTRATION = true;
-
ENABLE_NOTIFY_MAIL = true;
-
};
+
service = {
+
ALLOW_ONLY_INTERNAL_REGISTRATION = true;
+
DISABLE_REGISTRATION = true;
+
ENABLE_NOTIFY_MAIL = true;
+
};
-
session.COOKIE_SECURE = true;
+
session.COOKIE_SECURE = true;
-
storage = {
-
STORAGE_TYPE = "local";
-
PATH = "/var/lib/forgejo/data";
-
};
+
storage = {
+
STORAGE_TYPE = "local";
+
PATH = "/var/lib/forgejo/data";
+
};
-
ui.DEFAULT_THEME = "forgejo-auto";
+
ui.DEFAULT_THEME = "forgejo-auto";
-
"ui.meta" = {
-
AUTHOR = "Ayla";
-
DESCRIPTION = "i can't set up ssh via cloudflare tunnels!";
-
KEYWORDS = "git,source code,forge,forĝejo,aylac";
+
"ui.meta" = {
+
AUTHOR = "Ayla";
+
DESCRIPTION = "i can't set up ssh via cloudflare tunnels!";
+
KEYWORDS = "git,source code,forge,forgejo,aylac";
+
};
+
};
};
};
+
+
systemd.services.forgejo = lib.mkIf (cfg.db
+
== "postgresql") {
+
after = lib.mkForce ["network.target" "forgejo-secrets.service"];
+
requires = lib.mkForce ["forgejo-secrets.service"];
+
};
+
+
system.stateVersion = "25.11";
};
};
};
+2 -2
modules/nixos/services/glance/default.nix
···
sites = [
{
title = "Vaultwarden";
-
url = "https://${aylac-top.networkMap.vaultwarden.vHost}/";
-
check-url = "http://${aylac-top.networkMap.vaultwarden.hostName}:${toString aylac-top.networkMap.vaultwarden.port}/";
+
url = "https://${tailnet.networkMap.vaultwarden.vHost}/";
+
check-url = "http://${tailnet.networkMap.vaultwarden.hostName}:${toString tailnet.networkMap.vaultwarden.port}/";
icon = "di:vaultwarden";
}
{
+11 -2
modules/nixos/services/miniflux/default.nix
···
};
config = lib.mkIf cfg.enable {
-
age.secrets.miniflux.file = "${self.inputs.secrets}/miniflux.age";
+
age.secrets = {
+
miniflux.file = "${self.inputs.secrets}/miniflux.age";
+
postgresMiniflux.file = "${self.inputs.secrets}/postgres/miniflux.age";
+
};
+
+
myNixOS.services.postgresql = {
+
enable = true;
+
databases = ["miniflux"];
+
};
services = {
caddy.virtualHosts."${service.vHost}".extraConfig = lib.mkIf cfg.autoProxy ''
···
miniflux = {
enable = true;
adminCredentialsFile = config.age.secrets.miniflux.path;
+
createDatabaseLocally = false;
config = {
BATCH_SIZE = 100;
CLEANUP_FREQUENCY_HOURS = 48;
LISTEN_ADDR = "${service.hostName}:${toString service.port}";
BASE_URL = "https://${service.vHost}";
-
WEBAUTHN = 1;
+
DATABASE_URL = ''user=miniflux dbname=miniflux sslmode=disable'';
};
};
};
+33 -28
modules/nixos/services/ntfy/default.nix
···
};
config = lib.mkIf cfg.enable {
-
services = {
-
cloudflared.tunnels."${network.cloudflareTunnel}".ingress = lib.mkIf cfg.autoProxy {
-
"${service.vHost}" = "http://${service.hostName}:${toString service.port}";
-
};
+
services.cloudflared.tunnels."${network.cloudflareTunnel}".ingress = lib.mkIf cfg.autoProxy {
+
"${service.vHost}" = "http://${service.hostName}:${toString service.port}";
+
};
-
ntfy-sh = {
-
enable = true;
-
user = "ntfy";
-
group = "ntfy";
-
settings = {
-
listen-http = ":${toString service.port}";
-
base-url = "https://${service.vHost}";
-
cache-duration = "30d";
-
cache-startup-queries = ''
-
pragma journal_mode = WAL;
-
pragma synchronous = normal;
-
pragma temp_store = memory;
-
'';
-
behind-proxy = true;
-
auth-default-access = "deny-all";
-
auth-users = [
-
"ayla:$2a$10$hh05DMOuVQ3Zf67Rn8VUl.HYUop/.90V04IhNPmOsSYh9FSHCbL1K:admin"
-
"auto:$2a$10$w7EDB/6orrpM9JVBqu4jHeBKvXliA4jvRI7Nd.fn.Fo4rGTHD50ju:user"
-
];
-
auth-access = [
-
"everyone:up*:wo"
-
"auto:*:wo"
-
"everyone:message-to-ayla:wo"
-
];
+
containers.ntfy = {
+
autoStart = true;
+
config = {
+
services.ntfy-sh = {
+
enable = true;
+
user = "ntfy";
+
group = "ntfy";
+
settings = {
+
listen-http = ":${toString service.port}";
+
base-url = "https://${service.vHost}";
+
cache-duration = "30d";
+
cache-startup-queries = ''
+
pragma journal_mode = WAL;
+
pragma synchronous = normal;
+
pragma temp_store = memory;
+
'';
+
behind-proxy = true;
+
auth-default-access = "deny-all";
+
auth-users = [
+
"ayla:$2a$10$hh05DMOuVQ3Zf67Rn8VUl.HYUop/.90V04IhNPmOsSYh9FSHCbL1K:admin"
+
"auto:$2a$10$w7EDB/6orrpM9JVBqu4jHeBKvXliA4jvRI7Nd.fn.Fo4rGTHD50ju:user"
+
];
+
auth-access = [
+
"everyone:up*:wo"
+
"auto:*:wo"
+
"everyone:message-to-ayla:wo"
+
];
+
};
};
+
+
system.stateVersion = "25.11";
};
};
};
+16 -8
modules/nixos/services/pds/default.nix
···
reverse_proxy ${service.hostName}:${toString service.port}
}
'';
+
};
-
bluesky-pds = {
-
enable = true;
-
environmentFiles = [config.age.secrets.pds.path];
-
pdsadmin.enable = true;
-
settings = {
-
PDS_HOSTNAME = service.vHost;
-
# PDS_BSKY_APP_VIEW_URL = "https://bsky.zeppelin.social";
-
# PDS_BSKY_APP_VIEW_DID = "did:web:bsky.zeppelin.social";
+
containers.pds = {
+
autoStart = true;
+
bindMounts."${config.age.secrets.pds.path}".isReadOnly = true;
+
config = {
+
services.bluesky-pds = {
+
enable = true;
+
environmentFiles = [config.age.secrets.pds.path];
+
pdsadmin.enable = true;
+
settings = {
+
PDS_HOSTNAME = service.vHost;
+
# PDS_BSKY_APP_VIEW_URL = "https://bsky.zeppelin.social";
+
# PDS_BSKY_APP_VIEW_DID = "did:web:bsky.zeppelin.social";
+
};
};
+
+
system.stateVersion = "25.11";
};
};
};
+49
modules/nixos/services/postgresql/default.nix
···
+
{
+
lib,
+
config,
+
pkgs,
+
self,
+
...
+
}: let
+
name = "postgresql";
+
cfg = config.myNixOS.services.${name};
+
in {
+
options.myNixOS.services.${name} = {
+
enable = lib.mkEnableOption "${name} server";
+
databases = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
+
default = {};
+
description = "PostgreSQL databases.";
+
};
+
};
+
+
config.containers.postgresql = lib.mkIf cfg.enable {
+
autoStart = true;
+
config = {
+
imports = [self.nixosModules.locale-en-gb];
+
+
services.postgresql = {
+
enable = true;
+
enableTCPIP = true;
+
package = pkgs.postgresql_16;
+
+
ensureDatabases = cfg.databases;
+
ensureUsers =
+
lib.map (dbName: {
+
name = dbName;
+
ensureDBOwnership = true;
+
})
+
cfg.databases;
+
+
authentication = lib.concatStringsSep "\n" (
+
lib.map (dbName: ''
+
host ${dbName} ${dbName} samehost trust
+
'')
+
cfg.databases
+
);
+
};
+
+
system.stateVersion = "25.11";
+
};
+
};
+
}