Automatisation site musique

This commit is contained in:
nyanloutre 2018-10-29 00:59:03 +01:00
parent 8dc40629e9
commit 3d73bb02f2
3 changed files with 35 additions and 34 deletions

View file

@ -24,10 +24,6 @@ in
config = mkIf cfg.enable {
nixpkgs.overlays = [
(import ../overlays/site-musique.nix)
];
services.haproxy-acme.services = {
${cfg.domaine} = { ip = "127.0.0.1"; port = cfg.port; auth = false; };
};
@ -36,7 +32,7 @@ in
"musique" = {
listen = [ { addr = "127.0.0.1"; port = cfg.port; } ];
locations."/" = {
root = pkgs.site-musique;
root = "/run/site-musique/result";
index = "index.php";
extraConfig = ''
location ~* \.php$ {
@ -67,5 +63,39 @@ in
catch_workers_output = yes
'';
systemd.services.build-site-musique = {
description = "Compilation du site de la musique";
requires = ["network-online.target"];
path = with pkgs;[ git nix ];
environment = { HOME = "/var/lib/site-musique"; NIX_PATH = "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs"; };
serviceConfig = {
DynamicUser = true;
RuntimeDirectory = "site-musique";
RuntimeDirectoryPreserve = "yes";
CacheDirectory = "site-musique";
Type = "oneshot";
ExecStart = "${pkgs.writeShellScriptBin "build.sh" ''
set -x
set -e
GIT_CLONE_DIR=/var/cache/site-musique
if [ ! -d $GIT_CLONE_DIR/.git ]; then
git clone --depth 1 https://gitlab.com/nyanloutre/site-musique.git $GIT_CLONE_DIR
else
git -C $GIT_CLONE_DIR pull
fi
NIXPKGS_ALLOW_UNFREE=1 nix-build -o /run/site-musique/result $GIT_CLONE_DIR
''}/bin/build.sh";
};
};
systemd.timers.build-site-musique = {
description = "Timer de compilation du site de la musique";
requires = ["network-online.target"];
wantedBy = ["multi-user.target"];
timerConfig = { OnCalendar = "*:0/5"; Unit = "build-site-musique.service"; };
};
};
}