summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/2configs')
-rw-r--r--krebs/2configs/binary-cache/prism.nix2
-rw-r--r--krebs/2configs/cache.nsupdate.info.nix8
-rw-r--r--krebs/2configs/exim-smarthost.nix50
-rw-r--r--krebs/2configs/gitlab-runner-shackspace.nix2
-rw-r--r--krebs/2configs/nscd-fix.nix24
-rw-r--r--krebs/2configs/reaktor-krebs.nix30
-rw-r--r--krebs/2configs/reaktor-retiolum.nix21
-rw-r--r--krebs/2configs/reaktor2.nix158
-rw-r--r--krebs/2configs/shack/gitlab-runner.nix21
-rw-r--r--krebs/2configs/shack/mobile.mpd.nix5
-rw-r--r--krebs/2configs/shack/netbox.nix39
-rw-r--r--krebs/2configs/shack/ympd-top-next.patch16
12 files changed, 320 insertions, 56 deletions
diff --git a/krebs/2configs/binary-cache/prism.nix b/krebs/2configs/binary-cache/prism.nix
index 46b386e1..51b4a1af 100644
--- a/krebs/2configs/binary-cache/prism.nix
+++ b/krebs/2configs/binary-cache/prism.nix
@@ -3,7 +3,7 @@
{
nix = {
binaryCaches = [
- "http://cache.prism.r"
+ "https://cache.krebsco.de"
];
binaryCachePublicKeys = [
"cache.prism-1:+S+6Lo/n27XEtvdlQKuJIcb1yO5NUqUCE2lolmTgNJU="
diff --git a/krebs/2configs/cache.nsupdate.info.nix b/krebs/2configs/cache.nsupdate.info.nix
index 056667d8..74f34561 100644
--- a/krebs/2configs/cache.nsupdate.info.nix
+++ b/krebs/2configs/cache.nsupdate.info.nix
@@ -1,4 +1,4 @@
-{lib, ... }:
+{ pkgs, lib, ... }:
with lib;
let
domain = "cache.nsupdate.info";
@@ -17,9 +17,13 @@ in {
};
krebs.cachecache = {
enable = true;
- enableSSL = false; # disable letsencrypt for testing
+ enableSSL = true; # disable letsencrypt for testing
cacheDir = "/var/cache/nix-cache-cache";
maxSize = "10g";
+ indexFile = pkgs.fetchurl {
+ url = "https://raw.githubusercontent.com/krebs/35c3-nixos-cache/master/index.html";
+ sha256 = "1vlngzbn0jipigspccgikd7xgixksimdl4wf8ix7d30ljx47p9n0";
+ };
# assumes that the domain is reachable from the internet
virtualHost = domain;
diff --git a/krebs/2configs/exim-smarthost.nix b/krebs/2configs/exim-smarthost.nix
new file mode 100644
index 00000000..5dc24f1d
--- /dev/null
+++ b/krebs/2configs/exim-smarthost.nix
@@ -0,0 +1,50 @@
+with import <stockholm/lib>;
+{ config, ... }: let
+
+ format = from: to: {
+ inherit from;
+ # TODO assert is-retiolum-mail-address to;
+ to = concatMapStringsSep "," (getAttr "mail") (toList to);
+ };
+
+in {
+ krebs.exim-smarthost.internet-aliases =
+ mapAttrsToList format (with config.krebs.users; let
+ brain-ml = [
+ lass
+ makefu
+ tv
+ ];
+ eloop-ml = spam-ml ++ [ ciko ];
+ spam-ml = [
+ lass
+ makefu
+ tv
+ ];
+ ciko.mail = "ciko@slash16.net";
+ in {
+ "anmeldung@eloop.org" = eloop-ml;
+ "brain@krebsco.de" = brain-ml;
+ "cfp@eloop.org" = eloop-ml;
+ "kontakt@eloop.org" = eloop-ml;
+ "root@eloop.org" = eloop-ml;
+ "youtube@eloop.org" = eloop-ml;
+ "eloop2016@krebsco.de" = eloop-ml;
+ "eloop2017@krebsco.de" = eloop-ml;
+ "postmaster@krebsco.de" = spam-ml; # RFC 822
+ "lass@krebsco.de" = lass;
+ "makefu@krebsco.de" = makefu;
+ "spam@krebsco.de" = spam-ml;
+ "tv@krebsco.de" = tv;
+ # XXX These are no internet aliases
+ # XXX exim-retiolum hosts should be able to relay to retiolum addresses
+ "lass@retiolum" = lass;
+ "makefu@retiolum" = makefu;
+ "spam@retiolum" = spam-ml;
+ "tv@retiolum" = tv;
+ "lass@r" = lass;
+ "makefu@r" = makefu;
+ "spam@r" = spam-ml;
+ "tv@r" = tv;
+ });
+}
diff --git a/krebs/2configs/gitlab-runner-shackspace.nix b/krebs/2configs/gitlab-runner-shackspace.nix
index f4247b6d..75edf653 100644
--- a/krebs/2configs/gitlab-runner-shackspace.nix
+++ b/krebs/2configs/gitlab-runner-shackspace.nix
@@ -4,7 +4,7 @@ let
# generate token from CI-token via:
## gitlab-runner register
## cat /etc/gitlab-runner/config.toml
- token = import <secrets/shackspace-gitlab-ci-token.nix> ;
+ token = import (toString <secrets/shackspace-gitlab-ci-token.nix>);
in {
systemd.services.gitlab-runner.path = [
"/run/wrappers" # /run/wrappers/bin/su
diff --git a/krebs/2configs/nscd-fix.nix b/krebs/2configs/nscd-fix.nix
new file mode 100644
index 00000000..8e5909e7
--- /dev/null
+++ b/krebs/2configs/nscd-fix.nix
@@ -0,0 +1,24 @@
+with import <stockholm/lib>;
+{ pkgs, ... }: let
+
+ enable = versionOlderThan "19.03";
+
+ versionOlderThan = v:
+ compareVersions
+ (versions.majorMinor version)
+ (versions.majorMinor v)
+ == -1;
+
+ warning = ''
+ Using custom services.nscd.config because
+ https://github.com/NixOS/nixpkgs/pull/50316
+ '';
+
+in
+ optionalAttrs enable (trace warning {
+ services.nscd.enable = mkForce true;
+ services.nscd.config = mkForce (readFile (pkgs.fetchurl {
+ url = https://raw.githubusercontent.com/arianvp/nixpkgs/1d5f4cb/nixos/modules/services/system/nscd.conf;
+ sha256 = "1jlddk38lyynjn51zx3xi1nc29ahajyh0qg48qbq6dqlsrn3wxqs";
+ }));
+ })
diff --git a/krebs/2configs/reaktor-krebs.nix b/krebs/2configs/reaktor-krebs.nix
deleted file mode 100644
index dc2838ca..00000000
--- a/krebs/2configs/reaktor-krebs.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ config, lib, pkgs, ... }:
-with import <stockholm/lib>;
-
-{
- krebs.Reaktor.krebs = {
- nickname = "Reaktor|krebs";
- channels = [
- "#krebs"
- "#nixos-wiki"
- ];
- extraEnviron = {
- REAKTOR_HOST = "irc.freenode.org";
- REAKTOR_NICKSERV_PASSWORD = "/var/lib/Reaktor/reaktor_nickserv_password";
- };
- plugins = with pkgs.ReaktorPlugins; [
- sed-plugin
- task-add
- task-delete
- task-done
- task-list
- ] ++
- (attrValues (todo "agenda"))
- ;
- };
- krebs.secret.files.nix-serve-key = {
- path = "/var/lib/Reaktor/reaktor_nickserv_password";
- owner.name = "Reaktor";
- source-path = toString <secrets> + "/reaktor_nickserv_password";
- };
-}
diff --git a/krebs/2configs/reaktor-retiolum.nix b/krebs/2configs/reaktor-retiolum.nix
deleted file mode 100644
index 824f59d0..00000000
--- a/krebs/2configs/reaktor-retiolum.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-{ config, lib, pkgs, ... }:
-with import <stockholm/lib>;
-
-{
- krebs.Reaktor.retiolum = {
- nickname = "Reaktor|lass";
- channels = [ "#noise" "#xxx" ];
- extraEnviron = {
- REAKTOR_HOST = "irc.r";
- };
- plugins = with pkgs.ReaktorPlugins; [
- sed-plugin
- task-add
- task-delete
- task-done
- task-list
- ] ++
- (attrValues (todo "agenda"))
- ;
- };
-}
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
new file mode 100644
index 00000000..b52125ae
--- /dev/null
+++ b/krebs/2configs/reaktor2.nix
@@ -0,0 +1,158 @@
+with import <stockholm/lib>;
+{ config, pkgs, ... }:
+
+let
+ #for shared state directory
+ stateDir = config.krebs.reaktor2.r.stateDir;
+
+ generators = pkgs.reaktor2-plugins.generators;
+ hooks = pkgs.reaktor2-plugins.hooks;
+ commands = pkgs.reaktor2-plugins.commands;
+
+ task = name: let
+ rcFile = builtins.toFile "taskrc" ''
+ confirmation=no
+ '';
+ in {
+ pattern = "^${name}-([a-z]+)(?::\\s*(.*))?";
+ activate = "match";
+ command = 1;
+ arguments = [2];
+ env.TASKDATA = "${stateDir}/${name}";
+ commands = {
+ add.filename = pkgs.writeDash "${name}-task-add" ''
+ ${pkgs.taskwarrior}/bin/task rc:${rcFile} add "$1"
+ '';
+ list.filename = pkgs.writeDash "${name}-task-list" ''
+ ${pkgs.taskwarrior}/bin/task rc:${rcFile} export \
+ | ${pkgs.jq}/bin/jq -r '
+ .[] | select(.id != 0) | "\(.id) \(.description)"
+ '
+ '';
+ delete.filename = pkgs.writeDash "${name}-task-delete" ''
+ ${pkgs.taskwarrior}/bin/task rc:${rcFile} delete "$1"
+ '';
+ done.filename = pkgs.writeDash "${name}-task-done" ''
+ ${pkgs.taskwarrior}/bin/task rc:${rcFile} done "$1"
+ '';
+ };
+ };
+
+ systemPlugin = {
+ plugin = "system";
+ config = {
+ workdir = stateDir;
+ hooks.JOIN = [
+ {
+ activate = "always";
+ command = {
+ filename =
+ "${pkgs.Reaktor.src}/reaktor/commands/tell-on_join";
+ env = {
+ PATH = makeBinPath [
+ pkgs.coreutils # XXX env, touch
+ pkgs.jq # XXX sed
+ pkgs.utillinux # XXX flock
+ ];
+ state_file = "${stateDir}/tell.json";
+ };
+ };
+ }
+ ];
+ hooks.PRIVMSG = [
+ {
+ pattern = "^bier bal(an(ce)?)?$";
+ activate = "match";
+ command = {
+ env = {
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "bier-balance" ''
+ ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
+ | ${pkgs.coreutils}/bin/tail +2 \
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat
+ '';
+ };
+ }
+ {
+ pattern = ''^(\S+)\s+([+-][1-9][0-9]*)\s+(\S+)$'';
+ activate = "match";
+ arguments = [1 2 3];
+ command = {
+ env = {
+ # TODO; get state as argument
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "ledger-add" ''
+ set -x
+ tonick=$1
+ amt=$2
+ unit=$3
+ printf '%s\n %s %d %s\n %s %d %s\n' "$(date -Id)" "$tonick" "$amt" "$unit" "$_from" "$(expr 0 - "''${amt#+}")" "$unit" >> $state_file
+ '';
+ };
+ }
+ hooks.sed
+ (generators.command_hook {
+ inherit (commands) hello random-emoji nixos-version stockholm-issue;
+ tell = {
+ filename =
+ "${pkgs.Reaktor.src}/reaktor/commands/tell-on_privmsg";
+ env = {
+ PATH = makeBinPath [
+ pkgs.coreutils # XXX date, env
+ pkgs.jq # XXX sed
+ pkgs.utillinux # XXX flock
+ ];
+ state_file = "${stateDir}/tell.txt";
+ };
+ };
+ })
+ (task "agenda")
+ ];
+ };
+ };
+
+in {
+
+ users.users.reaktor2 = {
+ uid = genid_uint31 "reaktor2";
+ home = stateDir;
+ };
+
+ krebs.reaktor2 = {
+ freenode = {
+ hostname = "irc.freenode.org";
+ nick = "reaktor2|krebs";
+ plugins = [
+ {
+ plugin = "register";
+ config = {
+ channels = [
+ "#krebs"
+ ];
+ };
+ }
+ systemPlugin
+ ];
+ username = "reaktor2";
+ };
+ r = {
+ nick = "reaktor2|krebs";
+ sendDelaySec = null;
+ plugins = [
+ {
+ plugin = "register";
+ config = {
+ channels = [
+ "#noise"
+ "#xxx"
+ ];
+ };
+ }
+ systemPlugin
+ ];
+ username = "reaktor2";
+ };
+ };
+}
diff --git a/krebs/2configs/shack/gitlab-runner.nix b/krebs/2configs/shack/gitlab-runner.nix
new file mode 100644
index 00000000..57d670ea
--- /dev/null
+++ b/krebs/2configs/shack/gitlab-runner.nix
@@ -0,0 +1,21 @@
+{ pkgs, ... }:
+let
+ runner-src = builtins.fetchTarball {
+ url = "https://gitlab.com/arianvp/nixos-gitlab-runner/-/archive/master/nixos-gitlab-runner-master.tar.gz";
+ sha256 = "1s0fy5ny2ygcfvx35xws8xz5ih4z4kdfqlq3r6byxpylw7r52fyi";
+ };
+in
+{
+ systemd.services.gitlab-runner.path = [
+ "/run/wrappers" # /run/wrappers/bin/su
+ "/" # /bin/sh
+ ];
+ imports = [
+ "${runner-src}/gitlab-runner.nix"
+ ];
+ services.gitlab-runner2.enable = true;
+ ## registrationConfigurationFile contains:
+ # CI_SERVER_URL=<CI server URL>
+ # REGISTRATION_TOKEN=<registration secret>
+ services.gitlab-runner2.registrationConfigFile = <secrets/shackspace-gitlab-ci>;
+}
diff --git a/krebs/2configs/shack/mobile.mpd.nix b/krebs/2configs/shack/mobile.mpd.nix
index 2dc466ed..751d233e 100644
--- a/krebs/2configs/shack/mobile.mpd.nix
+++ b/krebs/2configs/shack/mobile.mpd.nix
@@ -1,5 +1,8 @@
{lib,pkgs, ... }:
let
+ pkg = lib.overrideDerivation pkgs.ympd (old: {
+ patches = [ ./ympd-top-next.patch ];
+ });
mpdHost = "mpd.shack";
ympd = name: port: let
webPort = 10000 + port;
@@ -7,7 +10,7 @@ let
systemd.services."ympd-${name}" = {
description = "mpd for ${name}";
wantedBy = [ "multi-user.target" ];
- serviceConfig.ExecStart = "${pkgs.ympd}/bin/ympd --host ${mpdHost} --port ${toString port} --webport ${toString webPort} --user nobody";
+ serviceConfig.ExecStart = "${pkg}/bin/ympd --host ${mpdHost} --port ${toString port} --webport ${toString webPort} --user nobody";
};
services.nginx.virtualHosts."mobile.${name}.mpd.shack" = {
serverAliases = [
diff --git a/krebs/2configs/shack/netbox.nix b/krebs/2configs/shack/netbox.nix
new file mode 100644
index 00000000..4fb5a7db
--- /dev/null
+++ b/krebs/2configs/shack/netbox.nix
@@ -0,0 +1,39 @@
+{ pkgs, ... }:
+{
+ environment.systemPackages = [ pkgs.docker-compose ];
+ virtualisation.docker.enable = true;
+ services.nginx = {
+ enable = true;
+ virtualHosts."netbox.shack".locations."/".proxyPass = "http://localhost:18080";
+ };
+ # we store the netbox config there:
+ # state = [ "/var/lib/netbox" ];
+ systemd.services.backup-netbox = {
+ after = [ "netbox-docker-compose.service" ];
+ startAt = "daily";
+ path = with pkgs; [ docker-compose docker gzip coreutils ];
+ script = ''
+ cd /var/lib/netbox
+ mkdir -p backup
+ docker-compose exec -T -upostgres postgres pg_dumpall \
+ | gzip > backup/netdata_$(date -Iseconds).dump.gz
+ '';
+ };
+
+ systemd.services.netbox-docker-compose = {
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network-online.target" "docker.service" ];
+ environment.VERSION = "v2.5.13";
+ serviceConfig = {
+ WorkingDirectory = "/var/lib/netbox";
+ # TODO: grep -q NAPALM_SECRET env/netbox.env
+ # TODO: grep -q NAPALM_SECRET netbox-netprod-importer/switches.yml
+ ExecStartPre = "${pkgs.docker-compose}/bin/docker-compose pull";
+ ExecStart = "${pkgs.docker-compose}/bin/docker-compose up";
+ Restart = "always";
+ RestartSec = "10";
+ StartLimitIntervalSec = 60;
+ StartLimitBurst = 3;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/ympd-top-next.patch b/krebs/2configs/shack/ympd-top-next.patch
new file mode 100644
index 00000000..fd424f11
--- /dev/null
+++ b/krebs/2configs/shack/ympd-top-next.patch
@@ -0,0 +1,16 @@
+diff --git a/htdocs/index.html b/htdocs/index.html
+index ed77279..eaf92b6 100644
+--- a/htdocs/index.html
++++ b/htdocs/index.html
+@@ -76,6 +76,11 @@
+
+ <div class="col-md-10 col-xs-12">
+ <div class="notifications top-right"></div>
++
++ <ul class="pager">
++ <li id="prev" class="page-btn hide"><a href="">Previous</a></li>
++ <li id="next" class="page-btn"><a href="">Next</a></li>
++ </ul>
+
+ <div class="panel panel-primary">
+ <!-- Default panel contents -->