shared shack-drivedroid: cleanup
This commit is contained in:
parent
0b89efb90e
commit
9cb758c1cb
@ -1,8 +1,7 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
with import <stockholm/lib>;
|
with import <stockholm/lib>;
|
||||||
let
|
let
|
||||||
repodir = "/var/srv/drivedroid";
|
root = "/var/srv/drivedroid";
|
||||||
srepodir = shell.escape repodir;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
environment.systemPackages = [ pkgs.drivedroid-gen-repo ];
|
environment.systemPackages = [ pkgs.drivedroid-gen-repo ];
|
||||||
@ -15,28 +14,34 @@ in
|
|||||||
];
|
];
|
||||||
# TODO: prepare this somehow
|
# TODO: prepare this somehow
|
||||||
locations."/".extraConfig = ''
|
locations."/".extraConfig = ''
|
||||||
root ${repodir};
|
root ${root};
|
||||||
index main.json;
|
index main.json;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.drivedroid = {
|
systemd.services.drivedroid-gen-repo = {
|
||||||
description = "generates drivedroid repo file";
|
description = "generates drivedroid repo file";
|
||||||
restartIfChanged = true;
|
path = [
|
||||||
|
pkgs.coreutils
|
||||||
|
pkgs.drivedroid-gen-repo
|
||||||
|
pkgs.inotify-tools
|
||||||
|
];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
ExecStartPre = pkgs.writeScript "prepare-drivedroid-gen-repo" ''
|
ExecStartPre = pkgs.writeDash "prepare-drivedroid-gen-repo" ''
|
||||||
#!/bin/sh
|
mkdir -p ${root}/repos
|
||||||
mkdir -p ${srepodir}/repos
|
|
||||||
'';
|
'';
|
||||||
ExecStart = pkgs.writeScript "start-drivedroid-gen-repo" ''
|
ExecStart = pkgs.writeDash "start-drivedroid-gen-repo" ''
|
||||||
#!/bin/sh
|
set -efu
|
||||||
|
cd ${root}
|
||||||
while sleep 60; do
|
while sleep 60; do
|
||||||
${pkgs.inotify-tools}/bin/inotifywait -r ${srepodir} && ${pkgs.drivedroid-gen-repo}/bin/drivedroid-gen-repo --chdir "${srepodir}" repos/ > "${srepodir}/main.json"
|
if inotifywait -r .; then
|
||||||
|
drivedroid-gen-repo repos > main.json
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user