From fb672cc78f192d697edfc0a13bd64ba25fdc45c0 Mon Sep 17 00:00:00 2001 From: Squibid Date: Thu, 4 Dec 2025 01:17:27 -0500 Subject: [PATCH] maybe this will let us merge into our global config state --- README.md | 2 +- lib.nix | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 99c36f9..828045e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib.nix b/lib.nix index a0052a2..0773644 100644 --- a/lib.nix +++ b/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