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 {
|
nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
|
||||||
modules = [{
|
modules = [{
|
||||||
services.nginx.virtualHosts."squi.bid" = {
|
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
|
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
|
dest = "/var/www/squi.bid"; # where should the files live on disk
|
||||||
keys = [ "BECE5684D3C4005D" ]; # requires the commit to be signed by me
|
keys = [ "BECE5684D3C4005D" ]; # requires the commit to be signed by me
|
||||||
|
|
|
||||||
22
lib.nix
22
lib.nix
|
|
@ -1,7 +1,6 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
defaultUpdater = { git ? null, url ? null, path ? null, keys ? null, dest, check, config }:
|
||||||
defaultUpdater = { git ? null, url ? null, path ? null, keys ? null, dest, check }:
|
|
||||||
let
|
let
|
||||||
config.systemd.services."fooud-${dest}" = {
|
config.systemd.services."fooud-${dest}" = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
|
@ -9,23 +8,22 @@ let
|
||||||
User = "root";
|
User = "root";
|
||||||
Group = "root";
|
Group = "root";
|
||||||
ExecStart = let
|
ExecStart = let
|
||||||
dest = lib.assertMsg dest "dest must be set";
|
dest = pkgs.lib.assertMsg dest "dest must be set";
|
||||||
remote =
|
remote =
|
||||||
if git then "--git " + git
|
if git then "--git " + git
|
||||||
else if url then "--url " + url
|
else if url then "--url " + url
|
||||||
else if path then "--path " + path
|
else if path then "--path " + path
|
||||||
else builtins.throw "one of git, url or path must be set";
|
else builtins.throw "one of git, url or path must be set";
|
||||||
keys_str = if git then
|
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";
|
else throw "cannot use keys with git";
|
||||||
|
|
||||||
in pkgs.writeShellScript "fooud-${dest}-wrapper" ''
|
in pkgs.writeShellScript "fooud-${dest}-wrapper" ''
|
||||||
${pkgs.fooud}/bin/fooud ${keys_str} ${remote} ${dest}
|
${pkgs.fooud}/bin/fooud ${keys_str} ${remote} ${dest}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.systemd.timers.${dest} = {
|
config.systemd.timers."fooud-${dest}" = {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnActiveSec = "0s";
|
OnActiveSec = "0s";
|
||||||
|
|
@ -38,12 +36,12 @@ let
|
||||||
dest;
|
dest;
|
||||||
in
|
in
|
||||||
let
|
let
|
||||||
gitUpdater = { git, keys, dest, check }:
|
gitUpdater = config: { git, keys, dest, check }:
|
||||||
defaultUpdater { git = git; keys = keys; dest = dest; check = check; };
|
defaultUpdater { git = git; keys = keys; dest = dest; check = check; config = config; };
|
||||||
fsUpdater = { path, dest, check }:
|
fsUpdater = config: { path, dest, check }:
|
||||||
defaultUpdater { path = path; dest = dest; check = check; };
|
defaultUpdater { path = path; dest = dest; check = check; config = config; };
|
||||||
urlUpdater = { url, dest, check }:
|
urlUpdater = config: { url, dest, check }:
|
||||||
defaultUpdater { url = url; dest = dest; check = check; };
|
defaultUpdater { url = url; dest = dest; check = check; config = config; };
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
inherit
|
inherit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue