initial commit
This commit is contained in:
commit
4b8dff4d24
18 changed files with 1290 additions and 0 deletions
55
lib.nix
Normal file
55
lib.nix
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
defaultUpdater = { git ? null, url ? null, path ? null, keys ? null, dest, check }:
|
||||
let
|
||||
config.systemd.services."fooud-${dest}" = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
Group = "root";
|
||||
ExecStart = let
|
||||
dest = lib.assertMsg dest "dest must be set";
|
||||
remote =
|
||||
if git then "--git " + git
|
||||
else if url then "--url " + url
|
||||
else if path then "--path " + path
|
||||
else builtins.throw "one of git, url or path must be set";
|
||||
keys_str = if git then
|
||||
lib.strings.concatStrings builtins.map (x: "--key ${x} ") keys
|
||||
else throw "cannot use keys with git";
|
||||
|
||||
in pkgs.writeShellScript "fooud-${dest}-wrapper" ''
|
||||
${pkgs.fooud}/bin/fooud ${keys_str} ${remote} ${dest}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config.systemd.timers.${dest} = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnActiveSec = "0s";
|
||||
OnUnitActiveSec = check;
|
||||
Unit = "fooud-${dest}.service";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
dest;
|
||||
in
|
||||
let
|
||||
gitUpdater = { git, keys, dest, check }:
|
||||
defaultUpdater { git = git; keys = keys; dest = dest; check = check; };
|
||||
fsUpdater = { path, dest, check }:
|
||||
defaultUpdater { path = path; dest = dest; check = check; };
|
||||
urlUpdater = { url, dest, check }:
|
||||
defaultUpdater { url = url; dest = dest; check = check; };
|
||||
|
||||
lib = {
|
||||
inherit
|
||||
gitUpdater
|
||||
fsUpdater
|
||||
urlUpdater;
|
||||
};
|
||||
in
|
||||
lib
|
||||
Loading…
Add table
Add a link
Reference in a new issue