diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..5161ed8 --- /dev/null +++ b/module.nix @@ -0,0 +1,33 @@ +{ options, lib, config, pkgs, ... }: +let + serverName = "anish.lakhwara.com"; + webRoot = "/var/www/${serverName}"; + + serviceConfig = config.services."${serverName}"; + options = { + enable = lib.mkEnableOption "${serverName} service"; + }; +in +{ + options.services.${serverName} = options; + config = lib.mkIf serviceConfig.enable { + systemd.services."source-${serverName}" = { + description = '' + https://${serverName} source + ''; + serviceConfig = { + Type = "oneshot"; + }; + startAt = "*:0/5"; + path = with pkgs; [ nix gnutar gzip curl jq ]; + script = '' + set -ex + + rev=$(curl https://git.sealight.xyz/repos/aynish/basant/git/ref/heads/main | jq -r .object.sha) + result=$(nix-build https://git.sealight.xyz/aynish/basant/archive/$rev.tar.gz -A anish-lakhwara) # TODO: need to define this file + + ln -sfT $result${webRoot} ${webRoot} + ''; + }; + }; +}