basant/module.nix

34 lines
938 B
Nix
Raw Normal View History

{ 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}
'';
};
};
}