Skip to content

Commit 0ee4639

Browse files
authored
Merge pull request #6 from nix-pizza/wastebin
Wastebin
2 parents 5a38feb + 96606e3 commit 0ee4639

File tree

10 files changed

+87
-28
lines changed

10 files changed

+87
-28
lines changed

.github/workflows/build.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: "CI"
2-
on: pull_request_target
2+
on:
3+
- pull_request_target
4+
- workflow_dispatch
35
jobs:
46
nix-flake-check:
57
# TODO idea: instead of using QEMU (which is slow) use the host as remote builder
68
strategy:
79
matrix:
8-
system: ["aarch64-linux", "x86_64-linux"]
10+
system: ["aarch64-linux"]
911
runs-on: ubuntu-latest
1012
name: "Build checks for ${{ matrix.system }}"
1113
steps:
@@ -22,6 +24,7 @@ jobs:
2224
system = ${{ matrix.system }}
2325
trusted-public-keys = nix-pizza.cachix.org-1:TQe66aP2buN2KXWrZqpdko7GAL0WtbPA40d+wlnEiyo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
2426
substituters = https://nix-pizza.cachix.org https://cache.nixos.org/
27+
always-allow-substitutes = true
2528
- id: retrieve-cachix-auth-token
2629
run: |
2730
source "$(nix build .#inject-secrets --no-link --print-out-paths)"/bin/install-agenix-shell
@@ -30,4 +33,5 @@ jobs:
3033
with:
3134
name: nix-pizza
3235
authToken: ${{ steps.retrieve-cachix-auth-token.outputs.CACHIX_AUTH_TOKEN }}
33-
- run: nix flake check -L
36+
installCommand: nix profile install github:cachix/cachix/debug-daemon-stop -L --accept-flake-config
37+
- run: nix build .#checks.aarch64-linux.nix-pizza-config -L -vvvv

.github/workflows/deploy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
system = ${{ matrix.system }}
2727
trusted-public-keys = nix-pizza.cachix.org-1:TQe66aP2buN2KXWrZqpdko7GAL0WtbPA40d+wlnEiyo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
2828
substituters = https://nix-pizza.cachix.org https://cache.nixos.org/
29+
always-allow-substitutes = true
2930
- id: retrieve-cachix-auth-token
3031
run: |
3132
source "$(nix build .#inject-secrets --no-link --print-out-paths)"/bin/install-agenix-shell

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hosts/nix-pizza/backup.nix

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
{ config, pkgs, lib, ... }: {
1+
{ config, pkgs, lib, ... }:
2+
let
3+
user = "u382036-sub2";
4+
host = "u382036.your-storagebox.de";
5+
port = "23";
6+
in
7+
{
28
age.secrets = {
39
HETZNER_STORAGE_BOX_SSH_PASSWORD = {
410
file = ../../secrets/HETZNER_STORAGE_BOX_SSH_PASSWORD.age;
@@ -10,21 +16,17 @@
1016
};
1117
};
1218

13-
services.restic.backups.nix-pizza =
14-
let
15-
user = "u382036-sub2";
16-
host = "u382036.your-storagebox.de";
17-
port = "23";
18-
in
19-
{
20-
paths = [ "/persist" ];
21-
passwordFile = config.age.secrets.NIX_PIZZA_RESTIC_PASSWORD.path;
22-
extraOptions = [
23-
"sftp.command='${lib.getExe pkgs.sshpass} -f ${config.age.secrets.HETZNER_STORAGE_BOX_SSH_PASSWORD.path} ssh -p${port} ${user}@${host} -s sftp'"
24-
];
25-
repository = "sftp://${user}@${host}:${port}/";
26-
initialize = true;
27-
timerConfig.OnCalendar = "daily";
28-
timerConfig.RandomizedDelaySec = "1h";
29-
};
19+
services.openssh.knownHosts."${host}".publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIICf9svRenC/PLKIL9nk6K/pxQgoiFC41wTNvoIncOxs";
20+
21+
services.restic.backups.nix-pizza = {
22+
paths = [ "/persist" ];
23+
passwordFile = config.age.secrets.NIX_PIZZA_RESTIC_PASSWORD.path;
24+
extraOptions = [
25+
"sftp.command='${lib.getExe pkgs.sshpass} -f ${config.age.secrets.HETZNER_STORAGE_BOX_SSH_PASSWORD.path} ssh -p${port} ${user}@${host} -s sftp'"
26+
];
27+
repository = "sftp://${user}@${host}:${port}/";
28+
initialize = true;
29+
timerConfig.OnCalendar = "daily";
30+
timerConfig.RandomizedDelaySec = "1h";
31+
};
3032
}

hosts/nix-pizza/default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
./fail2ban.nix
77
./nginx.nix
88
./hedgedoc.nix
9+
./wastebin.nix
910
];
1011

1112
boot.kernelParams = [ "console=tty" ];

hosts/nix-pizza/hedgedoc.nix

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ in
55
{
66
services.nginx = {
77
virtualHosts."${cfg.settings.domain}" = {
8-
default = true;
98
enableACME = true;
109
forceSSL = true;
1110
locations."/".proxyPass = "http://${cfg.settings.host}:${builtins.toString cfg.settings.port}";

hosts/nix-pizza/wastebin.nix

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{ config, lib, ... }:
2+
let
3+
cfg = config.services.wastebin;
4+
host = "marinara.nix.pizza";
5+
port = 8088;
6+
in
7+
{
8+
# contains WASTEBIN_PASSWORD_SALT and WASTEBIN_SIGNING_KEY
9+
age.secrets.WASTEBIN_ENVIRONMENT = {
10+
file = ../../secrets/WASTEBIN_ENVIRONMENT.age;
11+
owner = "wastebin";
12+
group = "wastebin";
13+
};
14+
15+
users.groups.wastebin = { };
16+
users.users.wastebin = {
17+
description = "Wastebin service user";
18+
group = "wastebin";
19+
isSystemUser = true;
20+
};
21+
22+
services.wastebin = {
23+
enable = true;
24+
stateDir = "/var/lib/wastebin";
25+
secretFile = config.age.secrets.WASTEBIN_ENVIRONMENT.path;
26+
settings = {
27+
WASTEBIN_DATABASE_PATH = "${cfg.stateDir}/sqlite3.db";
28+
WASTEBIN_BASE_URL = "https://${host}";
29+
WASTEBIN_ADDRESS_PORT = "127.0.0.1:${builtins.toString port}";
30+
};
31+
};
32+
33+
systemd.services.wastebin.serviceConfig = {
34+
User = "wastebin";
35+
Group = "wastebin";
36+
DynamicUser = lib.mkForce false;
37+
};
38+
39+
environment.persistence."/persist".directories = [
40+
cfg.stateDir
41+
];
42+
43+
services.nginx = {
44+
virtualHosts."${host}" = {
45+
enableACME = true;
46+
forceSSL = true;
47+
locations."/".proxyPass = "http://${cfg.settings.WASTEBIN_ADDRESS_PORT}";
48+
};
49+
};
50+
}

secrets/WASTEBIN_ENVIRONMENT.age

1.24 KB
Binary file not shown.

secrets/secrets.nix

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ in
1515
"CACHIX_AUTH_TOKEN.age".publicKeys = coreKeys;
1616

1717
"HEDGEDOC_ENVIRONMENT.age".publicKeys = coreKeys ++ [ nix-pizza.key ];
18+
"WASTEBIN_ENVIRONMENT.age".publicKeys = coreKeys ++ [ nix-pizza.key ];
1819
"HETZNER_STORAGE_BOX_SSH_PASSWORD.age".publicKeys = coreKeys ++ [ nix-pizza.key ];
1920
"NIX_PIZZA_RESTIC_PASSWORD.age".publicKeys = coreKeys ++ [ nix-pizza.key ];
2021
}

shell/default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
jq # FIXME report upstream: nixos-anywhere terraform module needs it in PATH
2121
inputs'.agenix.packages.agenix
2222
config.agenix-shell.agePackage
23+
pkgs.age
2324
];
2425
devshell.startup.terraform-init.text = ''
2526
tofu init

0 commit comments

Comments
 (0)