From 291bc460d522b2e2c785ec3c3b71a80f22b67853 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 03:23:18 +0200 Subject: tv xmonad: read screen/font width from build env --- tv/2configs/xserver/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 4e9e30741..256604a4c 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -6,6 +6,12 @@ let configDir = "/var/empty"; dataDir = "/run/xdg/${cfg.user.name}/xmonad"; user = config.krebs.build.user; + xmonad.pkg = pkgs.haskellPackages.xmonad-tv.overrideAttrs (_: { + XMONAD_BUILD_SCREEN_WIDTH = 1366; + XMONAD_BUILD_TERM_FONT_WIDTH = 6; + XMONAD_BUILD_TERM_FONT = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1"; + XMONAD_BUILD_TERM_PADDING = 2; + }); }; in { @@ -51,7 +57,7 @@ in { systemd.services.display-manager.enable = false; systemd.services.xmonad = let - xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad"; + xmonad = "${cfg.xmonad.pkg}/bin/xmonad"; xmonad-start = pkgs.writeDash "xmonad-start" '' ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR" ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR" -- cgit v1.2.3 From 9a63bb8769217a0240d00c226735f3bca95dbdee Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 03:34:32 +0200 Subject: tv xserver: reconfigure xmonad for au --- tv/2configs/xserver/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 256604a4c..032df5d90 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -7,6 +7,13 @@ let dataDir = "/run/xdg/${cfg.user.name}/xmonad"; user = config.krebs.build.user; xmonad.pkg = pkgs.haskellPackages.xmonad-tv.overrideAttrs (_: { + au = { + XMONAD_BUILD_SCREEN_WIDTH = 1920; + XMONAD_BUILD_TERM_FONT_WIDTH = 10; + XMONAD_BUILD_TERM_FONT = "xft:Input Mono:size=12:style=Regular"; + XMONAD_BUILD_TERM_PADDING = 2; + }; + }.${config.krebs.build.host.name} or { XMONAD_BUILD_SCREEN_WIDTH = 1366; XMONAD_BUILD_TERM_FONT_WIDTH = 6; XMONAD_BUILD_TERM_FONT = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1"; -- cgit v1.2.3 From 58eb3302b0423347433d72248f90912f60b580bd Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 04:07:25 +0200 Subject: tv: make default kernel easily overridable --- tv/2configs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 9db35184a..9132773ca 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -1,7 +1,7 @@ with import ; { config, pkgs, ... }: { - boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelPackages = mkDefault pkgs.linuxPackages_latest; boot.tmpOnTmpfs = true; -- cgit v1.2.3 From 74a65a60eadb6990d6cd6bcb06767f1f40e89f52 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 04:09:45 +0200 Subject: tv: cleanup stale shell aliases --- tv/2configs/default.nix | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 9132773ca..2d813fe32 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -68,18 +68,13 @@ with import ; ]; environment.shellAliases = mkForce { - # alias cal='cal -m3' gp = "${pkgs.pari}/bin/gp -q"; df = "df -h"; du = "du -h"; - # alias grep='grep --color=auto' # TODO alias cannot contain #\' # "ps?" = "ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep"; - # alias la='ls -lA' - lAtr = "ls -lAtr"; - # alias ll='ls -l' ls = "ls -h --color=auto --group-directories-first"; dmesg = "dmesg -L --reltime"; view = "vim -R"; -- cgit v1.2.3 From dac9dba691cb35300ee62199f5bf7b8975f62a1d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 12:17:08 +0200 Subject: tv ppp: remove default config --- tv/2configs/ppp.nix | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix index 9cc7568a5..02227343c 100644 --- a/tv/2configs/ppp.nix +++ b/tv/2configs/ppp.nix @@ -1,32 +1,2 @@ { pkgs, ... }: { - - # usage: pppd call default - - environment.etc."ppp/peers/default".text = '' - /dev/ttyACM2 - 921600 - crtscts - defaultroute - holdoff 10 - lock - maxfail 0 - noauth - nodetach - noipdefault - passive - persist - usepeerdns - connect "${pkgs.ppp}/bin/chat -f ${pkgs.writeText "default.chat" '' - ABORT "BUSY" - ABORT "NO CARRIER" - REPORT CONNECT - "" "ATDT*99#" - CONNECT - ''}" - ''; - - environment.systemPackages = [ - pkgs.ppp - ]; - } -- cgit v1.2.3 From 3c9945364c294ab65c62c01447d00ebc980558bc Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 12:19:13 +0200 Subject: tv ppp: add o2 config --- tv/2configs/ppp.nix | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix index 02227343c..ecb17c3f8 100644 --- a/tv/2configs/ppp.nix +++ b/tv/2configs/ppp.nix @@ -1,2 +1,34 @@ -{ pkgs, ... }: { +{ pkgs, ... }: let + lib = import ; + cfg = { + pin = "@${toString }"; + ttys.ppp = "/dev/ttyACM0"; + }; +in { + environment.etc."ppp/peers/o2".text = /* sh */ '' + ${cfg.ttys.ppp} + 921600 + crtscts + defaultroute + holdoff 10 + lock + maxfail 0 + noauth + nodetach + noipdefault + passive + persist + usepeerdns + connect "${pkgs.ppp}/bin/chat ''${DEBUG+-v} -Ss -f ${pkgs.writeText "o2.chat" /* sh */ '' + ABORT "BUSY" + ABORT "NO CARRIER" + REPORT CONNECT + "*EMRDY: 1" + ATZ OK + AT+CFUN=1 OK + ${cfg.pin} TIMEOUT 2 ERROR-AT-OK + AT+CGDCONT=1,\042IP\042,\042internet\042 OK + ATDT*99***1# CONNECT + ''}" + ''; } -- cgit v1.2.3 From 64a9aeed2298295d204efd05b321dea271ecdb2a Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 12:22:04 +0200 Subject: tv ppp: add connect script --- tv/2configs/ppp.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix index ecb17c3f8..0c74e1642 100644 --- a/tv/2configs/ppp.nix +++ b/tv/2configs/ppp.nix @@ -31,4 +31,30 @@ in { ATDT*99***1# CONNECT ''}" ''; + users.users.root.packages = [ + (pkgs.writeDashBin "connect" '' + # usage: + # connect wlan + # connect wwan [PEERNAME] + set -efu + rfkill_wlan=/sys/class/rfkill/rfkill2 + rfkill_wwan=/sys/class/rfkill/rfkill1 + case $1 in + wlan) + ${pkgs.procps}/bin/pkill pppd || : + echo 0 > "$rfkill_wwan"/state + echo 1 > "$rfkill_wlan"/state + ;; + wwan) + name=''${2-o2} + echo 0 > "$rfkill_wlan"/state + echo 1 > "$rfkill_wwan"/state + ${pkgs.ppp}/bin/pppd call "$name" updetach + ;; + *) + echo "$0: error: bad arguments: $*" >&2 + exit 1 + esac + '') + ]; } -- cgit v1.2.3 From 3f6a68eab4b49f16daf8373ee5d99b8ffd55a119 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 12:22:44 +0200 Subject: tv ppp: add modem-send script --- tv/2configs/ppp.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix index 0c74e1642..8c1dc65bc 100644 --- a/tv/2configs/ppp.nix +++ b/tv/2configs/ppp.nix @@ -3,6 +3,7 @@ cfg = { pin = "@${toString }"; ttys.ppp = "/dev/ttyACM0"; + ttys.com = "/dev/ttyACM1"; }; in { environment.etc."ppp/peers/o2".text = /* sh */ '' @@ -56,5 +57,16 @@ in { exit 1 esac '') + (pkgs.writeDashBin "modem-send" '' + # usage: modem-send ATCOMMAND + set -efu + tty=${lib.shell.escape cfg.ttys.com} + exec <"$tty" + printf '%s\r\n' "$1" >"$tty" + ${pkgs.gnused}/bin/sed -E ' + /^OK\r?$/q + /^ERROR\r?$/q + ' + '') ]; } -- cgit v1.2.3 From 885e7857c0f3ac7dc7d73ceb6db6de9924f9b570 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Oct 2020 12:24:25 +0200 Subject: tv ppp: reconfigure resolv.conf --- tv/2configs/ppp.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix index 8c1dc65bc..ff61f943f 100644 --- a/tv/2configs/ppp.nix +++ b/tv/2configs/ppp.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: let +{ config, pkgs, ... }: let lib = import ; cfg = { pin = "@${toString }"; @@ -6,6 +6,18 @@ ttys.com = "/dev/ttyACM1"; }; in { + assertions = [ + { + assertion = config.networking.resolvconf.enable; + message = "ppp configuration needs resolvconf"; + } + ]; + environment.etc."ppp/ip-up".source = pkgs.writeDash "ppp.ip-up" '' + ${pkgs.openresolv}/bin/resolvconf -a "$IFNAME" < /etc/ppp/resolv.conf + ''; + environment.etc."ppp/ip-down".source = pkgs.writeDash "ppp.ip-down" '' + ${pkgs.openresolv}/bin/resolvconf -fd "$IFNAME" + ''; environment.etc."ppp/peers/o2".text = /* sh */ '' ${cfg.ttys.ppp} 921600 -- cgit v1.2.3 From b034f63f7a2e4361b32c33c0e1a980eecf1a5aa6 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2020 01:00:54 +0200 Subject: tv iptables: move sshd stuff to sshd config --- tv/2configs/sshd.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/sshd.nix b/tv/2configs/sshd.nix index 25468f23e..79af5b01f 100644 --- a/tv/2configs/sshd.nix +++ b/tv/2configs/sshd.nix @@ -1,10 +1,22 @@ -{ config, lib, pkgs, ... }: - with import ; - -{ +{ config, ... }: let + cfg.host = config.krebs.build.host; +in { services.openssh = { enable = true; }; tv.iptables.input-internet-accept-tcp = singleton "ssh"; + tv.iptables.extra.nat.OUTPUT = [ + "-o lo -p tcp --dport 11423 -j REDIRECT --to-ports 22" + ]; + tv.iptables.extra4.nat.PREROUTING = [ + "-d ${cfg.host.nets.retiolum.ip4.addr} -p tcp --dport 22 -j ACCEPT" + ]; + tv.iptables.extra6.nat.PREROUTING = [ + "-d ${cfg.host.nets.retiolum.ip6.addr} -p tcp --dport 22 -j ACCEPT" + ]; + tv.iptables.extra.nat.PREROUTING = [ + "-p tcp --dport 22 -j REDIRECT --to-ports 0" + "-p tcp --dport 11423 -j REDIRECT --to-ports 22" + ]; } -- cgit v1.2.3