maybe this will let us merge into our global config state
This commit is contained in:
parent
44cbf6ca2a
commit
fb672cc78f
2 changed files with 13 additions and 15 deletions
|
|
@ -10,7 +10,7 @@ Declaratively keep your stuff up to date in your nixos config.
|
|||
nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
|
||||
modules = [{
|
||||
services.nginx.virtualHosts."squi.bid" = {
|
||||
root = fooud.lib.gitUpdater {
|
||||
root = fooud.lib.gitUpdater config {
|
||||
git = "https://git.squi.bid/squibid/squi.bid"; # the source of the data
|
||||
dest = "/var/www/squi.bid"; # where should the files live on disk
|
||||
keys = [ "BECE5684D3C4005D" ]; # requires the commit to be signed by me
|
||||
|
|
|
|||
26
lib.nix
26
lib.nix
|
|
@ -1,7 +1,6 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
defaultUpdater = { git ? null, url ? null, path ? null, keys ? null, dest, check }:
|
||||
defaultUpdater = { git ? null, url ? null, path ? null, keys ? null, dest, check, config }:
|
||||
let
|
||||
config.systemd.services."fooud-${dest}" = {
|
||||
serviceConfig = {
|
||||
|
|
@ -9,23 +8,22 @@ let
|
|||
User = "root";
|
||||
Group = "root";
|
||||
ExecStart = let
|
||||
dest = lib.assertMsg dest "dest must be set";
|
||||
dest = pkgs.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
|
||||
pkgs.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} = {
|
||||
config.systemd.timers."fooud-${dest}" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnActiveSec = "0s";
|
||||
|
|
@ -38,12 +36,12 @@ let
|
|||
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; };
|
||||
gitUpdater = config: { git, keys, dest, check }:
|
||||
defaultUpdater { git = git; keys = keys; dest = dest; check = check; config = config; };
|
||||
fsUpdater = config: { path, dest, check }:
|
||||
defaultUpdater { path = path; dest = dest; check = check; config = config; };
|
||||
urlUpdater = config: { url, dest, check }:
|
||||
defaultUpdater { url = url; dest = dest; check = check; config = config; };
|
||||
|
||||
lib = {
|
||||
inherit
|
||||
|
|
@ -51,5 +49,5 @@ let
|
|||
fsUpdater
|
||||
urlUpdater;
|
||||
};
|
||||
in
|
||||
lib
|
||||
in
|
||||
lib
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue