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 = environment.systemPackages =
let let
forgejo-cli = pkgs.writeShellScriptBin "forgejo-cli" '' forgejo-cli = pkgs.writeShellScriptBin "forgejo-cli" ''
@ -87,16 +76,20 @@
echo "No arguments supplied" echo "No arguments supplied"
exit 1 exit 1
fi 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 in
[ [
forgejo-cli forgejo-cli
]; ];
systemd.tmpfiles.rules = [
"d /cephfs/appdata/forgejo - forgejo forgejo - -"
];
services.forgejo = { services.forgejo = {
enable = true; enable = true;
stateDir = "/appdata/forgejo"; stateDir = "/cephfs/appdata/forgejo";
lfs.enable = true; lfs.enable = true;
database = { database = {

View file

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