add fossil server

This commit is contained in:
Cyryl Płotnicki 2022-10-23 00:06:39 +01:00
parent 0d205e0a74
commit a93b230e03
2 changed files with 68 additions and 0 deletions

View file

@ -8,6 +8,7 @@
./backups.nix ./backups.nix
./blog.cyplo.net.nix ./blog.cyplo.net.nix
./cryptpad.nix ./cryptpad.nix
./fossil.nix
./foundryvtt.nix ./foundryvtt.nix
./matrix-front.nix ./matrix-front.nix
./rss.nix ./rss.nix

View file

@ -0,0 +1,67 @@
{ config, pkgs, inputs, lib, ... }:
let
port = 8081;
domain = "fossil.cyplo.dev";
baseurl = "https://${domain}";
in {
imports = [ ../nginx.nix ];
services.nginx = {
virtualHosts = {
"${domain}" = {
forceSSL = true;
enableACME = true;
locations."/" = { proxyPass = "http://localhost:" + toString port; };
};
};
};
containers.fossil = {
autoStart = true;
forwardPorts = [{
containerPort = port;
hostPort = port;
}];
config = { config, pkgs, ... }:
let
path = "/var/lib/fossil";
repoPath = "${path}/repo.fossil";
user = "fossil";
group = "fossil";
in {
users.groups = { "${group}" = { }; };
users.users = {
fossil = {
description = "Fossil Service";
home = path;
useDefaultShell = true;
group = group;
isSystemUser = true;
};
};
systemd.tmpfiles.rules = [ "d '${path}' 0770 ${user} ${group} - -" ];
systemd.services.fossil = {
description = "fossil server";
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.fossil pkgs.git ];
serviceConfig = {
User = user;
Group = group;
WorkingDirectory = path;
ReadWritePaths = [ path ];
ExecStart = "${pkgs.fossil}/bin/fossil server --localhost --https"
+ " --port ${toString port}" + " --baseurl ${baseurl}"
+ " --create ${repoPath}";
Restart = "always";
RestartSec = 3;
};
};
};
};
}