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

@ -1,5 +0,0 @@
self: super:
{
site-musique = super.callPackage ../pkgs/site-musique { };
}

View File

@ -1,24 +0,0 @@
{ lib, stdenv, fetchgit }:
stdenv.mkDerivation rec {
name= "site-musique";
src = fetchgit {
url = "https://gitlab.com/nyanloutre/site-musique.git";
rev = "78e5d570534d528cdf19c44332cd2c929f6fa861";
sha256 = "0rv1il85gxvi4d6yal8ac7q9jjz0w0ghmklbwzpd3p04v34y1rpd";
};
installPhase = ''
mkdir -p $out/
cp -R . $out/
'';
meta = {
description = "Site internet de l'association Musique Fraternité de Meyenheim";
homepage = https://musique-meyenheim.fr/;
maintainers = with stdenv.lib.maintainers; [ nyanloutre ];
license = stdenv.lib.licenses.cc-by-nc-sa-40;
platforms = stdenv.lib.platforms.all;
};
}

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"; };
};
};
}