Compare commits
17 commits
tlater/cro
...
master
Author | SHA1 | Date | |
---|---|---|---|
94ec261a94 | |||
f2cbeebbb5 | |||
fc6be0c4c2 | |||
b067bbc8c0 | |||
913944cff3 | |||
8d0be61483 | |||
63b3cbe00b | |||
5c6b697e55 | |||
fc991a0b07 | |||
09b90433e6 | |||
1bef207356 | |||
cfbc2999d7 | |||
89f9196ef0 | |||
e37c589654 | |||
b396835f88 | |||
ee760bfa1b | |||
3c6afa0c66 |
29 changed files with 697 additions and 601 deletions
.git-blame-ignore-revs
checks
configuration
flake.lockflake.nixmodules/crowdsec
pkgs/crowdsec
|
@ -9,3 +9,6 @@ fd138d45e6a2cad89fead6e9f246ba282070d6b7
|
||||||
|
|
||||||
# Switch to alejandra formatting
|
# Switch to alejandra formatting
|
||||||
046a88905ddfa7f9edc3291c310dbb985dee34f9
|
046a88905ddfa7f9edc3291c310dbb985dee34f9
|
||||||
|
|
||||||
|
# Apply wide linting
|
||||||
|
63b3cbe00be80ccb4b221aad64eb657ae5c96d70
|
||||||
|
|
61
checks/default.nix
Normal file
61
checks/default.nix
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
deploy-rs,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
|
statix' = pkgs.statix.overrideAttrs (old: {
|
||||||
|
patches = old.patches ++ [
|
||||||
|
(pkgs.fetchpatch {
|
||||||
|
url = "https://github.com/oppiliappan/statix/commit/925dec39bb705acbbe77178b4d658fe1b752abbb.patch";
|
||||||
|
hash = "sha256-0wacO6wuYJ4ufN9PGucRVJucFdFFNF+NoHYIrLXsCWs=";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
runNuCheck =
|
||||||
|
{
|
||||||
|
name,
|
||||||
|
packages,
|
||||||
|
check,
|
||||||
|
}:
|
||||||
|
pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
inherit name;
|
||||||
|
|
||||||
|
src = nixpkgs.lib.cleanSourceWith {
|
||||||
|
src = self;
|
||||||
|
filter = nixpkgs.lib.cleanSourceFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
dontPatch = true;
|
||||||
|
dontConfigure = true;
|
||||||
|
dontBuild = true;
|
||||||
|
dontInstall = true;
|
||||||
|
dontFixup = true;
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
checkInputs = nixpkgs.lib.singleton pkgs.nushell ++ packages;
|
||||||
|
|
||||||
|
checkPhase = ''
|
||||||
|
nu ${check}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
nixpkgs.lib.recursiveUpdate {
|
||||||
|
lints = runNuCheck {
|
||||||
|
name = "lints";
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
pkgs.deadnix
|
||||||
|
pkgs.nixfmt-rfc-style
|
||||||
|
pkgs.shellcheck
|
||||||
|
statix'
|
||||||
|
];
|
||||||
|
|
||||||
|
check = ./lints.nu;
|
||||||
|
};
|
||||||
|
} (deploy-rs.lib.${system}.deployChecks self.deploy)
|
39
checks/lints.nu
Normal file
39
checks/lints.nu
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
let shell_files = ls **/*.sh | get name
|
||||||
|
let nix_files = ls **/*.nix | where name !~ "hardware-configuration.nix|_sources" | get name
|
||||||
|
|
||||||
|
let linters = [
|
||||||
|
([shellcheck] ++ $shell_files)
|
||||||
|
([nixfmt --check --strict] ++ $nix_files)
|
||||||
|
([deadnix --fail] ++ $nix_files)
|
||||||
|
([statix check] ++ $nix_files)
|
||||||
|
]
|
||||||
|
|
||||||
|
mkdir $env.out
|
||||||
|
|
||||||
|
def run-linter [linterArgs: list<string>] {
|
||||||
|
print $'Running ($linterArgs.0)...'
|
||||||
|
|
||||||
|
let exit_code = try {
|
||||||
|
^$linterArgs.0 ...($linterArgs | skip 1)
|
||||||
|
$env.LAST_EXIT_CODE
|
||||||
|
} catch {|e| $e.exit_code}
|
||||||
|
|
||||||
|
[$linterArgs.0, $exit_code]
|
||||||
|
}
|
||||||
|
|
||||||
|
let results = $linters | each {|linter| run-linter $linter}
|
||||||
|
|
||||||
|
print 'Linter results:'
|
||||||
|
|
||||||
|
let success = $results | each {|result|
|
||||||
|
match $result.1 {
|
||||||
|
0 => {print $'(ansi green)($result.0)(ansi reset)'}
|
||||||
|
_ => {print $'(ansi red)($result.0)(ansi reset)'}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result.1
|
||||||
|
} | math sum
|
||||||
|
|
||||||
|
exit $success
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
modulesPath,
|
modulesPath,
|
||||||
flake-inputs,
|
flake-inputs,
|
||||||
...
|
...
|
||||||
|
@ -21,6 +19,7 @@
|
||||||
./services/crowdsec.nix
|
./services/crowdsec.nix
|
||||||
./services/foundryvtt.nix
|
./services/foundryvtt.nix
|
||||||
./services/gitea.nix
|
./services/gitea.nix
|
||||||
|
./services/immich.nix
|
||||||
./services/metrics
|
./services/metrics
|
||||||
./services/nextcloud.nix
|
./services/nextcloud.nix
|
||||||
./services/webserver.nix
|
./services/webserver.nix
|
||||||
|
@ -31,13 +30,7 @@
|
||||||
./sops.nix
|
./sops.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [ (_: prev: { local = import ../pkgs { pkgs = prev; }; }) ];
|
||||||
(final: prev: {
|
|
||||||
local = import ../pkgs {
|
|
||||||
pkgs = prev;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
extraOptions = ''
|
extraOptions = ''
|
||||||
|
|
|
@ -80,6 +80,17 @@
|
||||||
inherit mountOptions;
|
inherit mountOptions;
|
||||||
mountpoint = "/var";
|
mountpoint = "/var";
|
||||||
};
|
};
|
||||||
|
"/volume/var/lib/private/matrix-conduit" = {
|
||||||
|
mountOptions = [
|
||||||
|
# Explicitly don't compress here, since
|
||||||
|
# conduwuit's database does compression by
|
||||||
|
# itself, and relies on being able to read the
|
||||||
|
# raw file data from disk (which is impossible
|
||||||
|
# if btrfs compresses it)
|
||||||
|
"noatime"
|
||||||
|
];
|
||||||
|
mountpoint = "/var/lib/private/matrix-conduit";
|
||||||
|
};
|
||||||
"/volume/nix-store" = {
|
"/volume/nix-store" = {
|
||||||
inherit mountOptions;
|
inherit mountOptions;
|
||||||
mountpoint = "/nix";
|
mountpoint = "/nix";
|
||||||
|
|
|
@ -6,26 +6,35 @@
|
||||||
boot.kernelParams = [ "nomodeset" ];
|
boot.kernelParams = [ "nomodeset" ];
|
||||||
|
|
||||||
networking.hostName = "testvm";
|
networking.hostName = "testvm";
|
||||||
|
|
||||||
|
services = {
|
||||||
# Sets the base domain for nginx to a local domain so that we can
|
# Sets the base domain for nginx to a local domain so that we can
|
||||||
# easily test locally with the VM.
|
# easily test locally with the VM.
|
||||||
services.nginx.domain = "dev.local";
|
nginx.domain = "dev.local";
|
||||||
|
|
||||||
|
# Don't run this
|
||||||
|
batteryManager.enable = lib.mkForce false;
|
||||||
|
|
||||||
|
openssh.hostKeys = lib.mkForce [
|
||||||
|
{
|
||||||
|
type = "rsa";
|
||||||
|
bits = 4096;
|
||||||
|
path = "/etc/staging.key";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Use the staging secrets
|
# Use the staging secrets
|
||||||
sops.defaultSopsFile = lib.mkOverride 99 ../../keys/staging.yaml;
|
sops.defaultSopsFile = lib.mkOverride 99 ../../keys/staging.yaml;
|
||||||
|
|
||||||
systemd.network.networks."10-eth0" = {
|
systemd.network.networks."10-eth0" = {
|
||||||
matchConfig.Name = "eth0";
|
matchConfig.Name = "eth0";
|
||||||
gateway = [
|
gateway = [ "192.168.9.1" ];
|
||||||
"192.168.9.1"
|
|
||||||
];
|
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
Address = "192.168.9.2/24";
|
Address = "192.168.9.2/24";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Don't run this
|
|
||||||
services.batteryManager.enable = lib.mkForce false;
|
|
||||||
|
|
||||||
# Both so we have a predictable key for the staging env, as well as
|
# Both so we have a predictable key for the staging env, as well as
|
||||||
# to have a static key for decrypting the sops secrets for the
|
# to have a static key for decrypting the sops secrets for the
|
||||||
# staging env.
|
# staging env.
|
||||||
|
@ -34,14 +43,6 @@
|
||||||
source = ../../keys/hosts/staging.key;
|
source = ../../keys/hosts/staging.key;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.openssh.hostKeys = lib.mkForce [
|
|
||||||
{
|
|
||||||
type = "rsa";
|
|
||||||
bits = 4096;
|
|
||||||
path = "/etc/staging.key";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
virtualisation.vmVariant = {
|
virtualisation.vmVariant = {
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
memorySize = 3941;
|
memorySize = 3941;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
{
|
{
|
||||||
services.nginx = {
|
services = {
|
||||||
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
recommendedTlsSettings = true;
|
recommendedTlsSettings = true;
|
||||||
recommendedOptimisation = true;
|
recommendedOptimisation = true;
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logrotate.settings =
|
logrotate.settings =
|
||||||
{
|
{
|
||||||
# Override the default, just keep fewer logs
|
# Override the default, just keep fewer logs
|
||||||
nginx.rotate = 6;
|
nginx.rotate = 6;
|
||||||
|
@ -36,6 +37,14 @@
|
||||||
}
|
}
|
||||||
) config.services.nginx.virtualHosts;
|
) config.services.nginx.virtualHosts;
|
||||||
|
|
||||||
|
backups.acme = {
|
||||||
|
user = "acme";
|
||||||
|
paths = lib.mapAttrsToList (
|
||||||
|
virtualHost: _: "/var/lib/acme/${virtualHost}"
|
||||||
|
) config.services.nginx.virtualHosts;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
systemd.tmpfiles.rules = lib.mapAttrsToList (
|
systemd.tmpfiles.rules = lib.mapAttrsToList (
|
||||||
virtualHost: _:
|
virtualHost: _:
|
||||||
#
|
#
|
||||||
|
@ -66,11 +75,4 @@
|
||||||
systemd.services.nginx.serviceConfig.SupplementaryGroups = [
|
systemd.services.nginx.serviceConfig.SupplementaryGroups = [
|
||||||
config.security.acme.certs."tlater.net".group
|
config.security.acme.certs."tlater.net".group
|
||||||
];
|
];
|
||||||
|
|
||||||
services.backups.acme = {
|
|
||||||
user = "acme";
|
|
||||||
paths = lib.mapAttrsToList (
|
|
||||||
virtualHost: _: "/var/lib/acme/${virtualHost}"
|
|
||||||
) config.services.nginx.virtualHosts;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ in
|
||||||
'';
|
'';
|
||||||
type = types.attrsOf (
|
type = types.attrsOf (
|
||||||
types.submodule (
|
types.submodule (
|
||||||
{ config, name, ... }:
|
{ name, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
|
@ -246,7 +246,7 @@ in
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// lib.mapAttrs' (
|
// lib.mapAttrs' (
|
||||||
name: backup:
|
name: _:
|
||||||
lib.nameValuePair "backup-${name}" {
|
lib.nameValuePair "backup-${name}" {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -16,12 +17,15 @@ in
|
||||||
./matrix-hookshot.nix
|
./matrix-hookshot.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.matrix-conduit = {
|
services = {
|
||||||
|
matrix-conduit = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = pkgs.matrix-continuwuity;
|
||||||
settings.global = {
|
settings.global = {
|
||||||
address = "127.0.0.1";
|
address = "127.0.0.1";
|
||||||
server_name = domain;
|
server_name = domain;
|
||||||
database_backend = "rocksdb";
|
new_user_displayname_suffix = "🦆";
|
||||||
|
allow_check_for_updates = true;
|
||||||
|
|
||||||
# Set up delegation: https://docs.conduit.rs/delegation.html#automatic-recommended
|
# Set up delegation: https://docs.conduit.rs/delegation.html#automatic-recommended
|
||||||
# This is primarily to make sliding sync work
|
# This is primarily to make sliding sync work
|
||||||
|
@ -44,17 +48,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Pass in the TURN secret via EnvironmentFile, not supported by
|
coturn = {
|
||||||
# upstream module currently.
|
|
||||||
#
|
|
||||||
# See also https://gitlab.com/famedly/conduit/-/issues/314
|
|
||||||
systemd.services.conduit.serviceConfig.EnvironmentFile = config.sops.secrets."turn/env".path;
|
|
||||||
|
|
||||||
systemd.services.coturn.serviceConfig.SupplementaryGroups = [
|
|
||||||
config.security.acme.certs."tlater.net".group
|
|
||||||
];
|
|
||||||
|
|
||||||
services.coturn = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
no-cli = true;
|
no-cli = true;
|
||||||
use-auth-secret = true;
|
use-auth-secret = true;
|
||||||
|
@ -110,7 +104,7 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts."${domain}" = {
|
nginx.virtualHosts."${domain}" = {
|
||||||
useACMEHost = "tlater.net";
|
useACMEHost = "tlater.net";
|
||||||
|
|
||||||
listen = [
|
listen = [
|
||||||
|
@ -164,11 +158,25 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.backups.conduit = {
|
backups.conduit = {
|
||||||
user = "root";
|
user = "root";
|
||||||
paths = [ "/var/lib/private/matrix-conduit/" ];
|
paths = [ "/var/lib/private/matrix-conduit/" ];
|
||||||
# Other services store their data in conduit, so no other services
|
# Other services store their data in conduit, so no other services
|
||||||
# need to be shut down currently.
|
# need to be shut down currently.
|
||||||
pauseServices = [ "conduit.service" ];
|
pauseServices = [ "conduit.service" ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.conduit.serviceConfig = {
|
||||||
|
ExecStart = lib.mkForce "${config.services.matrix-conduit.package}/bin/conduwuit";
|
||||||
|
# Pass in the TURN secret via EnvironmentFile, not supported by
|
||||||
|
# upstream module currently.
|
||||||
|
#
|
||||||
|
# See also https://gitlab.com/famedly/conduit/-/issues/314
|
||||||
|
EnvironmentFile = config.sops.secrets."turn/env".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.coturn.serviceConfig.SupplementaryGroups = [
|
||||||
|
config.security.acme.certs."tlater.net".group
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,29 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
# Encryption support
|
# Encryption support
|
||||||
extraSettings = {
|
# TODO(tlater): Enable when
|
||||||
"de.sorunome.msc2409.push_ephemeral" = true;
|
# https://github.com/matrix-org/matrix-hookshot/issues/1060 is
|
||||||
push_ephemeral = true;
|
# fixed
|
||||||
"org.matrix.msc3202" = true;
|
# extraSettings = {
|
||||||
};
|
# "de.sorunome.msc2409.push_ephemeral" = true;
|
||||||
|
# push_ephemeral = true;
|
||||||
|
# "org.matrix.msc3202" = true;
|
||||||
|
# };
|
||||||
|
|
||||||
runtimeRegistration = "${cfg.registrationFile}";
|
runtimeRegistration = "${cfg.registrationFile}";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
# users = {
|
||||||
|
# users.matrix-hookshot = {
|
||||||
|
# home = "/run/matrix-hookshot";
|
||||||
|
# group = "matrix-hookshot";
|
||||||
|
# isSystemUser = true;
|
||||||
|
# };
|
||||||
|
|
||||||
|
# groups.matrix-hookshot = { };
|
||||||
|
# };
|
||||||
|
|
||||||
systemd.services.matrix-hookshot = {
|
systemd.services.matrix-hookshot = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = lib.mkForce "exec";
|
Type = lib.mkForce "exec";
|
||||||
|
@ -49,6 +62,7 @@ in
|
||||||
# Some library in matrix-hookshot wants a home directory
|
# Some library in matrix-hookshot wants a home directory
|
||||||
Environment = [ "HOME=/run/matrix-hookshot" ];
|
Environment = [ "HOME=/run/matrix-hookshot" ];
|
||||||
|
|
||||||
|
# User = "matrix-hookshot";
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
StateDirectory = "matrix-hookshot";
|
StateDirectory = "matrix-hookshot";
|
||||||
RuntimeDirectory = "matrix-hookshot";
|
RuntimeDirectory = "matrix-hookshot";
|
||||||
|
@ -62,7 +76,11 @@ in
|
||||||
ProtectKernelModules = true;
|
ProtectKernelModules = true;
|
||||||
ProtectKernelLogs = true;
|
ProtectKernelLogs = true;
|
||||||
ProtectControlGroups = true;
|
ProtectControlGroups = true;
|
||||||
RestrictAddressFamilies = [ "AF_INET AF_INET6" ];
|
RestrictAddressFamilies = [
|
||||||
|
# "AF_UNIX"
|
||||||
|
"AF_INET"
|
||||||
|
"AF_INET6"
|
||||||
|
];
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
ProtectProc = "invisible";
|
ProtectProc = "invisible";
|
||||||
|
@ -71,12 +89,15 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# services.redis.servers.matrix-hookshot = {
|
||||||
|
# enable = true;
|
||||||
|
# user = "matrix-hookshot";
|
||||||
|
# };
|
||||||
|
|
||||||
services.matrix-hookshot = {
|
services.matrix-hookshot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
serviceDependencies = [
|
serviceDependencies = [ "conduit.service" ];
|
||||||
"conduit.service"
|
|
||||||
];
|
|
||||||
|
|
||||||
registrationFile = "/run/matrix-hookshot/registration.yaml";
|
registrationFile = "/run/matrix-hookshot/registration.yaml";
|
||||||
|
|
||||||
|
@ -91,6 +112,8 @@ in
|
||||||
|
|
||||||
bot.displayname = "Hookshot";
|
bot.displayname = "Hookshot";
|
||||||
|
|
||||||
|
# cache.redisUri = "redis://${config.services.redis.servers.matrix-hookshot.unixSocket}";
|
||||||
|
|
||||||
generic = {
|
generic = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
outbound = false;
|
outbound = false;
|
||||||
|
@ -100,7 +123,10 @@ in
|
||||||
allowJsTransformationFunctions = true;
|
allowJsTransformationFunctions = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
encryption.storagePath = "/var/lib/matrix-hookshot/cryptostore";
|
# TODO(tlater): Enable when
|
||||||
|
# https://github.com/matrix-org/matrix-hookshot/issues/1060 is
|
||||||
|
# fixed
|
||||||
|
# encryption.storagePath = "/var/lib/matrix-hookshot/cryptostore";
|
||||||
|
|
||||||
permissions = [
|
permissions = [
|
||||||
{
|
{
|
||||||
|
@ -126,19 +152,15 @@ in
|
||||||
listeners = [
|
listeners = [
|
||||||
{
|
{
|
||||||
port = 9000;
|
port = 9000;
|
||||||
resources = [
|
resources = [ "webhooks" ];
|
||||||
"webhooks"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
port = 9001;
|
port = 9001;
|
||||||
resources = [
|
resources = [ "metrics" ];
|
||||||
"metrics"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
metrics.enable = true;
|
metrics.enabled = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
security.crowdsec = {
|
security.crowdsec = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
parserWhitelist = [
|
parserWhitelist = [ "10.45.249.2" ];
|
||||||
"10.45.249.2"
|
|
||||||
];
|
|
||||||
|
|
||||||
extraGroups = [
|
extraGroups = [
|
||||||
"systemd-journal"
|
"systemd-journal"
|
||||||
|
@ -21,25 +19,19 @@
|
||||||
{
|
{
|
||||||
source = "journalctl";
|
source = "journalctl";
|
||||||
labels.type = "syslog";
|
labels.type = "syslog";
|
||||||
journalctl_filter = [
|
journalctl_filter = [ "SYSLOG_IDENTIFIER=Nextcloud" ];
|
||||||
"SYSLOG_IDENTIFIER=Nextcloud"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
source = "journalctl";
|
source = "journalctl";
|
||||||
labels.type = "syslog";
|
labels.type = "syslog";
|
||||||
journalctl_filter = [
|
journalctl_filter = [ "SYSLOG_IDENTIFIER=sshd-session" ];
|
||||||
"SYSLOG_IDENTIFIER=sshd-session"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
labels.type = "nginx";
|
labels.type = "nginx";
|
||||||
filenames =
|
filenames =
|
||||||
[
|
[ "/var/log/nginx/*.log" ]
|
||||||
"/var/log/nginx/*.log"
|
|
||||||
]
|
|
||||||
++ lib.mapAttrsToList (
|
++ lib.mapAttrsToList (
|
||||||
vHost: _: "/var/log/nginx/${vHost}/access.log"
|
vHost: _: "/var/log/nginx/${vHost}/access.log"
|
||||||
) config.services.nginx.virtualHosts;
|
) config.services.nginx.virtualHosts;
|
||||||
|
|
|
@ -11,20 +11,17 @@ in
|
||||||
{
|
{
|
||||||
imports = [ flake-inputs.foundryvtt.nixosModules.foundryvtt ];
|
imports = [ flake-inputs.foundryvtt.nixosModules.foundryvtt ];
|
||||||
|
|
||||||
services.foundryvtt = {
|
services = {
|
||||||
|
foundryvtt = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostName = domain;
|
hostName = domain;
|
||||||
minifyStaticFiles = true;
|
minifyStaticFiles = true;
|
||||||
proxySSL = true;
|
proxySSL = true;
|
||||||
proxyPort = 443;
|
proxyPort = 443;
|
||||||
package = flake-inputs.foundryvtt.packages.${pkgs.system}.foundryvtt_11;
|
package = flake-inputs.foundryvtt.packages.${pkgs.system}.foundryvtt_13;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Want to start it manually when I need it, not have it constantly
|
nginx.virtualHosts."${domain}" =
|
||||||
# running
|
|
||||||
systemd.services.foundryvtt.wantedBy = lib.mkForce [ ];
|
|
||||||
|
|
||||||
services.nginx.virtualHosts."${domain}" =
|
|
||||||
let
|
let
|
||||||
inherit (config.services.foundryvtt) port;
|
inherit (config.services.foundryvtt) port;
|
||||||
in
|
in
|
||||||
|
@ -39,9 +36,14 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.backups.foundryvtt = {
|
backups.foundryvtt = {
|
||||||
user = "foundryvtt";
|
user = "foundryvtt";
|
||||||
paths = [ config.services.foundryvtt.dataDir ];
|
paths = [ config.services.foundryvtt.dataDir ];
|
||||||
pauseServices = [ "foundryvtt.service" ];
|
pauseServices = [ "foundryvtt.service" ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Want to start it manually when I need it, not have it constantly
|
||||||
|
# running
|
||||||
|
systemd.services.foundryvtt.wantedBy = lib.mkForce [ ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ let
|
||||||
domain = "gitea.${config.services.nginx.domain}";
|
domain = "gitea.${config.services.nginx.domain}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.forgejo = {
|
services = {
|
||||||
|
forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
database.type = "postgres";
|
database.type = "postgres";
|
||||||
|
|
||||||
|
@ -29,16 +30,8 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.forgejo.serviceConfig.ExecStartPre =
|
|
||||||
let
|
|
||||||
replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret";
|
|
||||||
secretPath = config.sops.secrets."forgejo/metrics-token".path;
|
|
||||||
runConfig = "${config.services.forgejo.customDir}/conf/app.ini";
|
|
||||||
in
|
|
||||||
[ "+${replaceSecretBin} '#metricstoken#' '${secretPath}' '${runConfig}'" ];
|
|
||||||
|
|
||||||
# Set up SSL
|
# Set up SSL
|
||||||
services.nginx.virtualHosts."${domain}" =
|
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;
|
||||||
|
@ -59,7 +52,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.backups.forgejo = {
|
backups.forgejo = {
|
||||||
user = "forgejo";
|
user = "forgejo";
|
||||||
paths = [
|
paths = [
|
||||||
"/var/lib/forgejo/forgejo-db.sql"
|
"/var/lib/forgejo/forgejo-db.sql"
|
||||||
|
@ -78,4 +71,13 @@ in
|
||||||
};
|
};
|
||||||
pauseServices = [ "forgejo.service" ];
|
pauseServices = [ "forgejo.service" ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.forgejo.serviceConfig.ExecStartPre =
|
||||||
|
let
|
||||||
|
replaceSecretBin = "${pkgs.replace-secret}/bin/replace-secret";
|
||||||
|
secretPath = config.sops.secrets."forgejo/metrics-token".path;
|
||||||
|
runConfig = "${config.services.forgejo.customDir}/conf/app.ini";
|
||||||
|
in
|
||||||
|
[ "+${replaceSecretBin} '#metricstoken#' '${secretPath}' '${runConfig}'" ];
|
||||||
}
|
}
|
||||||
|
|
67
configuration/services/immich.nix
Normal file
67
configuration/services/immich.nix
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
hostName = "immich.${config.services.nginx.domain}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services = {
|
||||||
|
immich = {
|
||||||
|
enable = true;
|
||||||
|
settings.server.externalDomain = "https://${hostName}";
|
||||||
|
|
||||||
|
environment.IMMICH_TELEMETRY_INCLUDE = "all";
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx.virtualHosts.${hostName} =
|
||||||
|
let
|
||||||
|
local = "http://${config.services.immich.host}:${toString config.services.immich.port}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
forceSSL = true;
|
||||||
|
useACMEHost = "tlater.net";
|
||||||
|
enableHSTS = true;
|
||||||
|
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = local;
|
||||||
|
proxyWebsockets = true;
|
||||||
|
};
|
||||||
|
locations."/metrics" = {
|
||||||
|
extraConfig = ''
|
||||||
|
access_log off;
|
||||||
|
allow 127.0.0.1;
|
||||||
|
${lib.optionalString config.networking.enableIPv6 "allow ::1;"}
|
||||||
|
deny all;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
backups.immich =
|
||||||
|
let
|
||||||
|
db-dump = "${config.services.immich.mediaLocation}/immich-db.sql";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
user = "immich";
|
||||||
|
paths = [ config.services.immich.mediaLocation ];
|
||||||
|
|
||||||
|
preparation = {
|
||||||
|
packages = [ config.services.postgresql.package ];
|
||||||
|
text = ''
|
||||||
|
pg_dump ${config.services.immich.database.name} --clean --if-exists --file=${db-dump}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
cleanup = {
|
||||||
|
packages = [ pkgs.coreutils ];
|
||||||
|
text = "rm ${db-dump}";
|
||||||
|
};
|
||||||
|
pauseServices = [
|
||||||
|
"immich-server.service"
|
||||||
|
"immich-machine-learning.service"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -74,7 +74,7 @@ in
|
||||||
listenAddress = "127.0.0.1";
|
listenAddress = "127.0.0.1";
|
||||||
group = "nginx";
|
group = "nginx";
|
||||||
|
|
||||||
settings.namespaces = lib.mapAttrsToList (name: virtualHost: {
|
settings.namespaces = lib.mapAttrsToList (name: _: {
|
||||||
inherit name;
|
inherit name;
|
||||||
metrics_override.prefix = "nginxlog";
|
metrics_override.prefix = "nginxlog";
|
||||||
namespace_label = "vhost";
|
namespace_label = "vhost";
|
||||||
|
@ -97,4 +97,6 @@ in
|
||||||
# - postgres (?)
|
# - postgres (?)
|
||||||
# - ssl_exporter (?)
|
# - ssl_exporter (?)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.dbus.implementation = "broker";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
{
|
{ pkgs, config, ... }:
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
flake-inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
domain = "metrics.${config.services.nginx.domain}";
|
domain = "metrics.${config.services.nginx.domain}";
|
||||||
in
|
in
|
||||||
|
@ -35,7 +30,7 @@ in
|
||||||
|
|
||||||
declarativePlugins = [
|
declarativePlugins = [
|
||||||
pkgs.grafanaPlugins.victoriametrics-metrics-datasource
|
pkgs.grafanaPlugins.victoriametrics-metrics-datasource
|
||||||
flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.grafanaPlugins.victoriametrics-logs-datasource
|
pkgs.grafanaPlugins.victoriametrics-logs-datasource
|
||||||
];
|
];
|
||||||
|
|
||||||
provision = {
|
provision = {
|
||||||
|
|
|
@ -38,7 +38,7 @@ in
|
||||||
services.victoriametrics.scrapeConfigs = mkOption {
|
services.victoriametrics.scrapeConfigs = mkOption {
|
||||||
type = types.attrsOf (
|
type = types.attrsOf (
|
||||||
types.submodule (
|
types.submodule (
|
||||||
{ name, self, ... }:
|
{ name, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
job_name = mkOption {
|
job_name = mkOption {
|
||||||
|
@ -106,35 +106,37 @@ in
|
||||||
# module is an intractable mess
|
# module is an intractable mess
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
serviceConfig.Restart = mkDefault "always";
|
serviceConfig = {
|
||||||
serviceConfig.PrivateTmp = mkDefault true;
|
Restart = mkDefault "always";
|
||||||
serviceConfig.WorkingDirectory = mkDefault /tmp;
|
PrivateTmp = mkDefault true;
|
||||||
serviceConfig.DynamicUser = mkDefault true;
|
WorkingDirectory = mkDefault /tmp;
|
||||||
|
DynamicUser = mkDefault true;
|
||||||
# Hardening
|
# Hardening
|
||||||
serviceConfig.CapabilityBoundingSet = mkDefault [ "" ];
|
CapabilityBoundingSet = mkDefault [ "" ];
|
||||||
serviceConfig.DeviceAllow = [ "" ];
|
DeviceAllow = [ "" ];
|
||||||
serviceConfig.LockPersonality = true;
|
LockPersonality = true;
|
||||||
serviceConfig.MemoryDenyWriteExecute = true;
|
MemoryDenyWriteExecute = true;
|
||||||
serviceConfig.NoNewPrivileges = true;
|
NoNewPrivileges = true;
|
||||||
serviceConfig.PrivateDevices = mkDefault true;
|
PrivateDevices = mkDefault true;
|
||||||
serviceConfig.ProtectClock = mkDefault true;
|
ProtectClock = mkDefault true;
|
||||||
serviceConfig.ProtectControlGroups = true;
|
ProtectControlGroups = true;
|
||||||
serviceConfig.ProtectHome = true;
|
ProtectHome = true;
|
||||||
serviceConfig.ProtectHostname = true;
|
ProtectHostname = true;
|
||||||
serviceConfig.ProtectKernelLogs = true;
|
ProtectKernelLogs = true;
|
||||||
serviceConfig.ProtectKernelModules = true;
|
ProtectKernelModules = true;
|
||||||
serviceConfig.ProtectKernelTunables = true;
|
ProtectKernelTunables = true;
|
||||||
serviceConfig.ProtectSystem = mkDefault "strict";
|
ProtectSystem = mkDefault "strict";
|
||||||
serviceConfig.RemoveIPC = true;
|
RemoveIPC = true;
|
||||||
serviceConfig.RestrictAddressFamilies = [
|
RestrictAddressFamilies = [
|
||||||
"AF_INET"
|
"AF_INET"
|
||||||
"AF_INET6"
|
"AF_INET6"
|
||||||
];
|
];
|
||||||
serviceConfig.RestrictNamespaces = true;
|
RestrictNamespaces = true;
|
||||||
serviceConfig.RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
serviceConfig.RestrictSUIDSGID = true;
|
RestrictSUIDSGID = true;
|
||||||
serviceConfig.SystemCallArchitectures = "native";
|
SystemCallArchitectures = "native";
|
||||||
serviceConfig.UMask = "0077";
|
UMask = "0077";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
exporter.serviceOpts
|
exporter.serviceOpts
|
||||||
]
|
]
|
||||||
|
@ -144,7 +146,7 @@ in
|
||||||
{
|
{
|
||||||
vmagent-scrape-exporters =
|
vmagent-scrape-exporters =
|
||||||
let
|
let
|
||||||
listenAddress = config.services.victoriametrics.listenAddress;
|
inherit (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 (
|
||||||
|
@ -153,7 +155,7 @@ in
|
||||||
inherit (scrape) job_name;
|
inherit (scrape) job_name;
|
||||||
static_configs =
|
static_configs =
|
||||||
scrape.static_configs
|
scrape.static_configs
|
||||||
++ lib.optional (scrape.targets != [ ]) { targets = scrape.targets; };
|
++ lib.optional (scrape.targets != [ ]) { inherit (scrape) targets; };
|
||||||
} scrape.extraSettings
|
} scrape.extraSettings
|
||||||
) config.services.victoriametrics.scrapeConfigs;
|
) config.services.victoriametrics.scrapeConfigs;
|
||||||
};
|
};
|
||||||
|
@ -212,7 +214,7 @@ in
|
||||||
|
|
||||||
services.victoriametrics.scrapeConfigs =
|
services.victoriametrics.scrapeConfigs =
|
||||||
let
|
let
|
||||||
allExporters = lib.mapAttrs (name: exporter: { inherit (exporter) listenAddress port; }) (
|
allExporters = lib.mapAttrs (_: exporter: { inherit (exporter) listenAddress port; }) (
|
||||||
(lib.filterAttrs (
|
(lib.filterAttrs (
|
||||||
name: exporter:
|
name: exporter:
|
||||||
# A bunch of deprecated exporters that need to be ignored
|
# A bunch of deprecated exporters that need to be ignored
|
||||||
|
|
|
@ -1,37 +1,22 @@
|
||||||
{
|
{ config, lib, ... }:
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
cfg = config.services.victorialogs;
|
cfg = config.services.victorialogs;
|
||||||
pkg = pkgs.victoriametrics;
|
|
||||||
dirname = "victorialogs";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.victorialogs =
|
options.services.victorialogs.bindAddress = lib.mkOption {
|
||||||
let
|
|
||||||
inherit (lib.types) str;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
listenAddress = lib.mkOption {
|
|
||||||
default = ":9428";
|
|
||||||
type = str;
|
|
||||||
};
|
|
||||||
|
|
||||||
bindAddress = lib.mkOption {
|
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
type = str;
|
type = lib.types.str;
|
||||||
description = ''
|
description = ''
|
||||||
Final address on which victorialogs listens.
|
Final address on which victorialogs listens.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
services.victorialogs.bindAddress =
|
services.victorialogs = {
|
||||||
|
enable = true;
|
||||||
|
bindAddress =
|
||||||
(lib.optionalString (lib.hasPrefix ":" cfg.listenAddress) "127.0.0.1") + cfg.listenAddress;
|
(lib.optionalString (lib.hasPrefix ":" cfg.listenAddress) "127.0.0.1") + cfg.listenAddress;
|
||||||
|
};
|
||||||
|
|
||||||
services.journald.upload = {
|
services.journald.upload = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -40,71 +25,6 @@ in
|
||||||
NetworkTimeoutSec = "20s";
|
NetworkTimeoutSec = "20s";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services."systemd-journal-upload".after = [ "victorialogs.service" ];
|
systemd.services."systemd-journal-upload".after = [ "victorialogs.service" ];
|
||||||
|
|
||||||
systemd.services.victorialogs = {
|
|
||||||
description = "VictoriaLogs log database";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
after = [ "network.target" ];
|
|
||||||
startLimitBurst = 5;
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = lib.escapeShellArgs [
|
|
||||||
"${pkg}/bin/victoria-logs"
|
|
||||||
"-storageDataPath=/var/lib/${dirname}"
|
|
||||||
"-httpListenAddr=${cfg.listenAddress}"
|
|
||||||
];
|
|
||||||
|
|
||||||
DynamicUser = true;
|
|
||||||
RestartSec = 1;
|
|
||||||
Restart = "on-failure";
|
|
||||||
RuntimeDirectory = dirname;
|
|
||||||
RuntimeDirectoryMode = "0700";
|
|
||||||
StateDirectory = dirname;
|
|
||||||
StateDirectoryMode = "0700";
|
|
||||||
|
|
||||||
LimitNOFILE = 1048576;
|
|
||||||
|
|
||||||
# Hardening
|
|
||||||
DeviceAllow = [ "/dev/null rw" ];
|
|
||||||
DevicePolicy = "strict";
|
|
||||||
LockPersonality = true;
|
|
||||||
MemoryDenyWriteExecute = true;
|
|
||||||
NoNewPrivileges = true;
|
|
||||||
PrivateDevices = true;
|
|
||||||
PrivateTmp = true;
|
|
||||||
PrivateUsers = true;
|
|
||||||
ProtectClock = true;
|
|
||||||
ProtectControlGroups = true;
|
|
||||||
ProtectHome = true;
|
|
||||||
ProtectHostname = true;
|
|
||||||
ProtectKernelLogs = true;
|
|
||||||
ProtectKernelModules = true;
|
|
||||||
ProtectKernelTunables = true;
|
|
||||||
ProtectProc = "invisible";
|
|
||||||
ProtectSystem = "full";
|
|
||||||
RemoveIPC = true;
|
|
||||||
RestrictAddressFamilies = [
|
|
||||||
"AF_INET"
|
|
||||||
"AF_INET6"
|
|
||||||
"AF_UNIX"
|
|
||||||
];
|
|
||||||
RestrictNamespaces = true;
|
|
||||||
RestrictRealtime = true;
|
|
||||||
RestrictSUIDSGID = true;
|
|
||||||
SystemCallArchitectures = "native";
|
|
||||||
SystemCallFilter = [
|
|
||||||
"@system-service"
|
|
||||||
"~@privileged"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
postStart = lib.mkBefore ''
|
|
||||||
until ${lib.getBin pkgs.curl}/bin/curl -s -o /dev/null http://${cfg.bindAddress}/ping; do
|
|
||||||
sleep 1;
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,16 @@ in
|
||||||
in
|
in
|
||||||
[ "${address}:${toString port}" ];
|
[ "${address}:${toString port}" ];
|
||||||
|
|
||||||
|
immich.targets = [
|
||||||
|
"127.0.0.1:8081"
|
||||||
|
"127.0.0.1:8082"
|
||||||
|
];
|
||||||
|
|
||||||
# Configured in the hookshot listeners, but it's hard to filter
|
# Configured in the hookshot listeners, but it's hard to filter
|
||||||
# the correct values out of that config.
|
# the correct values out of that config.
|
||||||
matrixHookshot.targets = [ "127.0.0.1:9001" ];
|
matrixHookshot.targets = [ "127.0.0.1:9001" ];
|
||||||
|
|
||||||
|
victorialogs.targets = [ config.services.victorialogs.bindAddress ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,24 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
nextcloud = pkgs.nextcloud30;
|
nextcloud = pkgs.nextcloud31;
|
||||||
hostName = "nextcloud.${config.services.nginx.domain}";
|
hostName = "nextcloud.${config.services.nginx.domain}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.nextcloud = {
|
services = {
|
||||||
|
nextcloud = {
|
||||||
inherit hostName;
|
inherit hostName;
|
||||||
|
|
||||||
package = nextcloud;
|
package = nextcloud;
|
||||||
phpPackage = lib.mkForce (
|
phpPackage = lib.mkForce (
|
||||||
pkgs.php.override {
|
pkgs.php.override {
|
||||||
packageOverrides = final: prev: {
|
packageOverrides = _: prev: {
|
||||||
extensions = prev.extensions // {
|
extensions = prev.extensions // {
|
||||||
pgsql = prev.extensions.pgsql.overrideAttrs (old: {
|
pgsql = prev.extensions.pgsql.overrideAttrs (_: {
|
||||||
configureFlags = [ "--with-pgsql=${lib.getDev config.services.postgresql.package}" ];
|
configureFlags = [ "--with-pgsql=${lib.getDev config.services.postgresql.package.pg_config}" ];
|
||||||
});
|
});
|
||||||
pdo_pgsql = prev.extensions.pdo_pgsql.overrideAttrs (old: {
|
pdo_pgsql = prev.extensions.pdo_pgsql.overrideAttrs (_: {
|
||||||
configureFlags = [ "--with-pdo-pgsql=${lib.getDev config.services.postgresql.package}" ];
|
configureFlags = [ "--with-pdo-pgsql=${lib.getDev config.services.postgresql.package.pg_config}" ];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -60,17 +61,14 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ensure that this service doesn't start before postgres is ready
|
|
||||||
systemd.services.nextcloud-setup.after = [ "postgresql.service" ];
|
|
||||||
|
|
||||||
# Set up SSL
|
# Set up SSL
|
||||||
services.nginx.virtualHosts."${hostName}" = {
|
nginx.virtualHosts."${hostName}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
useACMEHost = "tlater.net";
|
useACMEHost = "tlater.net";
|
||||||
# The upstream module already adds HSTS
|
# The upstream module already adds HSTS
|
||||||
};
|
};
|
||||||
|
|
||||||
services.backups.nextcloud = {
|
backups.nextcloud = {
|
||||||
user = "nextcloud";
|
user = "nextcloud";
|
||||||
paths = [
|
paths = [
|
||||||
"/var/lib/nextcloud/nextcloud-db.sql"
|
"/var/lib/nextcloud/nextcloud-db.sql"
|
||||||
|
@ -98,4 +96,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Ensure that this service doesn't start before postgres is ready
|
||||||
|
systemd.services.nextcloud-setup.after = [ "postgresql.service" ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
let
|
let
|
||||||
domain = config.services.nginx.domain;
|
inherit (config.services.nginx) domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.tlaternet-webserver = {
|
services.tlaternet-webserver = {
|
||||||
|
|
43
flake.lock
generated
43
flake.lock
generated
|
@ -300,11 +300,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739841949,
|
"lastModified": 1747742835,
|
||||||
"narHash": "sha256-lSOXdgW/1zi/SSu7xp71v+55D5Egz8ACv0STkj7fhbs=",
|
"narHash": "sha256-kYL4GCwwznsypvsnA20oyvW8zB/Dvn6K5G/tgMjVMT4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "15dbf8cebd8e2655a883b74547108e089f051bf0",
|
"rev": "df522e787fdffc4f32ed3e1fca9ed0968a384d62",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -595,11 +595,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739712626,
|
"lastModified": 1746877938,
|
||||||
"narHash": "sha256-u3m+awbdL+0BKk8IWidsWMr+R0ian3GZMUlH7623kd8=",
|
"narHash": "sha256-N9J96pSPg4vbozV+ZZ++dwLnMIf2Le6ONNMO0kZCj1M=",
|
||||||
"owner": "reckenrode",
|
"owner": "reckenrode",
|
||||||
"repo": "nix-foundryvtt",
|
"repo": "nix-foundryvtt",
|
||||||
"rev": "a7fa493ba2c623cf90e83756b62285b3b58f18d2",
|
"rev": "f1b401831d796dd94cf5a11b65fd169a199d4ff0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -744,34 +744,18 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs-unstable": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1740215764,
|
|
||||||
"narHash": "sha256-wzBbGGZ6i1VVBA/cDJaLfuuGYCUriD7fwsLgJJHRVRk=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "8465e233b0668cf162c608a92e62e8d78c1ba7e4",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable-small",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740162160,
|
"lastModified": 1748085680,
|
||||||
"narHash": "sha256-SSYxFhqCOb3aiPb6MmN68yEzBIltfom8IgRz7phHscM=",
|
"narHash": "sha256-XG90Q/040NiV70gAVvoYbXg1lULbiwIzfkWmwSINyGQ=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "11415c7ae8539d6292f2928317ee7a8410b28bb9",
|
"rev": "4e6eeca5ed45465087274fc9dc6bc2011254a0f3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"ref": "nixos-24.11-small",
|
"ref": "nixos-25.05-small",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1006,6 @@
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"foundryvtt": "foundryvtt",
|
"foundryvtt": "foundryvtt",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
|
||||||
"sonnenshift": "sonnenshift",
|
"sonnenshift": "sonnenshift",
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
"tlaternet-webserver": "tlaternet-webserver"
|
"tlaternet-webserver": "tlaternet-webserver"
|
||||||
|
@ -1096,11 +1079,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739262228,
|
"lastModified": 1747603214,
|
||||||
"narHash": "sha256-7JAGezJ0Dn5qIyA2+T4Dt/xQgAbhCglh6lzCekTVMeU=",
|
"narHash": "sha256-lAblXm0VwifYCJ/ILPXJwlz0qNY07DDYdLD+9H+Wc8o=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "07af005bb7d60c7f118d9d9f5530485da5d1e975",
|
"rev": "8d215e1c981be3aa37e47aeabd4e61bb069548fd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
description = "tlater.net host configuration";
|
description = "tlater.net host configuration";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11-small";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05-small";
|
||||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
|
||||||
disko = {
|
disko = {
|
||||||
url = "github:nix-community/disko";
|
url = "github:nix-community/disko";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
@ -92,7 +91,7 @@
|
||||||
#########
|
#########
|
||||||
# Tests #
|
# Tests #
|
||||||
#########
|
#########
|
||||||
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
checks.${system} = import ./checks (inputs // { inherit system; });
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# Garbage collection root #
|
# Garbage collection root #
|
||||||
|
@ -117,8 +116,6 @@
|
||||||
run-vm = {
|
run-vm = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program =
|
program =
|
||||||
let
|
|
||||||
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;
|
||||||
|
|
|
@ -247,10 +247,7 @@ in
|
||||||
online_client = {
|
online_client = {
|
||||||
# By default, we don't let crowdsec phone home, since
|
# By default, we don't let crowdsec phone home, since
|
||||||
# this is usually within NixOS users' concerns.
|
# this is usually within NixOS users' concerns.
|
||||||
#
|
sharing = lib.mkDefault false;
|
||||||
# TODO: Enable when this option becomes available
|
|
||||||
# (1.6.4, current nixpkgs-unstable)
|
|
||||||
# sharing = lib.mkDefault false;
|
|
||||||
credentials_path = cfg.centralApiCredentials;
|
credentials_path = cfg.centralApiCredentials;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -267,9 +264,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.packages = [
|
systemd.packages = [ cfg.package ];
|
||||||
cfg.package
|
|
||||||
];
|
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = [
|
systemPackages = [
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
inherit (flake-inputs.self.packages.${pkgs.system}) crowdsec-firewall-bouncer;
|
||||||
|
|
||||||
crowdsecCfg = config.security.crowdsec;
|
crowdsecCfg = config.security.crowdsec;
|
||||||
cfg = crowdsecCfg.remediationComponents.firewallBouncer;
|
cfg = crowdsecCfg.remediationComponents.firewallBouncer;
|
||||||
settingsFormat = pkgs.formats.yaml { };
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
crowdsec-firewall-bouncer = flake-inputs.self.packages.${pkgs.system}.crowdsec-firewall-bouncer;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.security.crowdsec.remediationComponents.firewallBouncer = {
|
options.security.crowdsec.remediationComponents.firewallBouncer = {
|
||||||
|
@ -31,9 +32,7 @@ in
|
||||||
security.crowdsec.remediationComponents.firewallBouncer.settings = {
|
security.crowdsec.remediationComponents.firewallBouncer.settings = {
|
||||||
mode = lib.mkDefault "${if config.networking.nftables.enable then "nftables" else "iptables"}";
|
mode = lib.mkDefault "${if config.networking.nftables.enable then "nftables" else "iptables"}";
|
||||||
log_mode = "stdout";
|
log_mode = "stdout";
|
||||||
iptables_chains = [
|
iptables_chains = [ "nixos-fw" ];
|
||||||
"nixos-fw"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Don't let users easily override this; unfortunately we need to
|
# Don't let users easily override this; unfortunately we need to
|
||||||
# set up this key through substitution at runtime.
|
# set up this key through substitution at runtime.
|
||||||
|
@ -78,9 +77,7 @@ in
|
||||||
requiredBy = [ "crowdsec.service" ];
|
requiredBy = [ "crowdsec.service" ];
|
||||||
|
|
||||||
path =
|
path =
|
||||||
lib.optionals (cfg.settings.mode == "ipset" || cfg.settings.mode == "iptables") [
|
lib.optionals (cfg.settings.mode == "ipset" || cfg.settings.mode == "iptables") [ pkgs.ipset ]
|
||||||
pkgs.ipset
|
|
||||||
]
|
|
||||||
++ lib.optional (cfg.settings.mode == "iptables") pkgs.iptables
|
++ lib.optional (cfg.settings.mode == "iptables") pkgs.iptables
|
||||||
++ lib.optional (cfg.settings.mode == "nftables") pkgs.nftables;
|
++ lib.optional (cfg.settings.mode == "nftables") pkgs.nftables;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1 @@
|
||||||
{
|
{ imports = [ ./cs-firewall-bouncer.nix ]; }
|
||||||
imports = [
|
|
||||||
./cs-firewall-bouncer.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
"crowdsec-hub": {
|
"crowdsec-hub": {
|
||||||
"cargoLocks": null,
|
"cargoLocks": null,
|
||||||
"date": "2025-02-22",
|
"date": "2025-05-17",
|
||||||
"extract": null,
|
"extract": null,
|
||||||
"name": "crowdsec-hub",
|
"name": "crowdsec-hub",
|
||||||
"passthru": null,
|
"passthru": null,
|
||||||
|
@ -33,10 +33,10 @@
|
||||||
"name": null,
|
"name": null,
|
||||||
"owner": "crowdsecurity",
|
"owner": "crowdsecurity",
|
||||||
"repo": "hub",
|
"repo": "hub",
|
||||||
"rev": "f9883cd6c7d1913c13e4a3a69d9a0b887a7d57df",
|
"rev": "850614b9fcd4298f559b422c5ac685a69aa2e5ff",
|
||||||
"sha256": "sha256-45pUln7Qj5luY9I9BE2qhzjH7kv4IbYvNoEX3/4AVVg=",
|
"sha256": "sha256-96MMwFN5KongQA3YJVSuk7Kanbr1gR94CCyiflmez2k=",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"version": "f9883cd6c7d1913c13e4a3a69d9a0b887a7d57df"
|
"version": "850614b9fcd4298f559b422c5ac685a69aa2e5ff"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,14 +14,14 @@
|
||||||
};
|
};
|
||||||
crowdsec-hub = {
|
crowdsec-hub = {
|
||||||
pname = "crowdsec-hub";
|
pname = "crowdsec-hub";
|
||||||
version = "f9883cd6c7d1913c13e4a3a69d9a0b887a7d57df";
|
version = "850614b9fcd4298f559b422c5ac685a69aa2e5ff";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "crowdsecurity";
|
owner = "crowdsecurity";
|
||||||
repo = "hub";
|
repo = "hub";
|
||||||
rev = "f9883cd6c7d1913c13e4a3a69d9a0b887a7d57df";
|
rev = "850614b9fcd4298f559b422c5ac685a69aa2e5ff";
|
||||||
fetchSubmodules = false;
|
fetchSubmodules = false;
|
||||||
sha256 = "sha256-45pUln7Qj5luY9I9BE2qhzjH7kv4IbYvNoEX3/4AVVg=";
|
sha256 = "sha256-96MMwFN5KongQA3YJVSuk7Kanbr1gR94CCyiflmez2k=";
|
||||||
};
|
};
|
||||||
date = "2025-02-22";
|
date = "2025-05-17";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
{
|
{ sources }: sources.crowdsec-hub.src
|
||||||
sources,
|
|
||||||
}:
|
|
||||||
sources.crowdsec-hub.src
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue