Make forgejo persist data

This commit is contained in:
kalle 2025-04-11 14:00:09 +02:00
parent b67a4abbe3
commit 93cc8ebf36
2 changed files with 44 additions and 40 deletions

View file

@ -69,17 +69,6 @@
};
};
environment.persistence."/persistent" = {
directories = [
# TODO: Backup onto CEPH cluster periodically. Or maybe move fully, if performance allows it.
{
directory = "/appdata/forgejo";
user = "forgejo";
mode = "0700";
}
];
};
environment.systemPackages =
let
forgejo-cli = pkgs.writeShellScriptBin "forgejo-cli" ''
@ -87,16 +76,20 @@
echo "No arguments supplied"
exit 1
fi
sudo -u forgejo -- ${lib.getExe pkgs.forgejo} --config /appdata/forgejo/custom/conf/app.ini $@
sudo -u forgejo -- ${lib.getExe pkgs.forgejo} --config /cephfs/appdata/forgejo/custom/conf/app.ini $@
'';
in
[
forgejo-cli
];
systemd.tmpfiles.rules = [
"d /cephfs/appdata/forgejo - forgejo forgejo - -"
];
services.forgejo = {
enable = true;
stateDir = "/appdata/forgejo";
stateDir = "/cephfs/appdata/forgejo";
lfs.enable = true;
database = {

View file

@ -7,7 +7,10 @@
fileSystems."/" = {
device = "none";
fsType = "tmpfs";
options = [ "defaults" "mode=755" ];
options = [
"defaults"
"mode=755"
];
};
fileSystems."/boot" = {
@ -18,19 +21,27 @@
fileSystems."/nix" = {
device = "/dev/disk/by-label/btrfs";
fsType = "btrfs";
options = [ "compress=zstd" "subvol=nix" "noatime" ];
options = [
"compress=zstd"
"subvol=nix"
"noatime"
];
};
fileSystems."/persistent" = {
device = "/dev/disk/by-label/btrfs";
fsType = "btrfs";
options = [ "compress=zstd" "subvol=persistent" "noatime" ];
options = [
"compress=zstd"
"subvol=persistent"
"noatime"
];
autoResize = true;
neededForBoot = true;
};
fileSystems."/media" = {
device = "vm@b9b22d11-3492-49a6-92b7-b36cdf0161fe.cephfs=/media";
fileSystems."/cephfs" = {
device = "vm@b9b22d11-3492-49a6-92b7-b36cdf0161fe.cephfs=/";
fsType = "ceph";
options = [ "nofail" ];
};