From b091ebbab79d6780839ced56e3eef28241e6ea4c Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Oct 2017 22:30:23 +0200 Subject: tv umts: import from lass --- tv/3modules/default.nix | 1 + tv/3modules/umts.nix | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tv/3modules/umts.nix (limited to 'tv') diff --git a/tv/3modules/default.nix b/tv/3modules/default.nix index 493cc8b72..0fcf8cc9d 100644 --- a/tv/3modules/default.nix +++ b/tv/3modules/default.nix @@ -5,6 +5,7 @@ ./hosts.nix ./iptables.nix ./nixpkgs-overlays.nix + ./umts.nix ./x0vncserver.nix ]; } diff --git a/tv/3modules/umts.nix b/tv/3modules/umts.nix new file mode 100644 index 000000000..ebf4f780f --- /dev/null +++ b/tv/3modules/umts.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, ... }: + +with import ; + +let + cfg = config.tv.umts; + + out = { + options.tv.umts = api; + config = lib.mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "umts"; + modem = mkOption { + type = types.str; + default = "/dev/ttyUSB0"; + }; + initstrings = mkOption { + type = types.str; + default = '' + Init1 = ATZ + Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 + ''; + }; + username = mkOption { + type = types.str; + default = "default"; + }; + password = mkOption { + type = types.str; + default = "default"; + }; + pppDefaults = mkOption { + type = types.str; + default = '' + noipdefault + usepeerdns + defaultroute + persist + noauth + ''; + }; + }; + + nixpkgs-1509 = import (pkgs.fetchFromGitHub { + owner = "NixOS"; repo = "nixpkgs-channels"; + rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; + sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; + }) {}; + + wvdial = nixpkgs-1509.wvdial; # https://github.com/NixOS/nixpkgs/issues/16113 + + umts-bin = pkgs.writeScriptBin "umts" '' + #!/bin/sh + set -euf + systemctl start umts + trap "systemctl stop umts;trap - INT TERM EXIT;exit" INT TERM EXIT + echo nameserver 8.8.8.8 | tee -a /etc/resolv.conf + journalctl -xfu umts + ''; + + wvdial-defaults = '' + [Dialer Defaults] + Modem = ${cfg.modem} + ${cfg.initstrings} + Modem Type = Analog Modem + Baud = 460800 + phone= *99# + Username = ${cfg.username} + Password = ${cfg.password} + Stupid Mode = 1 + Idle Seconds = 0 + PPPD Path = ${pkgs.ppp}/bin/pppd + ''; + + imp = { + environment.shellAliases = { + umts = "sudo ${umts-bin}/bin/umts"; + }; + + environment.systemPackages = [ + pkgs.ppp + ]; + + security.sudo.extraConfig = '' + tv ALL= (root) NOPASSWD: ${umts-bin}/bin/umts + ''; + + environment.etc = [ + { + source = pkgs.writeText "wvdial.conf" wvdial-defaults; + target = "wvdial.conf"; + } + { + source = pkgs.writeText "wvdial" cfg.pppDefaults; + target = "ppp/peers/wvdial"; + } + ]; + + systemd.services.umts = { + description = "UMTS wvdial Service"; + serviceConfig = { + Type = "simple"; + Restart = "always"; + RestartSec = "10s"; + ExecStart = "${wvdial}/bin/wvdial -n"; + }; + }; + }; + +in out -- cgit v1.2.3 From 8c23c4d17ff89dbba18ce5ab2b6c8124a87c2c11 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Oct 2017 22:48:57 +0200 Subject: tv umts: cleanup --- tv/3modules/umts.nix | 105 ++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 59 deletions(-) (limited to 'tv') diff --git a/tv/3modules/umts.nix b/tv/3modules/umts.nix index ebf4f780f..a60627025 100644 --- a/tv/3modules/umts.nix +++ b/tv/3modules/umts.nix @@ -1,17 +1,32 @@ -{ config, lib, pkgs, ... }: - with import ; +{ config, lib, pkgs, ... }: let -let cfg = config.tv.umts; - out = { - options.tv.umts = api; - config = lib.mkIf cfg.enable imp; - }; + umts-dial = pkgs.writeDash "umts-dial" '' + set -euf + ${pkgs.systemd}/bin/systemctl start umts + trap 'cleanup; trap - EXIT INT TERM' EXIT INT TERM + cleanup() { + ${pkgs.systemd}/bin/systemctl stop umts + } + echo nameserver 8.8.8.8 >> /etc/resolv.conf + ${pkgs.systemd}/bin/journalctl -xfu umts + ''; - api = { - enable = mkEnableOption "umts"; + # https://github.com/NixOS/nixpkgs/issues/16113 + wvdial = let + nixpkgs-1509 = import (pkgs.fetchFromGitHub { + owner = "NixOS"; repo = "nixpkgs-channels"; + rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; + sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; + }) {}; + in + nixpkgs-1509.wvdial; + +in { + options.tv.umts = { + enable = mkEnableOption "tv.umts"; modem = mkOption { type = types.str; default = "/dev/ttyUSB0"; @@ -43,61 +58,34 @@ let }; }; - nixpkgs-1509 = import (pkgs.fetchFromGitHub { - owner = "NixOS"; repo = "nixpkgs-channels"; - rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; - sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; - }) {}; - - wvdial = nixpkgs-1509.wvdial; # https://github.com/NixOS/nixpkgs/issues/16113 - - umts-bin = pkgs.writeScriptBin "umts" '' - #!/bin/sh - set -euf - systemctl start umts - trap "systemctl stop umts;trap - INT TERM EXIT;exit" INT TERM EXIT - echo nameserver 8.8.8.8 | tee -a /etc/resolv.conf - journalctl -xfu umts - ''; - - wvdial-defaults = '' - [Dialer Defaults] - Modem = ${cfg.modem} - ${cfg.initstrings} - Modem Type = Analog Modem - Baud = 460800 - phone= *99# - Username = ${cfg.username} - Password = ${cfg.password} - Stupid Mode = 1 - Idle Seconds = 0 - PPPD Path = ${pkgs.ppp}/bin/pppd - ''; - - imp = { - environment.shellAliases = { - umts = "sudo ${umts-bin}/bin/umts"; + config = lib.mkIf cfg.enable { + environment.etc = { + "ppp/peers/wvdial".text = cfg.pppDefaults; + "wvdial.conf".text = '' + [Dialer Defaults] + Modem = ${cfg.modem} + ${cfg.initstrings} + Modem Type = Analog Modem + Baud = 460800 + phone= *99# + Username = ${cfg.username} + Password = ${cfg.password} + Stupid Mode = 1 + Idle Seconds = 0 + PPPD Path = ${pkgs.ppp}/bin/pppd + ''; }; - environment.systemPackages = [ - pkgs.ppp + krebs.per-user.tv.packages = [ + (pkgs.writeDashBin "umts" '' + exec sudo ${umts-dial} + '') ]; security.sudo.extraConfig = '' - tv ALL= (root) NOPASSWD: ${umts-bin}/bin/umts + tv ALL= (root) NOPASSWD: ${umts-dial} ''; - environment.etc = [ - { - source = pkgs.writeText "wvdial.conf" wvdial-defaults; - target = "wvdial.conf"; - } - { - source = pkgs.writeText "wvdial" cfg.pppDefaults; - target = "ppp/peers/wvdial"; - } - ]; - systemd.services.umts = { description = "UMTS wvdial Service"; serviceConfig = { @@ -108,5 +96,4 @@ let }; }; }; - -in out +} -- cgit v1.2.3 From 48e34b59ad446256f429528e4e8946299ed3c1a0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Oct 2017 22:49:19 +0200 Subject: tv xu: enable umts --- tv/1systems/xu/config.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tv') diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 0363c983d..08bdfa52b 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -161,5 +161,14 @@ with import ; tv = "/home/tv/stockholm/tv/5pkgs"; }; + tv.umts = { + enable = true; + modem = "/dev/serial/by-id/usb-Lenovo_F5521gw_097EAD658B094860-if09"; + initstrings = '' + Init1 = AT+CFUN=1 + Init2 = AT+CGDCONT=1,"IP","pinternet.interkom.de","",0,0 + ''; + }; + virtualisation.virtualbox.host.enable = true; } -- cgit v1.2.3 From 1993cbc42114c759a47fed8de1e73980d3df57d9 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 08:09:05 +0200 Subject: brscan4: init at 0.4.4-4 --- tv/5pkgs/default.nix | 8 -------- 1 file changed, 8 deletions(-) (limited to 'tv') diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index 9dc7ae7b1..261871e62 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -13,14 +13,6 @@ foldl' mergeAttrs {} // { - brscan4 = overrideDerivation super.brscan4 (original: rec { - name = "brscan4-0.4.4-4"; - src = super.fetchurl { - url = "http://download.brother.com/welcome/dlf006645/${name}.amd64.deb"; - sha256 = "0xy5px96y1saq9l80vwvfn6anr2q42qlxdhm6ci2a0diwib5q9fd"; - }; - }); - # TODO use XDG_RUNTIME_DIR? cr = self.writeDashBin "cr" '' set -efu -- cgit v1.2.3 From 7e269eaba530afd455f1438b18f68b1304244500 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 20:41:07 +0200 Subject: tv umts: RIP --- tv/1systems/xu/config.nix | 9 ----- tv/3modules/umts.nix | 99 ----------------------------------------------- 2 files changed, 108 deletions(-) delete mode 100644 tv/3modules/umts.nix (limited to 'tv') diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 08bdfa52b..0363c983d 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -161,14 +161,5 @@ with import ; tv = "/home/tv/stockholm/tv/5pkgs"; }; - tv.umts = { - enable = true; - modem = "/dev/serial/by-id/usb-Lenovo_F5521gw_097EAD658B094860-if09"; - initstrings = '' - Init1 = AT+CFUN=1 - Init2 = AT+CGDCONT=1,"IP","pinternet.interkom.de","",0,0 - ''; - }; - virtualisation.virtualbox.host.enable = true; } diff --git a/tv/3modules/umts.nix b/tv/3modules/umts.nix deleted file mode 100644 index a60627025..000000000 --- a/tv/3modules/umts.nix +++ /dev/null @@ -1,99 +0,0 @@ -with import ; -{ config, lib, pkgs, ... }: let - - cfg = config.tv.umts; - - umts-dial = pkgs.writeDash "umts-dial" '' - set -euf - ${pkgs.systemd}/bin/systemctl start umts - trap 'cleanup; trap - EXIT INT TERM' EXIT INT TERM - cleanup() { - ${pkgs.systemd}/bin/systemctl stop umts - } - echo nameserver 8.8.8.8 >> /etc/resolv.conf - ${pkgs.systemd}/bin/journalctl -xfu umts - ''; - - # https://github.com/NixOS/nixpkgs/issues/16113 - wvdial = let - nixpkgs-1509 = import (pkgs.fetchFromGitHub { - owner = "NixOS"; repo = "nixpkgs-channels"; - rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; - sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; - }) {}; - in - nixpkgs-1509.wvdial; - -in { - options.tv.umts = { - enable = mkEnableOption "tv.umts"; - modem = mkOption { - type = types.str; - default = "/dev/ttyUSB0"; - }; - initstrings = mkOption { - type = types.str; - default = '' - Init1 = ATZ - Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 - ''; - }; - username = mkOption { - type = types.str; - default = "default"; - }; - password = mkOption { - type = types.str; - default = "default"; - }; - pppDefaults = mkOption { - type = types.str; - default = '' - noipdefault - usepeerdns - defaultroute - persist - noauth - ''; - }; - }; - - config = lib.mkIf cfg.enable { - environment.etc = { - "ppp/peers/wvdial".text = cfg.pppDefaults; - "wvdial.conf".text = '' - [Dialer Defaults] - Modem = ${cfg.modem} - ${cfg.initstrings} - Modem Type = Analog Modem - Baud = 460800 - phone= *99# - Username = ${cfg.username} - Password = ${cfg.password} - Stupid Mode = 1 - Idle Seconds = 0 - PPPD Path = ${pkgs.ppp}/bin/pppd - ''; - }; - - krebs.per-user.tv.packages = [ - (pkgs.writeDashBin "umts" '' - exec sudo ${umts-dial} - '') - ]; - - security.sudo.extraConfig = '' - tv ALL= (root) NOPASSWD: ${umts-dial} - ''; - - systemd.services.umts = { - description = "UMTS wvdial Service"; - serviceConfig = { - Type = "simple"; - Restart = "always"; - RestartSec = "10s"; - ExecStart = "${wvdial}/bin/wvdial -n"; - }; - }; - }; -} -- cgit v1.2.3 From d5c6e52dd5793a7cb0fad3835a5d1ab014c5bcc1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 20:41:47 +0200 Subject: tv netzclub: init --- tv/1systems/xu/config.nix | 1 + tv/2configs/netzclub.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tv/2configs/netzclub.nix (limited to 'tv') diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 0363c983d..3e008a1bb 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -11,6 +11,7 @@ with import ; + diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix new file mode 100644 index 000000000..659e0d4e4 --- /dev/null +++ b/tv/2configs/netzclub.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: { + + # usage: ppp dial netzclub + + environment.etc."ppp/peers/netzclub".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 "netzclub.script" '' + ABORT 'BUSY' + ABORT 'NO CARRIER' + ABORT 'VOICE' + ABORT 'NO DIALTONE' + ABORT 'NO DIAL TONE' + ABORT 'NO ANSWER' + ABORT 'DELAYED' + REPORT CONNECT + TIMEOUT 6 + ''' 'ATQ0' + 'OK-AT-OK' 'ATZ' + TIMEOUT 3 + 'OK\d-AT-OK' 'ATI' + 'OK' 'ATZ' + 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' + 'OK' 'ATDT*99***1#' + TIMEOUT 30 + CONNECT ''' + ''} + ''; + + environment.systemPackages = [ + ppp + ]; + +} -- cgit v1.2.3 From a00d516b5897bae3583aeae16103d7b6657f7cc4 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 20:45:30 +0200 Subject: tv xu: lol wvdial --- tv/1systems/xu/config.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'tv') diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 3e008a1bb..6c99f6bd2 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -100,7 +100,6 @@ with import ; #tlsdate #unetbootin #utillinuxCurses - #wvdial #xdotool #xkill #xl2tpd -- cgit v1.2.3 From 01409f4dbfb353855f95c38210d2cb5b3fc90ba8 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 20:58:32 +0200 Subject: tv modules: rm umts --- tv/3modules/default.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'tv') diff --git a/tv/3modules/default.nix b/tv/3modules/default.nix index 0fcf8cc9d..493cc8b72 100644 --- a/tv/3modules/default.nix +++ b/tv/3modules/default.nix @@ -5,7 +5,6 @@ ./hosts.nix ./iptables.nix ./nixpkgs-overlays.nix - ./umts.nix ./x0vncserver.nix ]; } -- cgit v1.2.3 From 42f3a5661b4e53b76eb7315df1782b9942f47865 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 21:10:36 +0200 Subject: tv netzclub: { -> pkgs.}ppp --- tv/2configs/netzclub.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv') diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix index 659e0d4e4..dc2de7147 100644 --- a/tv/2configs/netzclub.nix +++ b/tv/2configs/netzclub.nix @@ -39,7 +39,7 @@ ''; environment.systemPackages = [ - ppp + pkgs.ppp ]; } -- cgit v1.2.3 From d19f415bb00368970f8e0a1548b89a472a24d634 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 21:29:35 +0200 Subject: tv netzclub: fix example --- tv/2configs/netzclub.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv') diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix index dc2de7147..6e06005e3 100644 --- a/tv/2configs/netzclub.nix +++ b/tv/2configs/netzclub.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { - # usage: ppp dial netzclub + # usage: pppd call netzclub environment.etc."ppp/peers/netzclub".text = '' /dev/ttyACM2 -- cgit v1.2.3 From f645e07f719e4529373674b8e47e18cb454f125f Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 26 Oct 2017 22:57:51 +0200 Subject: tv netzclub: add missing " --- tv/2configs/netzclub.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv') diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix index 6e06005e3..c49498ed4 100644 --- a/tv/2configs/netzclub.nix +++ b/tv/2configs/netzclub.nix @@ -35,7 +35,7 @@ 'OK' 'ATDT*99***1#' TIMEOUT 30 CONNECT ''' - ''} + ''}" ''; environment.systemPackages = [ -- cgit v1.2.3 From 6c8acbdf9ab464f09d2c08751528d31a81612351 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 27 Oct 2017 00:09:03 +0200 Subject: tv netzclub: simplify AT code --- tv/2configs/netzclub.nix | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'tv') diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix index c49498ed4..7286bc84d 100644 --- a/tv/2configs/netzclub.nix +++ b/tv/2configs/netzclub.nix @@ -25,16 +25,8 @@ ABORT 'NO ANSWER' ABORT 'DELAYED' REPORT CONNECT - TIMEOUT 6 - ''' 'ATQ0' - 'OK-AT-OK' 'ATZ' - TIMEOUT 3 - 'OK\d-AT-OK' 'ATI' - 'OK' 'ATZ' - 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' - 'OK' 'ATDT*99***1#' - TIMEOUT 30 - CONNECT ''' + "" "ATDT*99#" + CONNECT "" ''}" ''; -- cgit v1.2.3 From 36c01359dcffd3c7424366b9c43eb0b8baae666a Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 27 Oct 2017 01:35:04 +0200 Subject: tv: netzclub -> ppp --- tv/1systems/xu/config.nix | 2 +- tv/2configs/netzclub.nix | 37 ------------------------------------- tv/2configs/ppp.nix | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 38 deletions(-) delete mode 100644 tv/2configs/netzclub.nix create mode 100644 tv/2configs/ppp.nix (limited to 'tv') diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 6c99f6bd2..14926fe3b 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -11,9 +11,9 @@ with import ; - + diff --git a/tv/2configs/netzclub.nix b/tv/2configs/netzclub.nix deleted file mode 100644 index 7286bc84d..000000000 --- a/tv/2configs/netzclub.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ pkgs, ... }: { - - # usage: pppd call netzclub - - environment.etc."ppp/peers/netzclub".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 "netzclub.script" '' - ABORT 'BUSY' - ABORT 'NO CARRIER' - ABORT 'VOICE' - ABORT 'NO DIALTONE' - ABORT 'NO DIAL TONE' - ABORT 'NO ANSWER' - ABORT 'DELAYED' - REPORT CONNECT - "" "ATDT*99#" - CONNECT "" - ''}" - ''; - - environment.systemPackages = [ - pkgs.ppp - ]; - -} diff --git a/tv/2configs/ppp.nix b/tv/2configs/ppp.nix new file mode 100644 index 000000000..9cc7568a5 --- /dev/null +++ b/tv/2configs/ppp.nix @@ -0,0 +1,32 @@ +{ 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