From 14d51411fac831d06530a2192b35e3fbd87de30e 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 4e9e307..256604a 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 54f7597cec61bb77940f37e0ca18a6bd3d4bc387 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 256604a..032df5d 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 56f4315de2600475e9a70e8d49d9786c3a5e6044 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 9db3518..9132773 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 5c8163e30bd9332577275425fa9809d1d8a3e276 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 9132773..2d813fe 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 41afed6fd74178a5a1fc3c4b5277cbf1f0b5efbd 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 9cc7568..0222734 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 5742f67bc3fefc669ba610bd39b55f97320bb517 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 0222734..ecb17c3 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 f65e94d07f5f8bdc99ecf4c5e187f20438c05919 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 ecb17c3..0c74e16 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 88869167655b17ccb0bbebfd854be41ff808f3df 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 0c74e16..8c1dc65 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 3411277b7c440c9f86b51283e6bab55c92161620 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 8c1dc65..ff61f94 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 c5222bc188414a753fe8e8260c6dac26f05ac2e9 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 25468f2..79af5b0 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