Module outline, should eventually be moved into flake.nix

main
Anish Lakhwara 2022-03-17 13:02:07 +10:00
parent 277bafb535
commit 2c5e80b255
1 changed files with 33 additions and 0 deletions

33
module.nix Normal file
View File

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