From b28b68250d13bfa15b6cc58e597873737e616e93 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 27 Jun 2017 21:01:40 +0200 Subject: make x.r: init lancache prepare deployment of lan party steam cache --- makefu/1systems/x.nix | 1 + makefu/2configs/lancache.nix | 79 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 makefu/2configs/lancache.nix diff --git a/makefu/1systems/x.nix b/makefu/1systems/x.nix index 77b9915ae..b37c32944 100644 --- a/makefu/1systems/x.nix +++ b/makefu/1systems/x.nix @@ -34,6 +34,7 @@ with import ; ../2configs/exim-retiolum.nix ../2configs/mail-client.nix ../2configs/printer.nix + ../2configs/task-client.nix # Virtualization ../2configs/virtualization.nix diff --git a/makefu/2configs/lancache.nix b/makefu/2configs/lancache.nix new file mode 100644 index 000000000..8ec401361 --- /dev/null +++ b/makefu/2configs/lancache.nix @@ -0,0 +1,79 @@ +{ pkgs, lib, config, ... }: +with import ; +let + # see https://github.com/zeropingheroes/lancache for full docs + cachedir = "/var/lancache/cache"; + logdir = "/var/lancache/log"; + + lancache= pkgs.stdenv.mkDerivation rec { + name = "lancache-2017-06-26"; + src = pkgs.fetchFromGitHub { + # origin: https://github.com/multiplay/lancache + # forked: https://github.com/zeropingheroes/lancache + repo = "lancache"; + owner = "zeropingheroes"; + rev = "143f7bb"; + sha256 = "1ra4l7qz3k231j5wabr89s5hh80n1kk8vgd3dsh0xx5mdpjhvdl6"; + }; + phases = [ "unpackPhase" "installPhase" ]; + # here we can chance to edit `includes/proxy-cache-paths.conf` + installPhase = '' + mkdir -p $out + cp -r * $out/ + sed -i -e 's/^\(user\).*/\1 ${cfg.user} ${cfg.group};/' \ + -e 's/^\(error_log\).*/\1 stderr;\ndaemon off;/' $out/nginx.conf + ''; + }; + cfg = { + group = "nginx-lancache"; + user = "nginx-lancache"; + stateDir = "/var/lancache"; + package = pkgs.stdenv.lib.overrideDerivation pkgs.nginx (old:{ + configureFlags = old.configureFlags ++ [ + "--with-http_slice_module" + "--with-stream" + "--with-pcre" + ]; + }); + }; +in { + systemd.services.nginx-lancache = { + description = "Nginx lancache Server"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + restartIfChanged = true; + + preStart = '' + PATH_CACHE="/var/lancache/cache" + PATH_LOGS="/var/lancache/logs" + WWW_USER="${cfg.user}" + WWW_GROUP="${cfg.group}" + + mkdir -p $PATH_CACHE + cd $PATH_CACHE + mkdir -p installers tmp + mkdir -p $PATH_LOGS + + chown -R $WWW_USER:$WWW_USER $PATH_CACHE + chown -R $WWW_USER:$WWW_USER $PATH_LOGS + ''; + serviceConfig = { + ExecStart = "${cfg.package}/bin/nginx -c ${lancache}/nginx.conf -p ${lancache}"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + Restart = "always"; + RestartSec = "10s"; + StartLimitInterval = "1min"; + }; + }; + users.extraUsers = (singleton + { name = cfg.user; + group = cfg.group; + uid = genid cfg.group; + }); + + users.extraGroups = (singleton + { name = "${cfg.group}"; + gid = genid cfg.group; + }); + +} -- cgit v1.2.3 From dca58fbc212468cb97e15ac1fc2f47a1693c7ff3 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 27 Jun 2017 21:02:36 +0200 Subject: make led-fader: after networ-online.target --- makefu/2configs/deployment/led-fader.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/makefu/2configs/deployment/led-fader.nix b/makefu/2configs/deployment/led-fader.nix index 50023693d..678370c69 100644 --- a/makefu/2configs/deployment/led-fader.nix +++ b/makefu/2configs/deployment/led-fader.nix @@ -31,6 +31,7 @@ in { }; # after = [ (lib.optional config.services.mosqitto.enable "mosquitto.service") ]; wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" ]; serviceConfig = { # User = "nobody"; # need a user with permissions to run nix-shell ExecStart = "${pkg}/bin/ampel 4 ${pkg}/share/times.json"; -- cgit v1.2.3