From 29041d86c629ec87592a535bbcec3c1f6199f042 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 31 Jan 2023 15:13:17 +0100 Subject: kartei/palo: update retiolum keys --- kartei/palo/default.nix | 21 ++++++++++++++++++--- kartei/palo/retiolum.pub | 13 ------------- 2 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 kartei/palo/retiolum.pub diff --git a/kartei/palo/default.nix b/kartei/palo/default.nix index 9d35c380..6fc9a594 100644 --- a/kartei/palo/default.nix +++ b/kartei/palo/default.nix @@ -17,13 +17,28 @@ let in { hosts = mapAttrs hostDefaults { - sterni = { + sol = { owner = config.krebs.users.palo; nets = { retiolum = { tinc.port = 720; - aliases = [ "sterni.r" ]; - tinc.pubkey = builtins.readFile ./retiolum.pub; + aliases = [ "sol.r" ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIICCgKCAgEAxrvdMSAcOJXM1TbIIDZ+zPojrcRG3RVMfPC2/0DasRpBFSuS+L60 + mQEs0l0ptAL6Sbr4+9gfaHkdETfYpeKB4Q4lCPahMq88YfTyB1f3tEOqW3vP22nC + Z+Yf+W/sTLWVRoDoS/Eok6wS95R1IQ74vr37YXdbJTD/eeX6sAJkn2I2RV5PD6Bu + lHsMuunAj+PyhAgqb2P393h7FN4exL0xM6UbHbgsd9OSp5qKTjZE3jeOyWmounK1 + 7n+8pyRjI0VE47ontnj/GANwpsxRFFtRGmG/S5KhUBXMv7wZr/vaVETRphAu+KhT + NqdclmGkQlB/YBodzJID7C21Zz4b33kcn12TU3nc6AL5u9j3sU2sEu/22fAZBWLV + yOZ9l/Qe4aJkIbdL70Gvp9G8m7+M4vkdM+e/nA5cZT0N9ArI2D5ltJRd7VLVzxef + Y0t/bS9bVOcNt2Sgd81Ubg0OmF2paHGGboAAMqXhf3afwCMyXcDsP6sgPXOIEu7Q + hjuo5rg6Fu8eK9edAAQ2afl52GiFUawzjHbjGANwVyea1JTQ3uR6eBtxGOEaYpkr + vbl75CxLwE0YA0L3VwhJTNLMVldTrUi2M76QedjzyePkJHMijHT5+0nqTlsmjcNg + uv89Mh9shNKdqulfGjTAFyKjTCuUe/rCprJ5CeZWBaEuQKYkcZuMkJsCAwEAAQ== + -----END RSA PUBLIC KEY----- + ''; + tinc.pubkey_ed25519 = "qCJvjlNz5YNOz5IEiwGaoK3InSVCL76uNl+xVBUa/AP"; }; }; }; diff --git a/kartei/palo/retiolum.pub b/kartei/palo/retiolum.pub deleted file mode 100644 index 65284d51..00000000 --- a/kartei/palo/retiolum.pub +++ /dev/null @@ -1,13 +0,0 @@ ------BEGIN RSA PUBLIC KEY----- -MIICCgKCAgEA2ACttoosnRZ99o+OyMrxBdUWPqsT5btzSIQ5dU1XWqGjO4nRchCE -8tO0b/4jqVgJVTRZVIUJQESZRlSmclsCAjdM8tsGj74CJrm7tBvgbBn2IObSs5+4 -oJWe57VsQaeHPuI2JZuGqv8Z3Esw+B07bQS5VTaC1ISo7vnLG/q5XLCbKHB9JZc/ -ztYbk4bEQHwbulfoPjD9FY3heLnTzqPw9Xr3ixao5gbAXfWNJM+iCluMq+Q2g1BD -ozSnyYvaGLQ6h4yksDp+xuK8YCqiRj174EkXySI8Jee1CBMuI8ciX/5Q7yzvzscQ -ZQ/MLVdx3MRW+VeT0ctaRzoA9E09ILqPe+56DjpsKzt4Ne8qeMG5HdpzO9UdNzTu -MuibsCL7CJy5Ytl38PK+LAXHQr3Os1Z4OHjeTZ38vTAZcOUJZEkl6w9nO1XjcyBL -rIaG+20Nx0ZU79MlJZFiG7ovlUiDfIEKNygng8v/yoTMaqMYLxQZ/leQwLMNLujo -sku8+oV4Jvx4SyUjuAS6jgG9CnejLCnHP/yyDGdaMQSzmlzYXacLMfnPZE3r7bj1 -EjA6yQbkPixm7xLCyMm5u2leWtqtbg1oRA6Mw3UyYkNy3hiTU+jTvztEI3SCliDH -yjGlESH4/edryKjLNjmYP77VFbM9ZSQ+QGlbMGPvjcn6XCdJGdxm3PUCAwEAAQ== ------END RSA PUBLIC KEY----- -- cgit v1.2.3 From 05ae73b740eb6c54bf78132c0ddbd4c8b4ed69e8 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 31 Jan 2023 21:30:20 +0100 Subject: nix-writers: 3.6.2 -> 3.6.3 --- submodules/nix-writers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/nix-writers b/submodules/nix-writers index 0c8de150..d1424777 160000 --- a/submodules/nix-writers +++ b/submodules/nix-writers @@ -1 +1 @@ -Subproject commit 0c8de150426476b5287cf2787bbd85263691a802 +Subproject commit d1424777b5f2e12cbd80efd1b55335dcba7c32bd -- cgit v1.2.3 From 8f28d0cb51f74f0401705c608f29d6aa3e15c425 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 31 Jan 2023 21:32:29 +0100 Subject: nixos-format-error: init --- krebs/5pkgs/simple/nixos-format-error.nix | 105 ++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 krebs/5pkgs/simple/nixos-format-error.nix diff --git a/krebs/5pkgs/simple/nixos-format-error.nix b/krebs/5pkgs/simple/nixos-format-error.nix new file mode 100644 index 00000000..14066efb --- /dev/null +++ b/krebs/5pkgs/simple/nixos-format-error.nix @@ -0,0 +1,105 @@ +{ pkgs }: + +pkgs.writeGawk "nixos-format-error" '' + # usage: nixos-rebuild ... 2>&1 | nixos-format-error + + function out() { + print + next + } + + BEGIN { + IDLE = 0 + ACTIVE = 1 + PASSIVE = 2 + ERROR = 3 + + start_state = IDLE + + state = start_state + } + + END { + if (trace_count) + for (i = trace_count - 1; i >= 0; i--) + print trace[i] + } + + state == PASSIVE { + out() + } + + state == IDLE { + if ($0 == "building the system configuration...") { + state = ACTIVE + } + out() + } + + state == ACTIVE { + if ($1 == "error:") { + state = ERROR + sub(/^/,"\x1b[31;1m"); sub(/$/,"\x1b[m") + trace[trace_count++] = $0 + + "stty -F /dev/tty size" |& getline + COLUMNS = gensub(/.* ([0-9]+)$/, "\\1", "1") + + next + } + if ($0 ~ /^these [0-9]+ derivations will be built:/) { + state = PASSIVE + } + if ($0 == "activating the configuration...") { + state = PASSIVE + } + out() + } + + state == ERROR { + + if ($0 ~ /^\s*at /) { + location = gensub(/^\s*at (.*):$/,"\\1","1") + content = "" + lnumcol = gensub(/^.*:([0-9]+:[0-9]+)$/,"\\1","1",location) + lnum = gensub(/:.*/,"","1",lnumcol) + col = gensub(/.*:/,"","1",lnumcol) + next + } + + if ($1 == lnum "|") { + content = gensub(/^\s*[0-9]+\|(.*)/,"\\1","1") + + location = sprintf("%50s", location) + + preview_size = COLUMNS - length(location " ") + + prefix = gensub(/^\s*/,"","1",substr(content, 1, col)) + infix = gensub(/^([0-9a-zA-Z]+|.).*$/, "\\1", "1", substr(content, col + 1)) + suffix = substr(content, col + length(infix) + 1) + + if (length(prefix infix suffix) > preview_size) { + n = (preview_size - length(infix)) / 2 - length(" ") + prefix = substr(prefix, length(prefix) - n + 1) + if (prefix != "") { prefix = "…" prefix } + suffix = substr(suffix, 1, n) + if (suffix != "") { suffix = suffix "…" } + } + + preview = \ + "\x1b[38;5;244m" prefix "\x1b[m" \ + "\x1b[38;5;230m" infix "\x1b[m" \ + "\x1b[38;5;244m" suffix "\x1b[m" + + trace[trace_count++] = location " " preview + next + } + + if ($0 == "") next + if ($0 ~ /^\s*… (from|while)/) next + if ($0 ~ /^\s*([0-9]*)\|/) next + + trace[trace_count++] = $0 + next + } +'' -- cgit v1.2.3 From 7f45ab5b685cf2769bb07077568d5bdabab22824 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 14:46:47 +0100 Subject: nixos-format-error: use writeGawkBin --- krebs/5pkgs/simple/nixos-format-error.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/nixos-format-error.nix b/krebs/5pkgs/simple/nixos-format-error.nix index 14066efb..9ba410bb 100644 --- a/krebs/5pkgs/simple/nixos-format-error.nix +++ b/krebs/5pkgs/simple/nixos-format-error.nix @@ -1,6 +1,6 @@ { pkgs }: -pkgs.writeGawk "nixos-format-error" '' +pkgs.writeGawkBin "nixos-format-error" '' # usage: nixos-rebuild ... 2>&1 | nixos-format-error function out() { -- cgit v1.2.3 From 9316f445b62fbe9f92f8bf41c8c3780cd323839b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 14:47:10 +0100 Subject: nixos-format-error: grok SGR and \r --- krebs/5pkgs/simple/nixos-format-error.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/nixos-format-error.nix b/krebs/5pkgs/simple/nixos-format-error.nix index 9ba410bb..a28f7245 100644 --- a/krebs/5pkgs/simple/nixos-format-error.nix +++ b/krebs/5pkgs/simple/nixos-format-error.nix @@ -30,14 +30,14 @@ pkgs.writeGawkBin "nixos-format-error" '' } state == IDLE { - if ($0 == "building the system configuration...") { + if ($0 ~ /^building the system configuration\.\.\. ?$/) { state = ACTIVE } out() } state == ACTIVE { - if ($1 == "error:") { + if ($1 ~ /(\[[0-9;]+m)?error:(\[[0-9;]m)?/) { state = ERROR sub(/^/,"\x1b[31;1m"); sub(/$/,"\x1b[m") trace[trace_count++] = $0 @@ -57,6 +57,8 @@ pkgs.writeGawkBin "nixos-format-error" '' } state == ERROR { + sub(/ $/, "") + gsub(/\[[0-9;]*m/, "") if ($0 ~ /^\s*at /) { location = gensub(/^\s*at (.*):$/,"\\1","1") -- cgit v1.2.3 From 38062bf06659e3ad9b2427c2049aa3ccce47c24c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 15:21:52 +0100 Subject: urlwatch: admit dict-based filter lists --- krebs/3modules/urlwatch.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 2e336de2..e08289bb 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -71,7 +71,7 @@ let description = "URL to watch."; example = [ https://nixos.org/channels/nixos-unstable/git-revision - { url = http://localhost ; filter = "grep:important.*stuff"; } + { url = http://localhost ; filter = [ (grep "important.*stuff") ]; } ]; apply = map (x: getAttr (typeOf x) { set = x; @@ -211,7 +211,9 @@ let }; filter = mkOption { default = null; - type = with types; nullOr str; # TODO nullOr subtypes.filter + type = + with types; + nullOr (either str (listOf (pkgs.formats.json {}).type)); }; ignore_cached = mkOption { default = null; -- cgit v1.2.3 From beab66db651b3f5d0c6f033221a8acda4531c4d1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 15:24:04 +0100 Subject: tv urlwatch exec: use dict-based filter list Because string-based filter definitions are deprecated since 2.19 Refs https://urlwatch.readthedocs.io/en/latest/deprecated.html --- tv/2configs/urlwatch.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 7ba364ff..e2cd1990 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -2,9 +2,10 @@ with import ./lib; { config, pkgs, ... }: let exec = filename: args: url: { inherit url; - filter = "system:${ - concatMapStringsSep " " shell.escape ([filename] ++ toList args) - }"; + filter = singleton { + system = + concatMapStringsSep " " shell.escape ([filename] ++ toList args); + }; }; json = json' ["."]; json' = exec "${pkgs.jq}/bin/jq"; @@ -73,17 +74,23 @@ in { import subprocess import urlwatch - class CaseFilter(urlwatch.filters.FilterBase): + class SystemFilter(urlwatch.filters.FilterBase): """Filter for piping data through an external process""" __kind__ = 'system' + __supported_subfilters__ = { + 'command': 'shell command line to tranform data', + } + + __default_subfilter__ = 'command' + def filter(self, data, subfilter=None): - if subfilter is None: - raise ValueError('The system filter needs a command') + if 'command' not in subfilter: + raise ValueError('{} filter needs a command'.format(self.__kind__)) proc = subprocess.Popen( - subfilter, + subfilter['command'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, -- cgit v1.2.3 From 7a2b6a72fa75706dce069f9ec68c39f883dcba18 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 14:28:13 +0100 Subject: tv urlwatch: add samsung consumer-storage tools --- tv/2configs/urlwatch.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index e2cd1990..f5260ee0 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -9,6 +9,9 @@ with import ./lib; }; json = json' ["."]; json' = exec "${pkgs.jq}/bin/jq"; + urigrep' = exec (pkgs.writeDash "urigrep" '' + ${pkgs.urix}/bin/urix | ${pkgs.gnugrep}/bin/grep -E "$1" + ''); xml = xml' ["--format" "-"]; xml' = exec "${pkgs.libxml2}/bin/xmllint"; in { @@ -69,6 +72,8 @@ in { https://raw.githubusercontent.com/NixOS/nixpkgs/master/nixos/modules/services/x11/xserver.nix https://www.rabbitmq.com/changelog.html + + (urigrep' ["software-resources"] https://semiconductor.samsung.com/consumer-storage/support/tools/) ]; hooksFile = toFile "hooks.py" '' import subprocess -- cgit v1.2.3 From c2b601d123714f29474a0434555bf90c2ebedbbd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 16:02:01 +0100 Subject: urlwatch subject: put each url on its own line --- krebs/3modules/urlwatch.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index e08289bb..8ebbdd1f 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -177,8 +177,8 @@ let echo Date: $(date -R) echo From: ${shell.escape cfg.from} echo Subject: $( - sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \ - | tr '\n' ' ' + sed -nr 's/^(CHANGED|ERROR|NEW): //p' changes | + sed '1!s/^ //' ) echo To: ${shell.escape cfg.mailto} echo -- cgit v1.2.3 From 38d0a0a5be8e472c60c3745df9f34aadc51514dd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 16:02:31 +0100 Subject: urlwatch content-transfer-encoding: base64 --- krebs/3modules/urlwatch.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix index 8ebbdd1f..113f6e65 100644 --- a/krebs/3modules/urlwatch.nix +++ b/krebs/3modules/urlwatch.nix @@ -181,8 +181,11 @@ let sed '1!s/^ //' ) echo To: ${shell.escape cfg.mailto} + echo Mime-Version: 1.0 + echo Content-Type: text/plain\; charset=UTF-8 + echo Content-Transfer-Encoding: base64 echo - cat changes + base64 changes } | /run/wrappers/bin/sendmail -t fi ''} -- cgit v1.2.3 From eb39234ba8375d7274d70af678175ffe88109cb3 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 16:29:23 +0100 Subject: tv wiregrill: init --- tv/2configs/wiregrill.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tv/2configs/wiregrill.nix diff --git a/tv/2configs/wiregrill.nix b/tv/2configs/wiregrill.nix new file mode 100644 index 00000000..d28a1ec2 --- /dev/null +++ b/tv/2configs/wiregrill.nix @@ -0,0 +1,37 @@ +with import ./lib; +{ config, pkgs, ... }: let + cfg = { + enable = cfg.net != null; + net = config.krebs.build.host.nets.wiregrill or null; + }; + toCidrNotation = ip: "${ip.addr}/${toString ip.prefixLength}"; +in + mkIf cfg.enable { + networking.wireguard.interfaces.wiregrill = { + ips = + optional (cfg.net.ip4 != null) cfg.net.ip4.addr ++ + optional (cfg.net.ip6 != null) cfg.net.ip6.addr; + listenPort = 51820; + privateKeyFile = (toString ) + "/wiregrill.key"; + allowedIPsAsRoutes = true; + peers = mapAttrsToList + (_: host: { + allowedIPs = host.nets.wiregrill.wireguard.subnets; + endpoint = + mkIf (host.nets.wiregrill.via != null) (host.nets.wiregrill.via.ip4.addr + ":${toString host.nets.wiregrill.wireguard.port}"); + persistentKeepalive = mkIf (host.nets.wiregrill.via != null) 61; + publicKey = + replaceStrings ["\n"] [""] host.nets.wiregrill.wireguard.pubkey; + }) + (filterAttrs (_: h: hasAttr "wiregrill" h.nets) config.krebs.hosts); + }; + systemd.network.networks.wiregrill = { + matchConfig.Name = "wiregrill"; + address = + optional (!isNull cfg.net.ip4) (toCidrNotation cfg.net.ip4) ++ + optional (!isNull cfg.net.ip6) (toCidrNotation cfg.net.ip6); + }; + tv.iptables.extra.filter.INPUT = [ + "-p udp --dport ${toString cfg.net.wireguard.port} -j ACCEPT" + ]; + } -- cgit v1.2.3 From fc00990f712663688e5aea85624cb9317e9f4128 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 2 Feb 2023 16:50:29 +0100 Subject: tv: add default networking.hostId --- tv/1systems/bu/config.nix | 2 -- tv/2configs/default.nix | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tv/1systems/bu/config.nix b/tv/1systems/bu/config.nix index c7f7da24..a3959cd8 100644 --- a/tv/1systems/bu/config.nix +++ b/tv/1systems/bu/config.nix @@ -13,8 +13,6 @@ with import ./lib; krebs.build.host = config.krebs.hosts.bu; - networking.hostId = lib.mkDefault "00000000"; - networking.wireless.enable = true; networking.useDHCP = false; networking.interfaces.enp0s25.useDHCP = true; diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index d1384845..53b11c62 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -6,6 +6,7 @@ with import ./lib; krebs.build.user = config.krebs.users.tv; + networking.hostId = mkDefault (hashToLength 8 config.networking.hostName); networking.hostName = config.krebs.build.host.name; imports = [ -- cgit v1.2.3 From 4a0e27488e80935719f3dc41a1c337f94068e450 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 2 Feb 2023 19:27:00 +0100 Subject: l mail: remove empty newlines --- lass/2configs/mail.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/lass/2configs/mail.nix b/lass/2configs/mail.nix index f5b2e22b..85259176 100644 --- a/lass/2configs/mail.nix +++ b/lass/2configs/mail.nix @@ -92,8 +92,6 @@ let tag-new-mails = pkgs.writeDashBin "nm-tag-init" '' ${pkgs.notmuch}/bin/notmuch new - ${lib.concatMapStringsSep "\n" (i: '' - '') (lib.mapAttrsToList lib.nameValuePair mailboxes)} ${lib.concatMapStringsSep "\n" (i: '' mkdir -p "$HOME/Maildir/.${i.name}/cur" for mail in $(${pkgs.notmuch}/bin/notmuch search --output=files 'tag:inbox and (${lib.concatMapStringsSep " or " (f: "${f}") i.value})'); do -- cgit v1.2.3 From b3ccfd3a789e59f16d2e1ef616cc23e89bab1598 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 2 Feb 2023 19:27:13 +0100 Subject: l mail: retry muchsync until success --- lass/2configs/mail.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lass/2configs/mail.nix b/lass/2configs/mail.nix index 85259176..0adef8f8 100644 --- a/lass/2configs/mail.nix +++ b/lass/2configs/mail.nix @@ -184,7 +184,9 @@ let "unset wait_key \ ${pkgs.writeDash "muchsync" '' set -efu - ${pkgs.muchsync}/bin/muchsync -F lass@green.r + until ${pkgs.muchsync}/bin/muchsync -F lass@green.r; do + sleep 1 + done ''} \ 'run muchsync to green.r' -- cgit v1.2.3 From 51561857821558f62003b7a792286a1a7a1a11bf Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 02:40:28 +0100 Subject: tv wiregrill: remove extra ! --- tv/2configs/wiregrill.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tv/2configs/wiregrill.nix b/tv/2configs/wiregrill.nix index d28a1ec2..edf65e97 100644 --- a/tv/2configs/wiregrill.nix +++ b/tv/2configs/wiregrill.nix @@ -28,8 +28,8 @@ in systemd.network.networks.wiregrill = { matchConfig.Name = "wiregrill"; address = - optional (!isNull cfg.net.ip4) (toCidrNotation cfg.net.ip4) ++ - optional (!isNull cfg.net.ip6) (toCidrNotation cfg.net.ip6); + optional (cfg.net.ip4 != null) (toCidrNotation cfg.net.ip4) ++ + optional (cfg.net.ip6 != null) (toCidrNotation cfg.net.ip6); }; tv.iptables.extra.filter.INPUT = [ "-p udp --dport ${toString cfg.net.wireguard.port} -j ACCEPT" -- cgit v1.2.3 From 3e4b31e65303581444d01156935c5cef48048079 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 03:05:17 +0100 Subject: tv xmonad: allow settings gaps --- tv/5pkgs/haskell/xmonad-tv/src/main.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index eb61bd5c..118f2da4 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -23,6 +23,7 @@ import System.Posix.Process (executeFile) import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace , removeEmptyWorkspace) import XMonad.Actions.CycleWS (toggleWS) +import XMonad.Layout.Gaps (Direction2D(U,R,D,L), gaps) import XMonad.Layout.NoBorders ( smartBorders ) import XMonad.Layout.ResizableTile (ResizableTall(ResizableTall)) import XMonad.Layout.ResizableTile (MirrorResize(MirrorExpand,MirrorShrink)) @@ -58,13 +59,19 @@ main = getArgs >>= \case readEnv :: Data.Aeson.FromJSON b => String -> IO b readEnv name = - Data.Maybe.fromJust + readEnv' (error $ "could not get environment variable: " <> name) name + +readEnv' :: Data.Aeson.FromJSON b => b -> String -> IO b +readEnv' defaultValue name = + Data.Maybe.fromMaybe defaultValue . Data.Aeson.decodeStrict' . Data.ByteString.Char8.pack - <$> getEnv name + . Data.Maybe.fromMaybe mempty + <$> lookupEnv name mainNoArgs :: IO () mainNoArgs = do + myScreenGaps <- readEnv' [] "XMONAD_SCREEN_GAPS" :: IO [Int] myScreenWidth <- readEnv "XMONAD_SCREEN_WIDTH" :: IO Dimension myTermFont <- getEnv "XMONAD_TERM_FONT" myTermFontWidth <- readEnv "XMONAD_TERM_FONT_WIDTH" :: IO Dimension @@ -89,6 +96,7 @@ mainNoArgs = do , workspaces = workspaces0 , layoutHook = refocusLastLayoutHook $ + gaps (zip [U,R,D,L] myScreenGaps) $ smartBorders $ ResizableTall 1 -- cgit v1.2.3 From af9e845e861b51d691102c1bc177dfe5e26fe63f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 13:15:23 +0100 Subject: flameshot-once: move to tv --- krebs/5pkgs/haskell/flameshot-once.nix | 20 --- krebs/5pkgs/simple/flameshot-once/default.nix | 28 --- krebs/5pkgs/simple/flameshot-once/profile.nix | 235 -------------------------- lass/2configs/baseX.nix | 4 +- tv/5pkgs/haskell/flameshot-once.nix | 20 +++ tv/5pkgs/simple/flameshot-once/default.nix | 28 +++ tv/5pkgs/simple/flameshot-once/profile.nix | 235 ++++++++++++++++++++++++++ 7 files changed, 285 insertions(+), 285 deletions(-) delete mode 100644 krebs/5pkgs/haskell/flameshot-once.nix delete mode 100644 krebs/5pkgs/simple/flameshot-once/default.nix delete mode 100644 krebs/5pkgs/simple/flameshot-once/profile.nix create mode 100644 tv/5pkgs/haskell/flameshot-once.nix create mode 100644 tv/5pkgs/simple/flameshot-once/default.nix create mode 100644 tv/5pkgs/simple/flameshot-once/profile.nix diff --git a/krebs/5pkgs/haskell/flameshot-once.nix b/krebs/5pkgs/haskell/flameshot-once.nix deleted file mode 100644 index c8007ce9..00000000 --- a/krebs/5pkgs/haskell/flameshot-once.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ mkDerivation, async, base, blessings, bytestring, dbus, fetchgit -, iso8601-time, lib, process, random, text, time, unagi-chan, unix -}: -mkDerivation { - pname = "flameshot-once"; - version = "1.4.0"; - src = fetchgit { - url = "https://cgit.krebsco.de/flameshot-once"; - sha256 = "13szgsiwn29aixm5xvs1m7128y5km5xss0ry5ii5y068rc2vysw8"; - rev = "4475893c2081b3d9db4b7a54d0ce38d0914a17bf"; - fetchSubmodules = true; - }; - isLibrary = false; - isExecutable = true; - executableHaskellDepends = [ - async base blessings bytestring dbus iso8601-time process random - text time unagi-chan unix - ]; - license = lib.licenses.mit; -} diff --git a/krebs/5pkgs/simple/flameshot-once/default.nix b/krebs/5pkgs/simple/flameshot-once/default.nix deleted file mode 100644 index 0524c2cf..00000000 --- a/krebs/5pkgs/simple/flameshot-once/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, stockholm, ... }@args: -with stockholm.lib; - -let - # config cannot be declared in the input attribute set because that would - # cause callPackage to inject the wrong config. Instead, get it from ... - # via args. - config = args.config or {}; -in - - pkgs.symlinkJoin { - name = "flameshot-once-wrapper"; - paths = [ - (pkgs.writeDashBin "flameshot-once" '' - export PATH=${makeBinPath [ - pkgs.flameshot - pkgs.qt5.qtbase - pkgs.xclip - pkgs.xwaitforwindow - ]} - ${optionalString (config != null) /* sh */ '' - . ${import ./profile.nix { inherit config pkgs; }} - ''} - exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@" - '') - pkgs.haskellPackages.flameshot-once - ]; - } diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix deleted file mode 100644 index 269f13a6..00000000 --- a/krebs/5pkgs/simple/flameshot-once/profile.nix +++ /dev/null @@ -1,235 +0,0 @@ -{ config, pkgs }: -with pkgs.stockholm.lib; -with generators; -let - - # Refs https://github.com/lupoDharkael/flameshot/blob/master/src/widgets/capture/capturebutton.h - ButtonType = { - PENCIL = 0; - DRAWER = 1; - ARROW = 2; - SELECTION = 3; - RECTANGLE = 4; - CIRCLE = 5; - MARKER = 6; - SELECTIONINDICATOR = 7; - MOVESELECTION = 8; - UNDO = 9; - COPY = 10; - SAVE = 11; - EXIT = 12; - IMAGEUPLOADER = 13; - OPEN_APP = 14; - BLUR = 15; - REDO = 16; - PIN = 17; - TEXT = 18; - CIRCLECOUNT = 19; - }; - - cfg = eval.config; - - eval = evalModules { - modules = singleton { - _file = toString ./profile.nix; - imports = singleton config; - options = { - buttons = mkOption { - apply = map (name: ButtonType.${name}); - default = [ - "PENCIL" - "DRAWER" - "ARROW" - "SELECTION" - "RECTANGLE" - "CIRCLE" - "MARKER" - "SELECTIONINDICATOR" - "MOVESELECTION" - "UNDO" - "SAVE" - "EXIT" - "BLUR" - "CIRCLECOUNT" - ] - ++ optional cfg.imgur.enable "IMAGEUPLOADER" - ; - type = types.listOf (types.enum (attrNames ButtonType)); - }; - copyAndCloseAfterUpload = mkOption { - default = false; - type = types.bool; - }; - disabledTrayIcon = mkOption { - default = true; - type = types.bool; - }; - drawColor = mkOption { - default = "#ff0000"; - type = - types.addCheck types.str (test "#[0-9A-Fa-f]{6}"); - }; - drawThickness = mkOption { - default = 8; - type = types.positive; - }; - filenamePattern = mkOption { - default = "%FT%T%z_flameshot"; - type = - # This is types.filename extended by [%:][%:+]* - types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"); - }; - imgur = mkOption { - default = {}; - type = types.submodule { - options = { - enable = mkEnableOption "imgur"; - createUrl = mkOption { - example = "http://p.r/image"; - type = types.str; - }; - deleteUrl = mkOption { - example = "http://p.r/image/delete/%1"; - type = types.str; - }; - xdg-open = mkOption { - default = {}; - type = types.submodule { - options = { - enable = mkEnableOption "imgur.xdg-open" // { - default = true; - }; - browser = mkOption { - default = "${pkgs.coreutils}/bin/false"; - type = types.str; - }; - createPrefix = mkOption { - default = cfg.imgur.createUrl; - type = types.str; - }; - deletePrefix = mkOption { - default = removeSuffix "/%1" cfg.imgur.deleteUrl; - type = types.str; - }; - }; - }; - }; - }; - }; - }; - savePath = mkOption { - default = "/tmp"; - type = types.absolute-pathname; - }; - showDesktopNotification = mkOption { - default = false; - type = types.bool; - }; - showHelp = mkOption { - default = false; - type = types.bool; - }; - showSidePanelButton = mkOption { - default = false; - type = types.bool; - }; - showStartupLaunchMessage = mkOption { - default = false; - type = types.bool; - }; - timeout = mkOption { - default = 200; - description = '' - Maximum time in milliseconds allowed for the flameshot daemon to - react. - ''; - type = types.positive; - }; - }; - }; - }; - - hexchars = stringToCharacters "0123456789abcdef"; - - # Encode integer to C-escaped string of bytes, little endian / LSB 0 - le = rec { - x1 = i: let - i0 = mod i 16; - i1 = i / 16; - in - "\\x${elemAt hexchars i1}${elemAt hexchars i0}"; - - x2 = i: let - i0 = mod i 256; - i1 = i / 256; - in - "${x1 i0}${x1 i1}"; - - x4 = i: let - i0 = mod i 65536; - i1 = i / 65536; - in - "${x2 i0}${x2 i1}"; - }; - - toQList = t: xs: - assert t == "int"; - "QList<${t}>${le.x4 0}${le.x4 (length xs)}${concatMapStrings le.x4 xs}"; - - XDG_CONFIG_HOME = pkgs.write "flameshot-config" { - "/flameshot/flameshot.ini".text = - toINI {} { - General = { - buttons = ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})''; - disabledTrayIcon = cfg.disabledTrayIcon; - checkForUpdates = false; - copyAndCloseAfterUpload = cfg.copyAndCloseAfterUpload; - drawColor = cfg.drawColor; - drawThickness = cfg.drawThickness; - filenamePattern = cfg.filenamePattern; - savePath = cfg.savePath; - showDesktopNotification = cfg.showDesktopNotification; - showHelp = cfg.showHelp; - showSidePanelButton = cfg.showSidePanelButton; - showStartupLaunchMessage = cfg.showStartupLaunchMessage; - startupLaunch = false; - }; - Shortcuts = { - TYPE_COPY = "Return"; - }; - }; - }; - -in - - pkgs.writeDash "flameshot.profile" '' - export FLAMESHOT_CAPTURE_PATH=${cfg.savePath} - export FLAMESHOT_ONCE_TIMEOUT=${toString cfg.timeout} - export XDG_CONFIG_HOME=${XDG_CONFIG_HOME} - ${optionalString cfg.imgur.enable /* sh */ '' - export IMGUR_CREATE_URL=${shell.escape cfg.imgur.createUrl} - export IMGUR_DELETE_URL=${shell.escape cfg.imgur.deleteUrl} - ${optionalString cfg.imgur.xdg-open.enable /* sh */ '' - PATH=$PATH:${makeBinPath [ - (pkgs.writeDashBin "xdg-open" '' - set -efu - uri=$1 - prefix=$(${pkgs.coreutils}/bin/dirname "$uri") - case $prefix in - (${shell.escape cfg.imgur.xdg-open.createPrefix}) - echo "opening image in browser: $uri" >&2 - exec ${config.imgur.xdg-open.browser} "$uri" - ;; - (${shell.escape cfg.imgur.xdg-open.deletePrefix}) - echo "deleting image: $uri" >&2 - exec ${pkgs.curl}/bin/curl -fsS -X DELETE "$uri" - ;; - (*) - echo "don't know how to open URI: $uri" >&2 - exit 1 - esac - '') - ]} - ''} - ''} - '' diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix index efd6c8a2..2e28d48b 100644 --- a/lass/2configs/baseX.nix +++ b/lass/2configs/baseX.nix @@ -91,11 +91,11 @@ in { xorg.xhost xsel zathura - flameshot-once + flameshot (pkgs.writeDashBin "screenshot" '' set -efu - ${pkgs.flameshot-once}/bin/flameshot-once + ${pkgs.flameshot}/bin/flameshot ${pkgs.klem}/bin/klem '') ]; diff --git a/tv/5pkgs/haskell/flameshot-once.nix b/tv/5pkgs/haskell/flameshot-once.nix new file mode 100644 index 00000000..c8007ce9 --- /dev/null +++ b/tv/5pkgs/haskell/flameshot-once.nix @@ -0,0 +1,20 @@ +{ mkDerivation, async, base, blessings, bytestring, dbus, fetchgit +, iso8601-time, lib, process, random, text, time, unagi-chan, unix +}: +mkDerivation { + pname = "flameshot-once"; + version = "1.4.0"; + src = fetchgit { + url = "https://cgit.krebsco.de/flameshot-once"; + sha256 = "13szgsiwn29aixm5xvs1m7128y5km5xss0ry5ii5y068rc2vysw8"; + rev = "4475893c2081b3d9db4b7a54d0ce38d0914a17bf"; + fetchSubmodules = true; + }; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + async base blessings bytestring dbus iso8601-time process random + text time unagi-chan unix + ]; + license = lib.licenses.mit; +} diff --git a/tv/5pkgs/simple/flameshot-once/default.nix b/tv/5pkgs/simple/flameshot-once/default.nix new file mode 100644 index 00000000..0524c2cf --- /dev/null +++ b/tv/5pkgs/simple/flameshot-once/default.nix @@ -0,0 +1,28 @@ +{ pkgs, stockholm, ... }@args: +with stockholm.lib; + +let + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; +in + + pkgs.symlinkJoin { + name = "flameshot-once-wrapper"; + paths = [ + (pkgs.writeDashBin "flameshot-once" '' + export PATH=${makeBinPath [ + pkgs.flameshot + pkgs.qt5.qtbase + pkgs.xclip + pkgs.xwaitforwindow + ]} + ${optionalString (config != null) /* sh */ '' + . ${import ./profile.nix { inherit config pkgs; }} + ''} + exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@" + '') + pkgs.haskellPackages.flameshot-once + ]; + } diff --git a/tv/5pkgs/simple/flameshot-once/profile.nix b/tv/5pkgs/simple/flameshot-once/profile.nix new file mode 100644 index 00000000..269f13a6 --- /dev/null +++ b/tv/5pkgs/simple/flameshot-once/profile.nix @@ -0,0 +1,235 @@ +{ config, pkgs }: +with pkgs.stockholm.lib; +with generators; +let + + # Refs https://github.com/lupoDharkael/flameshot/blob/master/src/widgets/capture/capturebutton.h + ButtonType = { + PENCIL = 0; + DRAWER = 1; + ARROW = 2; + SELECTION = 3; + RECTANGLE = 4; + CIRCLE = 5; + MARKER = 6; + SELECTIONINDICATOR = 7; + MOVESELECTION = 8; + UNDO = 9; + COPY = 10; + SAVE = 11; + EXIT = 12; + IMAGEUPLOADER = 13; + OPEN_APP = 14; + BLUR = 15; + REDO = 16; + PIN = 17; + TEXT = 18; + CIRCLECOUNT = 19; + }; + + cfg = eval.config; + + eval = evalModules { + modules = singleton { + _file = toString ./profile.nix; + imports = singleton config; + options = { + buttons = mkOption { + apply = map (name: ButtonType.${name}); + default = [ + "PENCIL" + "DRAWER" + "ARROW" + "SELECTION" + "RECTANGLE" + "CIRCLE" + "MARKER" + "SELECTIONINDICATOR" + "MOVESELECTION" + "UNDO" + "SAVE" + "EXIT" + "BLUR" + "CIRCLECOUNT" + ] + ++ optional cfg.imgur.enable "IMAGEUPLOADER" + ; + type = types.listOf (types.enum (attrNames ButtonType)); + }; + copyAndCloseAfterUpload = mkOption { + default = false; + type = types.bool; + }; + disabledTrayIcon = mkOption { + default = true; + type = types.bool; + }; + drawColor = mkOption { + default = "#ff0000"; + type = + types.addCheck types.str (test "#[0-9A-Fa-f]{6}"); + }; + drawThickness = mkOption { + default = 8; + type = types.positive; + }; + filenamePattern = mkOption { + default = "%FT%T%z_flameshot"; + type = + # This is types.filename extended by [%:][%:+]* + types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"); + }; + imgur = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur"; + createUrl = mkOption { + example = "http://p.r/image"; + type = types.str; + }; + deleteUrl = mkOption { + example = "http://p.r/image/delete/%1"; + type = types.str; + }; + xdg-open = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur.xdg-open" // { + default = true; + }; + browser = mkOption { + default = "${pkgs.coreutils}/bin/false"; + type = types.str; + }; + createPrefix = mkOption { + default = cfg.imgur.createUrl; + type = types.str; + }; + deletePrefix = mkOption { + default = removeSuffix "/%1" cfg.imgur.deleteUrl; + type = types.str; + }; + }; + }; + }; + }; + }; + }; + savePath = mkOption { + default = "/tmp"; + type = types.absolute-pathname; + }; + showDesktopNotification = mkOption { + default = false; + type = types.bool; + }; + showHelp = mkOption { + default = false; + type = types.bool; + }; + showSidePanelButton = mkOption { + default = false; + type = types.bool; + }; + showStartupLaunchMessage = mkOption { + default = false; + type = types.bool; + }; + timeout = mkOption { + default = 200; + description = '' + Maximum time in milliseconds allowed for the flameshot daemon to + react. + ''; + type = types.positive; + }; + }; + }; + }; + + hexchars = stringToCharacters "0123456789abcdef"; + + # Encode integer to C-escaped string of bytes, little endian / LSB 0 + le = rec { + x1 = i: let + i0 = mod i 16; + i1 = i / 16; + in + "\\x${elemAt hexchars i1}${elemAt hexchars i0}"; + + x2 = i: let + i0 = mod i 256; + i1 = i / 256; + in + "${x1 i0}${x1 i1}"; + + x4 = i: let + i0 = mod i 65536; + i1 = i / 65536; + in + "${x2 i0}${x2 i1}"; + }; + + toQList = t: xs: + assert t == "int"; + "QList<${t}>${le.x4 0}${le.x4 (length xs)}${concatMapStrings le.x4 xs}"; + + XDG_CONFIG_HOME = pkgs.write "flameshot-config" { + "/flameshot/flameshot.ini".text = + toINI {} { + General = { + buttons = ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})''; + disabledTrayIcon = cfg.disabledTrayIcon; + checkForUpdates = false; + copyAndCloseAfterUpload = cfg.copyAndCloseAfterUpload; + drawColor = cfg.drawColor; + drawThickness = cfg.drawThickness; + filenamePattern = cfg.filenamePattern; + savePath = cfg.savePath; + showDesktopNotification = cfg.showDesktopNotification; + showHelp = cfg.showHelp; + showSidePanelButton = cfg.showSidePanelButton; + showStartupLaunchMessage = cfg.showStartupLaunchMessage; + startupLaunch = false; + }; + Shortcuts = { + TYPE_COPY = "Return"; + }; + }; + }; + +in + + pkgs.writeDash "flameshot.profile" '' + export FLAMESHOT_CAPTURE_PATH=${cfg.savePath} + export FLAMESHOT_ONCE_TIMEOUT=${toString cfg.timeout} + export XDG_CONFIG_HOME=${XDG_CONFIG_HOME} + ${optionalString cfg.imgur.enable /* sh */ '' + export IMGUR_CREATE_URL=${shell.escape cfg.imgur.createUrl} + export IMGUR_DELETE_URL=${shell.escape cfg.imgur.deleteUrl} + ${optionalString cfg.imgur.xdg-open.enable /* sh */ '' + PATH=$PATH:${makeBinPath [ + (pkgs.writeDashBin "xdg-open" '' + set -efu + uri=$1 + prefix=$(${pkgs.coreutils}/bin/dirname "$uri") + case $prefix in + (${shell.escape cfg.imgur.xdg-open.createPrefix}) + echo "opening image in browser: $uri" >&2 + exec ${config.imgur.xdg-open.browser} "$uri" + ;; + (${shell.escape cfg.imgur.xdg-open.deletePrefix}) + echo "deleting image: $uri" >&2 + exec ${pkgs.curl}/bin/curl -fsS -X DELETE "$uri" + ;; + (*) + echo "don't know how to open URI: $uri" >&2 + exit 1 + esac + '') + ]} + ''} + ''} + '' -- cgit v1.2.3 From 2fa9f8601ed3f5c81316b9b780a03d414b4de9b3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 3 Feb 2023 13:25:44 +0100 Subject: l baseX: flameshot-once -> flameshot --- lass/2configs/baseX.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix index efd6c8a2..79777429 100644 --- a/lass/2configs/baseX.nix +++ b/lass/2configs/baseX.nix @@ -91,11 +91,11 @@ in { xorg.xhost xsel zathura - flameshot-once + flameshot (pkgs.writeDashBin "screenshot" '' set -efu - ${pkgs.flameshot-once}/bin/flameshot-once + ${pkgs.flameshot}/bin/flameshot gui ${pkgs.klem}/bin/klem '') ]; -- cgit v1.2.3 From b1b4fedb1db2a1adcfb4a686de5a51db86af0df2 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 4 Feb 2023 17:51:20 +0100 Subject: news.r: move into sync-containers3 --- krebs/1systems/news/config.nix | 11 +++-------- krebs/2configs/news-host.nix | 9 ++------- krebs/2configs/news.nix | 3 ++- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/krebs/1systems/news/config.nix b/krebs/1systems/news/config.nix index 620e6249..b27fc373 100644 --- a/krebs/1systems/news/config.nix +++ b/krebs/1systems/news/config.nix @@ -17,13 +17,8 @@ boot.isContainer = true; networking.useDHCP = lib.mkForce true; - krebs.bindfs = { - "/var/lib/brockman" = { - source = "/var/state/brockman"; - options = [ - "-m ${toString config.users.users.brockman.uid}:${toString config.users.users.nginx.uid}" - ]; - clearTarget = true; - }; + krebs.sync-containers3.inContainer = { + enable = true; + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMBVZomw68WDQy0HsHhNbWK1KpzaR5aRUG1oioE7IgCv"; }; } diff --git a/krebs/2configs/news-host.nix b/krebs/2configs/news-host.nix index 07674c86..71793e51 100644 --- a/krebs/2configs/news-host.nix +++ b/krebs/2configs/news-host.nix @@ -1,10 +1,5 @@ { - krebs.sync-containers.containers.news = { - peers = [ - "shodan" - "mors" - "styx" - ]; - format = "plain"; + krebs.sync-containers3.containers.news = { + sshKey = "${toString }/news.sync.key"; }; } diff --git a/krebs/2configs/news.nix b/krebs/2configs/news.nix index d6c6371d..9d947072 100644 --- a/krebs/2configs/news.nix +++ b/krebs/2configs/news.nix @@ -74,7 +74,7 @@ limits.identlen = 100; history.enabled = false; }; - systemd.services.brockman.bindsTo = [ "ergo.service" ]; + systemd.services.brockman.bindsTo = [ "ergochat.service" ]; systemd.services.brockman.serviceConfig.LimitNOFILE = 16384; systemd.services.brockman.environment.BROCKMAN_LOG_LEVEL = "DEBUG"; krebs.brockman = { @@ -87,6 +87,7 @@ nick = "brockman"; extraChannels = [ "#all" ]; }; + statePath = "/var/state/brockman/brockman.json"; bots = {}; }; }; -- cgit v1.2.3 From 55d3bb391f32f1abe27f1e0f58a8baac82b703cc Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 4 Feb 2023 18:46:51 +0100 Subject: l jitsi: more configs for bigger groups --- lass/2configs/jitsi.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lass/2configs/jitsi.nix b/lass/2configs/jitsi.nix index fa41f663..2c148dcd 100644 --- a/lass/2configs/jitsi.nix +++ b/lass/2configs/jitsi.nix @@ -8,6 +8,16 @@ enableWelcomePage = true; requireDisplayName = true; analytics.disabled = true; + startAudioOnly = true; + channelLastN = 4; + stunServers = [ + # - https://www.kuketz-blog.de/jitsi-meet-server-einstellungen-fuer-einen-datenschutzfreundlichen-betrieb/ + { urls = "turn:turn.matrix.org:3478?transport=udp"; } + { urls = "turn:turn.matrix.org:3478?transport=tcp"; } + # - services.coturn: + #{ urls = "turn:turn.${domainName}:3479?transport=udp"; } + #{ urls = "turn:turn.${domainName}:3479?transport=tcp"; } + ]; }; interfaceConfig = { SHOW_JITSI_WATERMARK = false; @@ -17,6 +27,10 @@ }; }; + services.jitsi-videobridge.config = { + org.jitsi.videobridge.TRUST_BWE = false; + }; + krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-p tcp --dport 4443"; target = "ACCEPT"; } { predicate = "-p udp --dport 10000"; target = "ACCEPT"; } -- cgit v1.2.3 From 90b46307b5d71b36f28eed78dfcdd2b2e6b57972 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Feb 2023 00:59:47 +0100 Subject: htgen-imgur: 1.0.0 -> 1.2.0 Generate deletehash without dashes, otherwise an unpatched flameshot will fail to delete uploaded images, as it uses dashes to pack files into its history. --- krebs/5pkgs/simple/htgen-imgur/default.nix | 2 +- krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/htgen-imgur/default.nix b/krebs/5pkgs/simple/htgen-imgur/default.nix index e6b60be4..379150a8 100644 --- a/krebs/5pkgs/simple/htgen-imgur/default.nix +++ b/krebs/5pkgs/simple/htgen-imgur/default.nix @@ -1,7 +1,7 @@ { attr, coreutils, exiv2, findutils, gnugrep, jq, nix, stockholm, util-linux, stdenv }: stdenv.mkDerivation rec { pname = "htgen-imgur"; - version = "1.0.0"; + version = "1.2.0"; src = ./src; diff --git a/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur b/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur index af092d00..696d1c00 100644 --- a/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur +++ b/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur @@ -99,7 +99,7 @@ case "$Method $path" in if item=$(find_item $base32short); then - deletehash=$(uuidgen) + deletehash=$(uuidgen | tr -d -) info=$( exiv2 print "$item" | -- cgit v1.2.3 From 7b8f46c398b459bdbb9650465d5912100dd5f3fe Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 18:10:41 +0100 Subject: lib.types.boundedInt: init --- lib/types.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index 32b4541a..cda33813 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -287,6 +287,12 @@ rec { }; }); + boundedInt = min: max: mkOptionType { + name = "bounded integer"; + check = x: isInt x && min <= x && x <= max; + merge = mergeOneOption; + }; + positive = mkOptionType { name = "positive integer"; check = x: isInt x && x > 0; -- cgit v1.2.3 From 3b04273d5cf816897ba6f0b1879bea259726703b Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 18:10:50 +0100 Subject: lib.types.lowerBoundedInt: init --- lib/types.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/types.nix b/lib/types.nix index cda33813..f7c49164 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -293,15 +293,21 @@ rec { merge = mergeOneOption; }; + lowerBoundedInt = min: mkOptionType { + name = "lower bounded integer"; + check = x: isInt x && min <= x; + merge = mergeOneOption; + }; + positive = mkOptionType { + inherit (lowerBoundedInt 1) check; name = "positive integer"; - check = x: isInt x && x > 0; merge = mergeOneOption; }; uint = mkOptionType { + inherit (lowerBoundedInt 0) check; name = "unsigned integer"; - check = x: isInt x && x >= 0; merge = mergeOneOption; }; -- cgit v1.2.3 From 377840226c448fd44f616b77e6057cd414f12480 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Feb 2023 00:41:47 +0100 Subject: lib.types.svg.color-keyword: init --- lib/svg-colors.json | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/types.nix | 17 +++++- 2 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 lib/svg-colors.json diff --git a/lib/svg-colors.json b/lib/svg-colors.json new file mode 100644 index 00000000..834bf14f --- /dev/null +++ b/lib/svg-colors.json @@ -0,0 +1,149 @@ +[ + "aliceblue", + "antiquewhite", + "aqua", + "aquamarine", + "azure", + "beige", + "bisque", + "black", + "blanchedalmond", + "blue", + "blueviolet", + "brown", + "burlywood", + "cadetblue", + "chartreuse", + "chocolate", + "coral", + "cornflowerblue", + "cornsilk", + "crimson", + "cyan", + "darkblue", + "darkcyan", + "darkgoldenrod", + "darkgray", + "darkgreen", + "darkgrey", + "darkkhaki", + "darkmagenta", + "darkolivegreen", + "darkorange", + "darkorchid", + "darkred", + "darksalmon", + "darkseagreen", + "darkslateblue", + "darkslategray", + "darkslategrey", + "darkturquoise", + "darkviolet", + "deeppink", + "deepskyblue", + "dimgray", + "dimgrey", + "dodgerblue", + "firebrick", + "floralwhite", + "forestgreen", + "fuchsia", + "gainsboro", + "ghostwhite", + "gold", + "goldenrod", + "gray", + "green", + "greenyellow", + "grey", + "honeydew", + "hotpink", + "indianred", + "indigo", + "ivory", + "khaki", + "lavender", + "lavenderblush", + "lawngreen", + "lemonchiffon", + "lightblue", + "lightcoral", + "lightcyan", + "lightgoldenrodyellow", + "lightgray", + "lightgreen", + "lightgrey", + "lightpink", + "lightsalmon", + "lightseagreen", + "lightskyblue", + "lightslategray", + "lightslategrey", + "lightsteelblue", + "lightyellow", + "lime", + "limegreen", + "linen", + "magenta", + "maroon", + "mediumaquamarine", + "mediumblue", + "mediumorchid", + "mediumpurple", + "mediumseagreen", + "mediumslateblue", + "mediumspringgreen", + "mediumturquoise", + "mediumvioletred", + "midnightblue", + "mintcream", + "mistyrose", + "moccasin", + "navajowhite", + "navy", + "oldlace", + "olive", + "olivedrab", + "orange", + "orangered", + "orchid", + "palegoldenrod", + "palegreen", + "paleturquoise", + "palevioletred", + "papayawhip", + "peachpuff", + "peru", + "pink", + "plum", + "powderblue", + "purple", + "red", + "rosybrown", + "royalblue", + "saddlebrown", + "salmon", + "sandybrown", + "seagreen", + "seashell", + "sienna", + "silver", + "skyblue", + "slateblue", + "slategray", + "slategrey", + "snow", + "springgreen", + "steelblue", + "tan", + "teal", + "thistle", + "tomato", + "turquoise", + "violet", + "wheat", + "white", + "whitesmoke", + "yellow", + "yellowgreen" +] diff --git a/lib/types.nix b/lib/types.nix index f7c49164..4bb8c173 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -3,8 +3,8 @@ let inherit (lib) all any attrNames concatMapStringsSep concatStringsSep const filter flip - genid_uint31 hasSuffix head isInt isString length mergeOneOption mkOption - mkOptionType optional optionalAttrs optionals range splitString + genid_uint31 hasSuffix head importJSON isInt isString length mergeOneOption + mkOption mkOptionType optional optionalAttrs optionals range splitString stringLength substring test testString typeOf; inherit (lib.types) attrsOf bool either enum int lines listOf nullOr path str submodule; @@ -613,6 +613,19 @@ rec { merge = mergeOneOption; }; + # SVG 1.1, 4.4 Recognized color keyword names + # + # svg-colors.json has been generated with: + # curl -sS https://www.w3.org/TR/SVG11/types.html#ColorKeywords | + # fq -d html '[ + # grep_by(.["@class"]=="color-keywords") | + # grep_by(.["@class"]=="prop-value"and.["#text"]!="").["#text"] + # ] | sort' + # + svg.color-keyword = enum (importJSON ./svg-colors.json) // { + name = "SVG 1.1 recognized color keyword"; + }; + systemd.unit-name = mkOptionType { name = "systemd unit name"; check = x: -- cgit v1.2.3 From f802eaf7847eb7bd1b8a735dac5166fa8999ea06 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Feb 2023 00:47:55 +0100 Subject: lib.hexchars: init --- lib/default.nix | 2 ++ lib/genid.nix | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 280f0429..187514a3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -45,6 +45,8 @@ let genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2; genid_uint32 = import ./genid.nix { inherit lib; }; + hexchars = stringToCharacters "0123456789abcdef"; + lpad = n: c: s: if lib.stringLength s < n then lib.lpad n c (c + s) diff --git a/lib/genid.nix b/lib/genid.nix index 0aed1d35..bfa4a9a0 100644 --- a/lib/genid.nix +++ b/lib/genid.nix @@ -32,6 +32,5 @@ let out = genid; hexint = x: hexvals.${toLower x}; # :: attrset char uint4 - hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; }) - (stringToCharacters "0123456789abcdef")); + hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; }) hexchars); in out -- cgit v1.2.3 From 23b63bfdfb5ed2700441f13429cbd1cd0c2ea870 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 4 Feb 2023 21:52:14 +0100 Subject: flameshot-once: reinit with flameshot 12.1.0-pre --- krebs/5pkgs/simple/flameshot-once/config.nix | 408 +++++++++++++++++++++ krebs/5pkgs/simple/flameshot-once/default.nix | 71 ++++ .../simple/flameshot-once/flameshot/default.nix | 15 + .../flameshot/flameshot-12.imgur.patch | 43 +++ lib/types.nix | 5 +- tv/5pkgs/haskell/flameshot-once.nix | 20 - tv/5pkgs/override/flameshot/default.nix | 15 - .../flameshot/flameshot_imgur_0.10.2.patch | 35 -- tv/5pkgs/simple/flameshot-once/default.nix | 28 -- tv/5pkgs/simple/flameshot-once/profile.nix | 235 ------------ 10 files changed, 541 insertions(+), 334 deletions(-) create mode 100644 krebs/5pkgs/simple/flameshot-once/config.nix create mode 100644 krebs/5pkgs/simple/flameshot-once/default.nix create mode 100644 krebs/5pkgs/simple/flameshot-once/flameshot/default.nix create mode 100644 krebs/5pkgs/simple/flameshot-once/flameshot/flameshot-12.imgur.patch delete mode 100644 tv/5pkgs/haskell/flameshot-once.nix delete mode 100644 tv/5pkgs/override/flameshot/default.nix delete mode 100644 tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch delete mode 100644 tv/5pkgs/simple/flameshot-once/default.nix delete mode 100644 tv/5pkgs/simple/flameshot-once/profile.nix diff --git a/krebs/5pkgs/simple/flameshot-once/config.nix b/krebs/5pkgs/simple/flameshot-once/config.nix new file mode 100644 index 00000000..817c700a --- /dev/null +++ b/krebs/5pkgs/simple/flameshot-once/config.nix @@ -0,0 +1,408 @@ +{ config, pkgs, ... }: +with pkgs.stockholm.lib; + +let + # Encode integer to C-escaped string of bytes, little endian / LSB 0 + le = rec { + x1 = i: let + i0 = mod i 16; + i1 = i / 16; + in + if i == 0 then + "\\0" + else if i < 16 then + "\\x${elemAt hexchars i0}" + else + "\\x${elemAt hexchars i1}${elemAt hexchars i0}"; + + x2 = i: let + i0 = mod i 256; + i1 = i / 256; + in + "${x1 i1}${x1 i0}"; + + x4 = i: let + i0 = mod i 65536; + i1 = i / 65536; + in + "${x2 i1}${x2 i0}"; + }; + + toQList = t: xs: + assert t == "int"; + "QList<${t}>${le.x4 0}${le.x1 (length xs)}${concatMapStrings le.x4 xs}"; +in + +{ + options = { + imgur = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur"; + createUrl = mkOption { + example = "http://p.r/image"; + type = types.str; + }; + deleteUrl = mkOption { + example = "http://p.r/image/delete/%1"; + type = types.str; + }; + xdg-open = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur.xdg-open" // { + default = true; + }; + browser = mkOption { + default = "${pkgs.coreutils}/bin/false"; + type = types.str; + }; + createPrefix = mkOption { + default = config.imgur.createUrl; + type = types.str; + }; + deletePrefix = mkOption { + default = removeSuffix "/%1" config.imgur.deleteUrl; + type = types.str; + }; + }; + }; + }; + }; + }; + }; + package = mkOption { + type = types.package; + default = import ./flameshot { inherit pkgs; }; + }; + settings = { + # Options without a description are not documented in flameshot's README. + General = mapAttrs (_: recursiveUpdate { default = null; }) { + allowMultipleGuiInstances = mkOption { + description = '' + Allow multiple instances of `flameshot gui` to run at the same time + ''; + type = with types; nullOr bool; + }; + antialiasingPinZoom = mkOption { + description = '' + Anti-aliasing image when zoom the pinned image + ''; + type = with types; nullOr bool; + }; + autoCloseIdleDaemon = mkOption { + description = '' + Automatically close daemon when it's not needed + ''; + type = with types; nullOr bool; + }; + buttons = let + buttonTypes = { + TYPE_PENCIL = 0; + TYPE_DRAWER = 1; + TYPE_ARROW = 2; + TYPE_SELECTION = 3; + TYPE_RECTANGLE = 4; + TYPE_CIRCLE = 5; + TYPE_MARKER = 6; + TYPE_SELECTIONINDICATOR = 7; + TYPE_MOVESELECTION = 8; + TYPE_UNDO = 9; + TYPE_COPY = 10; + TYPE_SAVE = 11; + TYPE_EXIT = 12; + TYPE_IMAGEUPLOADER = 13; + TYPE_OPEN_APP = 14; + TYPE_PIXELATE = 15; + TYPE_REDO = 16; + TYPE_PIN = 17; + TYPE_TEXT = 18; + TYPE_CIRCLECOUNT = 19; + TYPE_SIZEINCREASE = 20; + TYPE_SIZEDECREASE = 21; + TYPE_INVERT = 22; + TYPE_ACCEPT = 23; + }; + iterableButtonTypes = [ + "TYPE_ACCEPT" + "TYPE_ARROW" + "TYPE_CIRCLE" + "TYPE_CIRCLECOUNT" + "TYPE_COPY" + "TYPE_DRAWER" + "TYPE_EXIT" + "TYPE_IMAGEUPLOADER" + "TYPE_MARKER" + "TYPE_MOVESELECTION" + "TYPE_OPEN_APP" + "TYPE_PENCIL" + "TYPE_PIN" + "TYPE_PIXELATE" + "TYPE_RECTANGLE" + "TYPE_REDO" + "TYPE_SAVE" + "TYPE_SELECTION" + "TYPE_SIZEDECREASE" + "TYPE_SIZEINCREASE" + "TYPE_TEXT" + "TYPE_UNDO" + ]; + in mkOption { + apply = names: + if names != null then let + values = map (name: buttonTypes.${name}) names; + in + ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" values})'' + else + null; + description = '' + Configure which buttons to show after drawing a selection + ''; + type = with types; nullOr (listOf (enum iterableButtonTypes)); + }; + checkForUpdates = mkOption { + type = with types; nullOr bool; + }; + contrastOpacity = mkOption { + description = '' + Opacity of area outside selection + ''; + type = with types; nullOr (boundedInt 0 255); + }; + contrastUiColor = mkOption { + description = '' + Contrast UI color + ''; + type = with types; nullOr flameshot.color; + }; + copyAndCloseAfterUpload = mkOption { + type = with types; nullOr bool; + }; + copyOnDoubleClick = mkOption { + type = with types; nullOr bool; + }; + copyPathAfterSave = mkOption { + description = '' + Copy path to image after save + ''; + type = with types; nullOr bool; + }; + copyURLAfterUpload = mkOption { + description = '' + On successful upload, close the dialog and copy URL to clipboard + ''; + type = with types; nullOr bool; + }; + disabledTrayIcon = mkOption { + description = '' + Whether the tray icon is disabled + ''; + type = with types; nullOr bool; + }; + drawColor = mkOption { + description = '' + Last used color + ''; + type = with types; nullOr flameshot.color; + }; + drawFontSize = mkOption { + type = with types; nullOr positive; + }; + drawThickness = mkOption { + description = '' + Last used tool thickness + ''; + type = with types; nullOr positive; + }; + filenamePattern = mkOption { + description = '' + Filename pattern using C++ strftime formatting + ''; + type = + # This is types.filename extended by [%:][%:+]* + with types; + nullOr (addCheck str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*")); + }; + fontFamily = mkOption { + type = with types; nullOr str; + }; + historyConfirmationToDelete = mkOption { + type = with types; nullOr bool; + }; + ignoreUpdateToVersion = mkOption { + description = '' + Ignore updates to versions less than this value + ''; + type = with types; nullOr str; + }; + keepOpenAppLauncher = mkOption { + description = '' + Keep the App Launcher open after selecting an app + ''; + type = with types; nullOr bool; + }; + predefinedColorPaletteLarge = mkOption { + description = '' + Use larger color palette as the default one + ''; + type = with types; nullOr bool; + }; + saveAfterCopy = mkOption { + description = '' + Save image after copy + ''; + type = with types; nullOr bool; + }; + saveAsFileExtension = mkOption { + description = '' + Default file extension for screenshots + ''; + type = with types; nullOr (addCheck filename (hasPrefix ".")); + }; + safeLastRegion = mkOption { + type = with types; nullOr bool; +