56 lines
1.6 KiB
Nix
56 lines
1.6 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
with lib;
|
|
let
|
|
src = pkgs.callPackage (pkgs.fetchFromGitHub {
|
|
owner = "Gleipnir-Technology";
|
|
repo = "fieldseeker-sync";
|
|
rev = "ecc408d09e7769dc43cd6a01c09c8d00255802bf";
|
|
sha256 = "sha256-hPdtf78PlkMCXZC3fG7Q7ZVM8moYlwbVnkElR5yx6yA=";
|
|
}) { };
|
|
in {
|
|
options.myModules.fieldseeker-sync.enable = mkEnableOption "custom fieldseeker-sync configuration";
|
|
|
|
config = mkIf config.myModules.fieldseeker-sync.enable {
|
|
environment.systemPackages = [
|
|
src
|
|
];
|
|
services.postgresql = {
|
|
enable = true;
|
|
ensureDatabases = [ "fieldseeker-sync" ];
|
|
ensureUsers = [{
|
|
ensureClauses.login = true;
|
|
ensureDBOwnership = true;
|
|
name = "fieldseeker-sync";
|
|
}];
|
|
};
|
|
sops.secrets.fieldseeker-sync-env = {
|
|
format = "dotenv";
|
|
group = "fieldseeker-sync";
|
|
mode = "0440";
|
|
owner = "fieldseeker-sync";
|
|
restartUnits = ["fieldseeker-sync.service"];
|
|
sopsFile = ../../secrets/fieldseeker-sync.env;
|
|
};
|
|
systemd.services.fieldseeker-sync = {
|
|
after=["network.target" "network-online.target"];
|
|
description="FieldSeeker sync";
|
|
requires=["network-online.target"];
|
|
serviceConfig = {
|
|
EnvironmentFile="/var/run/secrets/fieldseeker-sync-env";
|
|
Type = "simple";
|
|
User = "fieldseeker-sync";
|
|
Group = "fieldseeker-sync";
|
|
ExecStart = "${src}/bin/full-export";
|
|
TimeoutStopSec = "5s";
|
|
PrivateTmp = true;
|
|
WorkingDirectory = "/tmp";
|
|
};
|
|
wantedBy = ["multi-user.target"];
|
|
};
|
|
users.groups.fieldseeker-sync = {};
|
|
users.users.fieldseeker-sync = {
|
|
group = "fieldseeker-sync";
|
|
isSystemUser = true;
|
|
};
|
|
};
|
|
}
|