2023-06-10 10:50:53 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with import ../../../lib/pure.nix { inherit lib; };
|
2015-11-18 13:05:54 +00:00
|
|
|
let
|
2017-04-17 13:59:27 +00:00
|
|
|
root = "/var/srv/drivedroid";
|
2015-11-18 13:05:54 +00:00
|
|
|
in
|
2015-11-17 21:15:07 +00:00
|
|
|
{
|
2015-12-04 09:22:18 +00:00
|
|
|
environment.systemPackages = [ pkgs.drivedroid-gen-repo ];
|
2015-11-18 13:05:54 +00:00
|
|
|
|
2017-04-17 13:46:45 +00:00
|
|
|
services.nginx = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
virtualHosts.shack-drivedroid = {
|
|
|
|
serverAliases = [
|
|
|
|
"drivedroid.shack"
|
|
|
|
];
|
|
|
|
# TODO: prepare this somehow
|
|
|
|
locations."/".extraConfig = ''
|
2017-04-17 13:59:27 +00:00
|
|
|
root ${root};
|
2017-04-17 13:46:45 +00:00
|
|
|
index main.json;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-04-17 13:59:27 +00:00
|
|
|
systemd.services.drivedroid-gen-repo = {
|
2015-12-04 09:22:18 +00:00
|
|
|
description = "generates drivedroid repo file";
|
2017-04-17 13:59:27 +00:00
|
|
|
path = [
|
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.drivedroid-gen-repo
|
|
|
|
pkgs.inotify-tools
|
|
|
|
];
|
2015-12-04 09:22:18 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
Restart = "always";
|
2017-04-17 13:59:27 +00:00
|
|
|
ExecStartPre = pkgs.writeDash "prepare-drivedroid-gen-repo" ''
|
|
|
|
mkdir -p ${root}/repos
|
2015-11-18 13:05:54 +00:00
|
|
|
'';
|
2017-04-17 13:59:27 +00:00
|
|
|
ExecStart = pkgs.writeDash "start-drivedroid-gen-repo" ''
|
|
|
|
set -efu
|
|
|
|
cd ${root}
|
2015-12-04 09:22:18 +00:00
|
|
|
while sleep 60; do
|
2017-04-17 13:59:27 +00:00
|
|
|
if inotifywait -r .; then
|
|
|
|
drivedroid-gen-repo repos > main.json
|
|
|
|
fi
|
2015-12-04 09:22:18 +00:00
|
|
|
done
|
2015-11-18 13:05:54 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2015-11-17 21:15:07 +00:00
|
|
|
}
|