summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
Diffstat (limited to 'tv')
-rw-r--r--tv/1systems/cd.nix78
-rw-r--r--tv/1systems/xu.nix1
-rw-r--r--tv/2configs/default.nix17
-rw-r--r--tv/2configs/git.nix7
-rw-r--r--tv/2configs/retiolum.nix3
-rw-r--r--tv/5pkgs/netcup/default.nix32
-rw-r--r--tv/5pkgs/q/default.nix177
-rw-r--r--tv/Zcerts/charybdis_cd.crt.pem24
8 files changed, 185 insertions, 154 deletions
diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix
index 043e91510..dd8e2cc64 100644
--- a/tv/1systems/cd.nix
+++ b/tv/1systems/cd.nix
@@ -10,85 +10,7 @@ with import <stockholm/lib>;
../2configs/hw/CAC-Developer-2.nix
../2configs/fs/CAC-CentOS-7-64bit.nix
../2configs/exim-smarthost.nix
- ../2configs/git.nix
../2configs/retiolum.nix
- ../2configs/urlwatch.nix
- {
- tv.charybdis = {
- enable = true;
- ssl_cert = ../Zcerts/charybdis_cd.crt.pem;
- };
- tv.iptables.input-retiolum-accept-tcp = [
- config.tv.charybdis.port
- config.tv.charybdis.sslport
- ];
- }
- {
- tv.ejabberd = {
- enable = true;
- hosts = [ "jabber.viljetic.de" ];
- };
- tv.iptables.input-internet-accept-tcp = [
- "xmpp-client"
- "xmpp-server"
- ];
- }
- {
- krebs.github-hosts-sync.enable = true;
- tv.iptables.input-internet-accept-tcp =
- singleton config.krebs.github-hosts-sync.port;
- }
- {
- krebs.nginx.servers.cgit.server-names = [
- "cgit.cd.krebsco.de"
- "cgit.cd.viljetic.de"
- ];
- # TODO make public_html also available to cd, cd.retiolum (AKA default)
- krebs.nginx.servers."https://viljetic.de" = {
- server-names = singleton "viljetic.de";
- listen = mkForce []; # disable default
- ssl = {
- enable = true;
- certificate = "/var/lib/acme/viljetic.de/fullchain.pem";
- certificate_key = "/var/lib/acme/viljetic.de/key.pem";
- };
- locations = [
- (nameValuePair "/" ''
- root ${pkgs.viljetic-pages};
- '')
- (nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
- alias /home/$1/public_html$2;
- '')
- ];
- };
- krebs.nginx.servers."http://viljetic.de" = {
- server-names = singleton "viljetic.de";
- locations = [
- (nameValuePair "/.well-known/acme-challenge/" ''
- root /var/lib/acme/challenges/viljetic.de/;
- '')
- (nameValuePair "/" ''
- return 301 https://viljetic.de$request_uri;
- '')
- ];
- };
- security.acme = {
- certs."viljetic.de" = {
- email = "tomislav@viljetic.de";
- webroot = "/var/lib/acme/challenges/viljetic.de";
- plugins = [
- "account_key.json"
- "key.pem"
- "fullchain.pem"
- ];
- user = "nginx";
- };
- };
- tv.iptables.input-internet-accept-tcp = [
- "http"
- "https"
- ];
- }
];
networking = {
diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix
index a84da38db..a7e0b839d 100644
--- a/tv/1systems/xu.nix
+++ b/tv/1systems/xu.nix
@@ -54,6 +54,7 @@ with import <stockholm/lib>;
jq
mkpasswd
netcat
+ netcup
nix-repl
nmap
p7zip
diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix
index 39d0c4f6b..dbf311479 100644
--- a/tv/2configs/default.nix
+++ b/tv/2configs/default.nix
@@ -14,7 +14,7 @@ with import <stockholm/lib>;
stockholm.file = "/home/tv/stockholm";
nixpkgs.git = {
url = https://github.com/NixOS/nixpkgs;
- ref = "e4fb65a3627f8c17a2f92c08bf302dc30f0a8db9";
+ ref = "1e1112edc57e93046f35707b874d2a4f3ff321e6";
};
} // optionalAttrs host.secure {
secrets-master.file = "/home/tv/secrets/master";
@@ -112,13 +112,14 @@ with import <stockholm/lib>;
};
}
- (let ca-bundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; in {
- environment.variables = {
- CURL_CA_BUNDLE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
- GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
- SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
- };
- })
+ {
+ environment.variables =
+ flip genAttrs (_: "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt") [
+ "CURL_CA_BUNDLE"
+ "GIT_SSL_CAINFO"
+ "SSL_CERT_FILE"
+ ];
+ }
{
services.cron.enable = false;
diff --git a/tv/2configs/git.nix b/tv/2configs/git.nix
index d937be2c4..b6724f40e 100644
--- a/tv/2configs/git.nix
+++ b/tv/2configs/git.nix
@@ -32,6 +32,9 @@ let
get = {};
hack = {};
load-env = {};
+ loldns = {
+ cgit.desc = "toy DNS server";
+ };
make-snapshot = {};
much = {};
netcup = {
@@ -81,12 +84,12 @@ let
make-public-repo = name: { cgit ? {}, ... }: {
inherit cgit name;
public = true;
- hooks = optionalAttrs (config.krebs.build.host.name == "cd") {
+ hooks = optionalAttrs (config.krebs.build.host.name == "ni") {
post-receive = pkgs.git-hooks.irc-announce {
# TODO make nick = config.krebs.build.host.name the default
nick = config.krebs.build.host.name;
channel = "#retiolum";
- server = "cd.retiolum";
+ server = "ni.r";
verbose = true;
};
};
diff --git a/tv/2configs/retiolum.nix b/tv/2configs/retiolum.nix
index ad1116d4f..a914dad43 100644
--- a/tv/2configs/retiolum.nix
+++ b/tv/2configs/retiolum.nix
@@ -7,9 +7,8 @@ with import <stockholm/lib>;
enable = true;
connectTo = filter (ne config.krebs.build.host.name) [
"gum"
+ "ni"
"prism"
- "echelon"
- "cd"
];
tincPackage = pkgs.tinc_pre;
};
diff --git a/tv/5pkgs/netcup/default.nix b/tv/5pkgs/netcup/default.nix
new file mode 100644
index 000000000..6d2ec6896
--- /dev/null
+++ b/tv/5pkgs/netcup/default.nix
@@ -0,0 +1,32 @@
+{ coreutils, curl, fetchgit, gawk, gnugrep, gnused, jq, stdenv, w3m, ... }:
+with import <stockholm/lib>;
+let
+ readJSON = path: fromJSON (readFile path);
+ sed.escape = replaceChars ["/"] ["\\/"]; # close enough
+ PATH = makeBinPath [
+ coreutils
+ curl
+ gawk
+ gnugrep
+ gnused
+ jq
+ w3m
+ ];
+in
+stdenv.mkDerivation {
+ name = "netcup-1.0.0";
+ src = fetchgit {
+ url = "http://cgit.ni.krebsco.de/netcup";
+ rev = "tags/v1.0.0";
+ sha256 = "0m6mk16pblvnapxykxdccvphslbv1gjfziyr86bnqin1xb1g99bq";
+ };
+ phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+ patchPhase = ''
+ path=${shell.escape (sed.escape PATH)}
+ sed -i "1s/.*/&\nPATH=$path/" vcp
+ '';
+ installPhase = ''
+ mkdir -p $out/bin
+ cp vcp $out/bin
+ '';
+}
diff --git a/tv/5pkgs/q/default.nix b/tv/5pkgs/q/default.nix
index f923950f0..a3a7cd739 100644
--- a/tv/5pkgs/q/default.nix
+++ b/tv/5pkgs/q/default.nix
@@ -62,47 +62,143 @@ let
fi
'';
- q-power_supply = ''
+ q-intel_backlight = ''
+ cd /sys/class/backlight/intel_backlight
+ </dev/null exec ${pkgs.gawk}/bin/awk '
+ END {
+ getline actual_brightness < "actual_brightness"
+ getline max_brightness < "max_brightness"
+ getline brightness < "brightness"
+ printf "intel_backlight %d%% %d/%d\n" \
+ , actual_brightness / max_brightness * 100 \
+ , actual_brightness \
+ , max_brightness
+ }
+ '
+ '';
+
+ q-power_supply = let
+ power_supply = pkgs.writeBash "power_supply" ''
+ set -efu
+ uevent=$1
+ eval "$(${pkgs.gnused}/bin/sed -n '
+ s/^\([A-Z_]\+=[0-9A-Za-z_-]*\)$/export \1/p
+ ' $uevent)"
+ case $POWER_SUPPLY_NAME in
+ AC)
+ exit # not battery
+ ;;
+ esac
+ exec </dev/null
+ exec ${pkgs.gawk}/bin/awk '
+ function die(s) {
+ printf "%s: %s\n", name, s
+ exit 1
+ }
+
+ function print_hm(h, m) {
+ m = (h - int(h)) * 60
+ return sprintf("%dh%dm", h, m)
+ }
+
+ function print_bar(n, r, t1, t2, t_col) {
+ t1 = int(r * n)
+ t2 = n - t1
+ if (r >= .42) t_col = "1;32"
+ else if (r >= 23) t_col = "1;33"
+ else if (r >= 11) t_col = "1;31"
+ else t_col = "5;1;31"
+ return sgr(t_col) strdup("■", t1) sgr(";30") strdup("■", t2) sgr()
+ }
+
+ function sgr(p) {
+ return "\x1b[" p "m"
+ }
+
+ function strdup(s,n,t) {
+ t = sprintf("%"n"s","")
+ gsub(/ /,s,t)
+ return t
+ }
+
+ END {
+ name = ENVIRON["POWER_SUPPLY_NAME"]
+
+ charge_unit = "Ah"
+ charge_now = ENVIRON["POWER_SUPPLY_CHARGE_NOW"] / 10^6
+ charge_full = ENVIRON["POWER_SUPPLY_CHARGE_FULL"] / 10^6
+
+ current_unit = "A"
+ current_now = ENVIRON["POWER_SUPPLY_CURRENT_NOW"] / 10^6
+
+ energy_unit = "Wh"
+ energy_now = ENVIRON["POWER_SUPPLY_ENERGY_NOW"] / 10^6
+ energy_full = ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6
+
+ power_unit = "W"
+ power_now = ENVIRON["POWER_SUPPLY_POWER_NOW"] / 10^6
+
+ voltage_unit = "V"
+ voltage_now = ENVIRON["POWER_SUPPLY_VOLTAGE_NOW"] / 10^6
+ voltage_min_design = ENVIRON["POWER_SUPPLY_VOLTAGE_MIN_DESIGN"] / 10^6
+
+ #printf "charge_now: %s\n", charge_now
+ #printf "charge_full: %s\n", charge_full
+ #printf "current_now: %s\n", current_now
+ #printf "energy_now: %s\n", energy_now
+ #printf "energy_full: %s\n", energy_full
+ #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"]
+ #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6
+ #printf "power_now: %s\n", power_now
+ #printf "voltage_now: %s\n", voltage_now
+
+ if (current_now == 0 && voltage_now != 0) {
+ current_now = power_now / voltage_now
+ }
+ if (power_now == 0) {
+ power_now = current_now * voltage_now
+ }
+ if (charge_now == 0 && voltage_min_design != 0) {
+ charge_now = energy_now / voltage_min_design
+ }
+ if (energy_now == 0) {
+ energy_now = charge_now * voltage_min_design
+ }
+ if (charge_full == 0 && voltage_min_design != 0) {
+ charge_full = energy_full / voltage_min_design
+ }
+ if (energy_full == 0) {
+ energy_full = charge_full * voltage_min_design
+ }
+
+ if (charge_now == 0 || charge_full == 0) {
+ die("unknown charge")
+ }
+
+ charge_ratio = charge_now / charge_full
+
+ out = out name
+ out = out sprintf(" %s", print_bar(10, charge_ratio))
+ out = out sprintf(" %d%", charge_ratio * 100)
+ out = out sprintf(" %.2f%s", charge_now, charge_unit)
+ if (current_now != 0) {
+ out = out sprintf("/%.1f%s", current_now, current_unit)
+ }
+ out = out sprintf(" %d%s", energy_full, energy_unit)
+ if (power_now != 0) {
+ out = out sprintf("/%.1f%s", power_now, power_unit)
+ }
+ if (current_now != 0) {
+ out = out sprintf(" %s", print_hm(charge_now / current_now))
+ }
+
+ print out
+ }
+ '
+ '';
+ in ''
for uevent in /sys/class/power_supply/*/uevent; do
- if test -f $uevent; then
- eval "$(${pkgs.gnused}/bin/sed -n '
- s/^\([A-Z_]\+=\)\(.*\)/\1'\'''\2'\'''/p
- ' $uevent)"
-
- if test "x''${POWER_SUPPLY_CHARGE_NOW-}" = x; then
- continue
- fi
-
- charge_percentage=$(echo "
- scale=2
- $POWER_SUPPLY_CHARGE_NOW / $POWER_SUPPLY_CHARGE_FULL
- " | ${pkgs.bc}/bin/bc)
-
- lfc=$POWER_SUPPLY_CHARGE_FULL
- rc=$POWER_SUPPLY_CHARGE_NOW
- #rc=2800
- N=78; N=76
- N=10
- n=$(echo $N-1 | ${pkgs.bc}/bin/bc)
- centi=$(echo "$rc*100/$lfc" | ${pkgs.bc}/bin/bc)
- deci=$(echo "$rc*$N/$lfc" | ${pkgs.bc}/bin/bc)
- energy_evel=$(
- echo -n '☳ ' # TRIGRAM FOR THUNDER
- if test $centi -ge 42; then echo -n ''
- elif test $centi -ge 23; then echo -n ''
- elif test $centi -ge 11; then echo -n ''
- else echo -n ''; fi
- for i in $(${pkgs.coreutils}/bin/seq 1 $deci); do
- echo -n ■
- done
- echo -n ''
- for i in $(${pkgs.coreutils}/bin/seq $deci $n); do
- echo -n ■
- done
- echo '' $rc #/ $lfc
- )
- echo "$energy_evel $charge_percentage"
- fi
+ ${power_supply} "$uevent" || :
done
'';
@@ -188,6 +284,7 @@ pkgs.writeBashBin "q" ''
${q-isodate}
${q-sgtdate}
(${q-gitdir}) &
+ (${q-intel_backlight}) &
(${q-power_supply}) &
(${q-virtualization}) &
(${q-wireless}) &
diff --git a/tv/Zcerts/charybdis_cd.crt.pem b/tv/Zcerts/charybdis_cd.crt.pem
deleted file mode 100644
index c613ff380..000000000
--- a/tv/Zcerts/charybdis_cd.crt.pem
+++ /dev/null
@@ -1,24 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEGzCCAwOgAwIBAgIJAJJiphQRTzFPMA0GCSqGSIb3DQEBBQUAMIGjMQswCQYD
-VQQGEwJhcTEYMBYGA1UECAwPTWFyaWUgQnlyZCBMYW5kMSIwIAYDVQQHDBlCZW50
-bGV5IFN1YmdsYWNpYWwgVHJlbmNoMQ4wDAYDVQQKDAVrcmViczERMA8GA1UECwwI
-cmV0aW9sdW0xFDASBgNVBAMMC2NkLnJldGlvbHVtMR0wGwYJKoZIhvcNAQkBFg50
-dkB3dS5yZXRpb2x1bTAeFw0xNTA3MTkxODQ2MjhaFw0xNjA3MDkxODQ2MjhaMIGj
-MQswCQYDVQQGEwJhcTEYMBYGA1UECAwPTWFyaWUgQnlyZCBMYW5kMSIwIAYDVQQH
-DBlCZW50bGV5IFN1YmdsYWNpYWwgVHJlbmNoMQ4wDAYDVQQKDAVrcmViczERMA8G
-A1UECwwIcmV0aW9sdW0xFDASBgNVBAMMC2NkLnJldGlvbHVtMR0wGwYJKoZIhvcN
-AQkBFg50dkB3dS5yZXRpb2x1bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
-ggEBAMyPb37kchbjZi6WsvpQeGOVEBTU8B4E24GkfetbfYtsFqW6pIKN7DlTFKzJ
-3WKSLIf/cZuBQJucKuc8QXc5ZEXQ66QyCiX6al0j4C0AnHN17OhgH3yvmioWI4kI
-ycD4N5TnaD2V0OK/HlhKCrIEly6+Nczeo+k5vrcgkkSYJivFpgK1r5+taBYiU4cc
-Pgke2p3mRpZFfK61Ft6DlAg2rL2NVt7Qk0pp6BgCrtVIl968SmVKAEQBHnSYd9z2
-bNE2PH3qI+FLIfioOfXazmogxoQWR9LbKPUQ5nFRDXEJZg1hKDzseUkwV/oU8W3K
-a37lOovqy+qwjYELrWP346/OF5UCAwEAAaNQME4wHQYDVR0OBBYEFI7WWP+tabb5
-CH5aY5mJcMdKGeaXMB8GA1UdIwQYMBaAFI7WWP+tabb5CH5aY5mJcMdKGeaXMAwG
-A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKAF8hSu7Cgp2jei3GPVOE+R
-TtZUePjFJw7iUSYaG1loGfY23IgEzS/jPd/m4jueRTDbtDl7cFTUmKKsF1WWH84l
-s49J2HktiHTiHyZphgWFfbjUZO4nbH11Pac64WPfoeTzm9LnM0xXNd/7VCDXRess
-a6pXtAQXAZri9HOsAeNO0WFivu4oug2pyUoLE64o3UemSwBi0JW2W1KvuYGnQXEa
-HqrFGLBSEQuD4wTePdK0USjhNC8ceMx04b1hUQzuMf8pcXdpkLN6bIOaA/FRxmX9
-3L+6CZPVfQvvw10eLjWv3UYgIjOQFCUR4LsvkVxTaEav0KwmyCC4GUr9Vd+n3eQ=
------END CERTIFICATE-----