From 9d61f006a67ff2aa60ec730816ba996b21c7c3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 28 Feb 2023 21:32:42 +0100 Subject: [PATCH] feat: get krebs stuff from stockholm flake --- configs/default.nix | 5 +- configs/packages.nix | 10 +- configs/power-action.nix | 4 +- flake.lock | 139 +++++++++++++++++++----- flake.nix | 13 +-- modules/htgen.nix | 47 -------- modules/power-action.nix | 94 ---------------- modules/retiolum.nix | 72 ------------- packages/cyberlocker-tools.nix | 23 ---- packages/dic.nix | 43 -------- packages/hc.nix | 49 --------- packages/htgen.nix | 31 ------ packages/kpaste.nix | 9 -- packages/timer.nix | 5 +- packages/untilport.nix | 17 --- packages/weechat-declarative.nix | 177 ------------------------------- systems/makanek/tarot.nix | 48 ++++----- systems/makanek/weechat.nix | 4 +- 18 files changed, 155 insertions(+), 635 deletions(-) delete mode 100644 modules/htgen.nix delete mode 100644 modules/power-action.nix delete mode 100644 modules/retiolum.nix delete mode 100644 packages/cyberlocker-tools.nix delete mode 100644 packages/dic.nix delete mode 100644 packages/hc.nix delete mode 100644 packages/htgen.nix delete mode 100644 packages/kpaste.nix delete mode 100644 packages/untilport.nix delete mode 100644 packages/weechat-declarative.nix diff --git a/configs/default.nix b/configs/default.nix index 86dd3ff..4a1b5fd 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -13,7 +13,10 @@ in { imports = [ inputs.self.nixosModules.system-dependent inputs.self.nixosModules.traadfri - inputs.self.nixosModules.power-action + inputs.stockholm.nixosModules.power-action + { + nixpkgs.config.overlays = [inputs.nix-writers]; + } { boot.supportedFilesystems = ["ntfs"]; } diff --git a/configs/packages.nix b/configs/packages.nix index f3c7ba1..5ce7346 100644 --- a/configs/packages.nix +++ b/configs/packages.nix @@ -134,7 +134,7 @@ in { okular # the word is nucular xournalpp # for annotating pdfs pdfpc # presenter console for pdf slides - niveumPackages.hc # print files as qr codes + inputs.stockholm.packages.x86_64-linux.hc # print files as qr codes yt-dlp espeak bc # calculator @@ -214,10 +214,10 @@ in { niveumPackages.nix-index-update #krebs - niveumPackages.dic - niveumPackages.cyberlocker-tools - niveumPackages.untilport - niveumPackages.kpaste + inputs.stockholm.packages.x86_64-linux.dic + inputs.stockholm.packages.x86_64-linux.cyberlocker-tools + inputs.stockholm.packages.x86_64-linux.untilport + inputs.stockholm.packages.x86_64-linux.kpaste config.nur.repos.mic92.ircsink (python3.withPackages (py: [ diff --git a/configs/power-action.nix b/configs/power-action.nix index b466908..794bee0 100644 --- a/configs/power-action.nix +++ b/configs/power-action.nix @@ -5,7 +5,7 @@ }: let suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend"; in { - services.power-action = { + krebs.power-action = { enable = true; plans.suspend = { upperLimit = 7; @@ -19,6 +19,6 @@ in { }; security.sudo.extraConfig = '' - ${config.services.power-action.user} ALL= (root) NOPASSWD: ${suspend} + ${config.krebs.power-action.user} ALL= (root) NOPASSWD: ${suspend} ''; } diff --git a/flake.lock b/flake.lock index f2889ba..63acda5 100644 --- a/flake.lock +++ b/flake.lock @@ -74,6 +74,36 @@ "type": "github" } }, + "flake-utils_10": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_11": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flake-utils_2": { "locked": { "lastModified": 1659877975, @@ -166,11 +196,11 @@ }, "flake-utils_8": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "type": "github" }, "original": { @@ -290,6 +320,25 @@ "type": "github" } }, + "nix-writers": { + "inputs": { + "flake-utils": "flake-utils_8", + "nixpkgs": "nixpkgs_7" + }, + "locked": { + "lastModified": 1677612737, + "narHash": "sha256-UaCKZ4PbMZU6UZH7XNFcjRtd5jheswl66rjZDBfQgp8=", + "ref": "refs/heads/master", + "rev": "66a1f6833464bbb121b6d94247ad769f277351f8", + "revCount": 39, + "type": "git", + "url": "https://cgit.krebsco.de/nix-writers" + }, + "original": { + "type": "git", + "url": "https://cgit.krebsco.de/nix-writers" + } + }, "nixinate": { "inputs": { "nixpkgs": [ @@ -326,6 +375,22 @@ "type": "github" } }, + "nixpkgs_10": { + "locked": { + "lastModified": 1669418739, + "narHash": "sha256-T86oFvcUIRwHWBWUt7WjaP4BP/3lDGbv5AppQSI1FkI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "695b3515251873e0a7e2021add4bba643c56cde3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "695b3515251873e0a7e2021add4bba643c56cde3", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1665296151, @@ -406,6 +471,21 @@ } }, "nixpkgs_7": { + "locked": { + "lastModified": 1677608380, + "narHash": "sha256-k82O23qBAK+43X0KSBjsMYXG2x4kWWXeAmpPTc2KRGY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4aba90e89f6d4ac6138939961f62842bd94ec929", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_8": { "locked": { "lastModified": 1659446231, "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", @@ -421,7 +501,7 @@ "type": "github" } }, - "nixpkgs_8": { + "nixpkgs_9": { "locked": { "lastModified": 1665296151, "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", @@ -437,22 +517,6 @@ "type": "github" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1669418739, - "narHash": "sha256-T86oFvcUIRwHWBWUt7WjaP4BP/3lDGbv5AppQSI1FkI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "695b3515251873e0a7e2021add4bba643c56cde3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "695b3515251873e0a7e2021add4bba643c56cde3", - "type": "github" - } - }, "nur": { "locked": { "lastModified": 1677308535, @@ -516,6 +580,7 @@ "recht": "recht", "retiolum": "retiolum", "scripts": "scripts", + "stockholm": "stockholm", "telebots": "telebots", "tinc-graph": "tinc-graph", "traadfri": "traadfri", @@ -581,8 +646,8 @@ }, "rust-overlay_4": { "inputs": { - "flake-utils": "flake-utils_8", - "nixpkgs": "nixpkgs_8" + "flake-utils": "flake-utils_10", + "nixpkgs": "nixpkgs_9" }, "locked": { "lastModified": 1677119371, @@ -626,10 +691,32 @@ "type": "github" } }, - "telebots": { + "stockholm": { "inputs": { "flake-utils": "flake-utils_7", - "nixpkgs": "nixpkgs_7" + "nix-writers": "nix-writers", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677616153, + "narHash": "sha256-PNXb97q62yK61alFlOeohpro8WLxt2ay1jYUTrFMgPA=", + "owner": "kmein", + "repo": "stockholm", + "rev": "831a6668339e3be59a449645624fd61e55bd45ff", + "type": "github" + }, + "original": { + "owner": "kmein", + "repo": "stockholm", + "type": "github" + } + }, + "telebots": { + "inputs": { + "flake-utils": "flake-utils_9", + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1677156381, @@ -671,8 +758,8 @@ }, "traadfri": { "inputs": { - "flake-utils": "flake-utils_9", - "nixpkgs": "nixpkgs_9" + "flake-utils": "flake-utils_11", + "nixpkgs": "nixpkgs_10" }, "locked": { "lastModified": 1677165914, diff --git a/flake.nix b/flake.nix index 4323e02..5ca899e 100644 --- a/flake.nix +++ b/flake.nix @@ -17,12 +17,14 @@ tinc-graph.url = "github:kmein/tinc-graph"; traadfri.url = "github:kmein/traadfri"; voidrice.url = "github:Lukesmithxyz/voidrice"; + stockholm.url = "github:kmein/stockholm"; agenix.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; menstruation-backend.inputs.flake-utils.follows = "flake-utils"; menstruation-backend.inputs.nixpkgs.follows = "nixpkgs"; nixinate.inputs.nixpkgs.follows = "nixpkgs"; + stockholm.inputs.nixpkgs.follows = "nixpkgs"; tinc-graph.inputs.flake-utils.follows = "flake-utils"; tinc-graph.inputs.nixpkgs.follows = "nixpkgs"; voidrice.flake = false; @@ -37,6 +39,7 @@ agenix, retiolum, flake-utils, + stockholm, ... }: let in @@ -44,11 +47,9 @@ apps = nixinate.nixinate.x86_64-linux self; nixosModules = { - htgen = import modules/htgen.nix; moodle-dl = import modules/moodle-dl.nix; networkmanager-declarative = import modules/networkmanager-declarative.nix; passport = import modules/passport.nix; - power-action = import modules/power-action.nix; system-dependent = import modules/system-dependent.nix; telegram-bot = import modules/telegram-bot.nix; traadfri = import modules/traadfri.nix; @@ -117,7 +118,7 @@ } systems/makanek/configuration.nix inputs.self.nixosModules.telegram-bot - inputs.self.nixosModules.htgen + inputs.stockholm.nixosModules.htgen inputs.self.nixosModules.passport agenix.nixosModules.default retiolum.nixosModules.retiolum @@ -205,7 +206,6 @@ betacode = pkgs.callPackage packages/betacode.nix {}; cheat-sh = pkgs.callPackage packages/cheat-sh.nix {}; closest = pkgs.callPackage packages/closest {}; - cyberlocker-tools = pkgs.callPackage packages/cyberlocker-tools.nix {}; default-gateway = pkgs.callPackage packages/default-gateway.nix {}; depp = pkgs.callPackage packages/depp.nix {}; devanagari = pkgs.callPackage packages/devanagari {}; @@ -220,9 +220,7 @@ genius = pkgs.callPackage packages/genius.nix {}; gfs-fonts = pkgs.callPackage packages/gfs-fonts.nix {}; git-preview = pkgs.callPackage packages/git-preview.nix {}; - hc = pkgs.callPackage packages/hc.nix {}; heuretes = pkgs.callPackage packages/heuretes.nix {}; - htgen = pkgs.callPackage packages/htgen.nix {}; image-convert-favicon = pkgs.callPackage packages/image-convert-favicon.nix {}; image-convert-tolino = pkgs.callPackage packages/image-convert-tolino.nix {}; infschmv = pkgs.callPackage packages/infschmv.nix {}; @@ -233,7 +231,6 @@ k-lock = pkgs.callPackage packages/k-lock.nix {}; kirciuoklis = pkgs.callPackage packages/kirciuoklis.nix {}; klem = pkgs.callPackage packages/klem.nix {}; - kpaste = pkgs.callPackage packages/kpaste.nix {}; literature-quote = pkgs.callPackage packages/literature-quote.nix {}; mahlzeit = pkgs.haskellPackages.callPackage packages/mahlzeit.nix {}; man-pandoc = pkgs.callPackage packages/man/pandoc.nix {}; @@ -260,7 +257,6 @@ trans = pkgs.callPackage packages/trans.nix {}; ttspaste = pkgs.callPackage packages/ttspaste.nix {}; unicodmenu = pkgs.callPackage packages/unicodmenu.nix {}; - untilport = pkgs.callPackage packages/untilport.nix {}; vg = pkgs.callPackage packages/vg.nix {}; vimPlugins-cheat-sh-vim = pkgs.callPackage packages/vimPlugins/cheat-sh.nix {}; vimPlugins-icalendar-vim = pkgs.callPackage packages/vimPlugins/icalendar-vim.nix {}; @@ -272,7 +268,6 @@ vimPlugins-vim-mail = pkgs.callPackage packages/vimPlugins/vim-mail.nix {}; vimPlugins-vim-reason-plus = pkgs.callPackage packages/vimPlugins/vim-reason-plus.nix {}; vimv = pkgs.callPackage packages/vimv.nix {}; - weechat-declarative = pkgs.callPackage packages/weechat-declarative.nix {}; weechatScripts-hotlist2extern = pkgs.callPackage packages/weechatScripts/hotlist2extern.nix {}; wttr = pkgs.callPackage packages/wttr.nix {}; diff --git a/modules/htgen.nix b/modules/htgen.nix deleted file mode 100644 index 6f1e043..0000000 --- a/modules/htgen.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - htgen = pkgs.callPackage ../packages/htgen.nix {}; -in { - options.services.htgen = lib.mkOption { - default = {}; - type = lib.types.attrsOf (lib.types.submodule ({config, ...}: { - options = { - enable = lib.mkEnableOption "htgen-${config._module.args.name}"; - port = lib.mkOption { - type = lib.types.int; - }; - script = lib.mkOption { - type = lib.types.str; - }; - }; - })); - }; - config = { - systemd.services = - lib.mapAttrs' ( - name: cfg: - lib.nameValuePair "htgen-${name}" { - wantedBy = ["multi-user.target"]; - after = ["network.target"]; - environment = { - HOME = "/var/lib/htgen-${name}"; - HTGEN_PORT = toString cfg.port; - HTGEN_SCRIPT = cfg.script; - }; - serviceConfig = { - SyslogIdentifier = "htgen-${name}"; - DynamicUser = true; - StateDirectory = "htgen-${name}"; - PrivateTmp = true; - Restart = "always"; - ExecStart = "${htgen}/bin/htgen --serve"; - }; - } - ) - config.services.htgen; - }; -} diff --git a/modules/power-action.nix b/modules/power-action.nix deleted file mode 100644 index 71fd8f1..0000000 --- a/modules/power-action.nix +++ /dev/null @@ -1,94 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.services.power-action; - - out = { - options.services.power-action = api; - config = lib.mkIf cfg.enable imp; - }; - - api = { - enable = mkEnableOption "power-action"; - battery = mkOption { - type = types.str; - default = "BAT0"; - }; - user = mkOption { - type = types.str; - default = "power-action"; - }; - startAt = mkOption { - type = types.str; - default = "*:0/1"; - }; - plans = mkOption { - type = with types; - attrsOf (submodule { - options = { - charging = mkOption { - type = nullOr bool; - default = null; - description = '' - check for charging status. - null = don't care - true = only if system is charging or unknown - false = only if system is discharging - ''; - }; - upperLimit = mkOption { - type = int; - }; - lowerLimit = mkOption { - type = int; - }; - action = mkOption { - type = path; - }; - }; - }); - }; - }; - - imp = { - systemd.services.power-action = { - serviceConfig = rec { - ExecStart = startScript; - User = cfg.user; - }; - startAt = cfg.startAt; - }; - }; - - startScript = pkgs.writers.writeDash "power-action" '' - set -euf - - power="$(${powerlvl})" - state="$(${state})" - ${concatStringsSep "\n" (mapAttrsToList writeRule cfg.plans)} - ''; - charging_check = plan: - if (plan.charging == null) - then "" - else if plan.charging - then ''&& [ "$state" = "true" ]'' - else ''&& ! [ "$state" = "true" ]''; - - writeRule = _: plan: "if [ $power -ge ${toString plan.lowerLimit} ] && [ $power -le ${toString plan.upperLimit} ] ${charging_check plan}; then ${plan.action}; fi"; - - powerlvl = pkgs.writers.writeDash "powerlvl" '' - cat /sys/class/power_supply/${cfg.battery}/capacity - ''; - - state = pkgs.writers.writeDash "state" '' - if [ "$(cat /sys/class/power_supply/${cfg.battery}/status)" = "Discharging" ] - then echo "false" - else echo "true" - fi - ''; -in - out diff --git a/modules/retiolum.nix b/modules/retiolum.nix deleted file mode 100644 index 908a356..0000000 --- a/modules/retiolum.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: -with lib; let - netname = "retiolum"; - cfg = config.networking.retiolum; -in { - options = { - networking.retiolum.ipv4 = mkOption { - type = types.str; - description = '' - own ipv4 address - ''; - }; - networking.retiolum.ipv6 = mkOption { - type = types.str; - description = '' - own ipv6 address - ''; - }; - networking.retiolum.nodename = mkOption { - type = types.str; - default = config.networking.hostName; - description = '' - tinc network name - ''; - }; - }; - - config = { - services.tinc.networks.${netname} = { - name = cfg.nodename; - hosts = - builtins.mapAttrs - (name: _: builtins.readFile "${}/${name}") - (builtins.readDir ); - rsaPrivateKeyFile = toString ; - ed25519PrivateKeyFile = toString ; - extraConfig = '' - LocalDiscovery = yes - AutoConnect = yes - ''; - }; - - networking.extraHosts = builtins.readFile (toString ); - - environment.systemPackages = [config.services.tinc.networks.${netname}.package]; - - networking.firewall = { - allowedTCPPorts = [655]; - allowedUDPPorts = [655]; - }; - #services.netdata.portcheck.checks.tinc.port = 655; - - systemd.network = { - enable = true; - networks = { - "${netname}".extraConfig = '' - [Match] - Name = tinc.${netname} - - [Network] - Address=${cfg.ipv4}/12 - Address=${cfg.ipv6}/16 - ''; - }; - }; - }; -} diff --git a/packages/cyberlocker-tools.nix b/packages/cyberlocker-tools.nix deleted file mode 100644 index 0c997ea..0000000 --- a/packages/cyberlocker-tools.nix +++ /dev/null @@ -1,23 +0,0 @@ -{pkgs}: -pkgs.symlinkJoin { - name = "cyberlocker-tools"; - paths = [ - (pkgs.writers.writeDashBin "cput" '' - set -efu - path=''${1:-$(hostname)} - path=$(echo "/$path" | sed -E 's:/+:/:') - url=http://c.r$path - - ${pkgs.curl}/bin/curl -fSs --data-binary @- "$url" - echo "$url" - '') - (pkgs.writers.writeDashBin "cdel" '' - set -efu - path=$1 - path=$(echo "/$path" | sed -E 's:/+:/:') - url=http://c.r$path - - ${pkgs.curl}/bin/curl -f -X DELETE "$url" - '') - ]; -} diff --git a/packages/dic.nix b/packages/dic.nix deleted file mode 100644 index 334a5fc..0000000 --- a/packages/dic.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ - fetchgit, - lib, - stdenv, - coreutils, - curl, - gnugrep, - gnused, - util-linux, -}: -stdenv.mkDerivation { - name = "dic"; - - src = fetchgit { - url = https://cgit.ni.krebsco.de/dic; - rev = "refs/tags/v1.1.1"; - sha256 = "1gbj967a5hj53fdkkxijqgwnl9hb8kskz0cmpjq7v65ffz3v6vag"; - }; - - phases = [ - "unpackPhase" - "installPhase" - ]; - - installPhase = let - path = lib.makeBinPath [ - coreutils - curl - gnused - gnugrep - util-linux - ]; - in '' - mkdir -p $out/bin - - sed \ - 's,^main() {$,&\n PATH=${path}; export PATH,' \ - < ./dic \ - > $out/bin/dic - - chmod +x $out/bin/dic - ''; -} diff --git a/packages/hc.nix b/packages/hc.nix deleted file mode 100644 index b481de8..0000000 --- a/packages/hc.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - fetchgit, - lib, - makeWrapper, - stdenv, - coreutils, - findutils, - gawk, - gnugrep, - qrencode, - texlive, - utillinux, - zbar, -}: -stdenv.mkDerivation rec { - name = "hc-${meta.version}"; - - src = fetchgit { - url = "https://cgit.krebsco.de/hc"; - rev = "refs/tags/v${meta.version}"; - sha256 = "09349gja22p0j3xs082kp0fnaaada14bafszn4r3q7rg1id2slfb"; - }; - - nativeBuildInputs = [makeWrapper]; - - buildPhase = null; - - installPhase = '' - mkdir -p $out/bin - - cp $src/bin/hc $out/bin/hc - - wrapProgram $out/bin/hc \ - --prefix PATH : ${lib.makeBinPath [ - coreutils - findutils - gawk - gnugrep - qrencode - texlive.combined.scheme-full - utillinux - zbar - ]} - ''; - - meta = { - version = "1.0.0"; - }; -} diff --git a/packages/htgen.nix b/packages/htgen.nix deleted file mode 100644 index 7d129b0..0000000 --- a/packages/htgen.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - fetchgit, - lib, - pkgs, - stdenv, -}: -stdenv.mkDerivation rec { - pname = "htgen"; - version = "1.3.1"; - - src = fetchgit { - url = "http://cgit.krebsco.de/htgen"; - rev = "refs/tags/${version}"; - sha256 = "0ml8kp89bwkrwy6iqclzyhxgv2qn9dcpwaafbmsr4mgcl70zx22r"; - }; - - installPhase = '' - mkdir -p $out/bin - { - echo '#! ${pkgs.dash}/bin/dash' - echo 'export PATH=${lib.makeBinPath [ - pkgs.coreutils - pkgs.jq - pkgs.ucspi-tcp - ]}''${PATH+":$PATH"}' - sed 's:^Server=htgen$:&/${version}:' htgen - } > $out/bin/htgen - chmod +x $out/bin/htgen - cp -r examples $out - ''; -} diff --git a/packages/kpaste.nix b/packages/kpaste.nix deleted file mode 100644 index 54d7f28..0000000 --- a/packages/kpaste.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - curl, - gnused, - writers, -}: -writers.writeDashBin "kpaste" '' - ${curl}/bin/curl -sS http://p.r --data-binary @"''${1:--}" | - ${gnused}/bin/sed '$ {p;s|http://p.r|https://p.krebsco.de|}' -'' diff --git a/packages/timer.nix b/packages/timer.nix index d743e56..5422b09 100644 --- a/packages/timer.nix +++ b/packages/timer.nix @@ -9,9 +9,6 @@ writers.writeDashBin "timer" '' echo "Usage: $0 TIME MESSAGE" 1>&2 exit 1 } - time=$(echo "$1" | ${bc}/bin/bc) echo "sleeping $time seconds, then saying: $2" - ${coreutils}/bin/sleep "$time" && { - echo "$2" | ${espeak}/bin/espeak -v german-mbrola-6 - } + ${coreutils}/bin/sleep "$time" && ${espeak}/bin/espeak -v german-mbrola-6 "$2" '' diff --git a/packages/untilport.nix b/packages/untilport.nix deleted file mode 100644 index 0db755f..0000000 --- a/packages/untilport.nix +++ /dev/null @@ -1,17 +0,0 @@ -{pkgs, ...}: -pkgs.writers.writeDashBin "untilport" '' - set -euf - - usage() { - echo 'untiport $target $port' - echo 'Sleeps until the destinated port is reachable.' - echo 'ex: untilport google.de 80 && echo "google is now reachable"' - } - - - if [ $# -ne 2 ]; then - usage - else - until ${pkgs.libressl.nc}/bin/nc -z "$@"; do sleep 1; done - fi -'' diff --git a/packages/weechat-declarative.nix b/packages/weechat-declarative.nix deleted file mode 100644 index b12eb9f..0000000 --- a/packages/weechat-declarative.nix +++ /dev/null @@ -1,177 +0,0 @@ -{ - pkgs, - lib, - ... -} @ args: 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 {}; - - lib = - args.lib - // rec { - attrPaths = let - recurse = path: value: - if builtins.isAttrs value - then lib.mapAttrsToList (name: recurse (path ++ [name])) value - else [(lib.nameValuePair path value)]; - in - attrs: lib.flatten (recurse [] attrs); - - attrPathsSep = sep: attrs: lib.listToAttrs (map (x: x // {name = lib.concatStringsSep sep x.name;}) (attrPaths attrs)); - - toWeechatValue = x: - { - bool = builtins.toJSON x; - string = x; - list = lib.concatMapStringsSep "," toWeechatValue x; - int = toString x; - } - .${builtins.typeOf x}; - - setCommand = name: value: "/set ${name} \"${toWeechatValue value}\""; - - filterAddreplace = name: filter: "/filter addreplace ${name} ${filter.buffer} ${toWeechatValue filter.tags} ${filter.regex}"; - }; - - cfg = eval.config; - - eval = lib.evalModules { - modules = lib.singleton { - _file = toString ./default.nix; - imports = lib.singleton config; - options = { - scripts = lib.mkOption { - type = lib.types.listOf lib.types.package; - default = []; - description = '' - some stuff from pkgs.weechatScripts - ''; - }; - settings = lib.mkOption { - type = (pkgs.formats.json {}).type; - description = '' - your weechat config in nix-style syntax. - secrets can be defined with \''${my.secret.value} - ''; - default = {}; - example = { - irc.server_default.nicks = "rick_\\\${sec.data.foo}"; - irc.server_default.msg_part = "ciao kakao"; - irc.server_default.msg_quit = "tschö mit \\\${sec.data.foo}"; - irc.look.color_nicks_in_nicklist = true; - matrix.server.nibbana = { - address = "nibbana.jp"; - }; - irc.server.hackint = { - address = "irc.hackint.org/6697"; - ssl = true; - autoconnect = true; - autojoin = ["#krebs"]; - }; - weechat.bar.buflist.hidden = true; - irc.server.hackint.command = lib.concatStringsSep "\\;" [ - "/msg nickserv IDENTIFY \\\${sec.data.hackint_password}" - "/msg nickserv SET CLOAK ON" - ]; - filters.playlist_topic = { - buffer = "irc.*.#the_playlist"; - tags = ["irc_topic"]; - regex = "*"; - }; - relay = { - port.weechat = 9000; - network.password = "hunter2"; - }; - alias.cmd.mod = "quote omode $channel +o $nick"; - secure.test.passphrase_command = "echo lol1234123124"; - }; - }; - extraCommands = lib.mkOption { - type = lib.types.lines; - default = ""; - }; - files = lib.mkOption { - type = lib.types.attrsOf lib.types.str; - default = {}; - example = lib.literalExpression '' - { - "sec.conf" = toString (pkgs.writeText "sec.conf" ''' - [crypt] - cipher = aes256 - hash_algo = sha256 - passphrase_command = "" - salt = on - - [data] - __passphrase__ = off - foo = "bar" - '''); - } - ''; - }; - }; - }; - }; - - setFile = pkgs.writeText "weechat.set" ( - lib.optionalString (cfg.settings != {}) - (lib.concatStringsSep "\n" ( - lib.optionals - (cfg.settings.irc or {} != {}) - (lib.mapAttrsToList - (name: server: "/server add ${name} ${lib.toWeechatValue server.addresses}") - cfg.settings.irc.server) - ++ lib.optionals - (cfg.settings.matrix or {} != {}) - (lib.mapAttrsToList - (name: server: "/matrix server add ${name} ${server.address}") - cfg.settings.matrix.server) - ++ lib.mapAttrsToList lib.setCommand (lib.attrPathsSep "." cfg.settings) - ++ lib.optionals - (cfg.settings.filters or {} != {}) - (lib.mapAttrsToList lib.filterAddreplace cfg.settings.filters) - ++ lib.singleton cfg.extraCommands - )) - ); - - weechat = pkgs.weechat.override { - configure = _: { - init = "/exec -oc cat ${setFile}"; - - scripts = cfg.scripts; - }; - }; - - wrapper = pkgs.writers.writeDashBin "weechat" '' - CONFDIR=''${XDG_CONFIG_HOME:-$HOME/.config}/weechat - ${pkgs.coreutils}/bin/mkdir -p "$CONFDIR" - ${ - lib.concatStringsSep "\n" - ( - lib.mapAttrsToList - (name: target: - /* - sh - */ - '' - ${pkgs.coreutils}/bin/cp ${lib.escapeShellArg target} "$CONFDIR"/${lib.escapeShellArg name} - ${pkgs.coreutils}/bin/chmod +w "$CONFDIR"/${lib.escapeShellArg name} - '') - cfg.files - ) - } - exec ${weechat}/bin/weechat "$@" - ''; -in - pkgs.symlinkJoin { - name = "weechat-configured"; - paths = [ - wrapper - pkgs.weechat - ]; - postBuild = '' - ln -s ${setFile} $out/weechat.set - ''; - } diff --git a/systems/makanek/tarot.nix b/systems/makanek/tarot.nix index d633310..aa344a7 100644 --- a/systems/makanek/tarot.nix +++ b/systems/makanek/tarot.nix @@ -15,32 +15,32 @@ sha256 = "1n2m53kjg2vj9dbr70b9jrsbqwdfrcb48l4wswn21549fi24g6dx"; }; in { - services.htgen.tarot = { + krebs.htgen.tarot = { port = tarotPort; - script = ''. ${pkgs.writers.writeDash "tarot" '' - case "$Method $Request_URI" in - "GET /") - if item=$(${pkgs.findutils}/bin/find ${toString tarotFiles} -type f | ${pkgs.coreutils}/bin/shuf -n1); then - card=$(mktemp --tmpdir tarot.XXX) - trap 'rm $card' EXIT - reverse=$(${pkgs.coreutils}/bin/shuf -i0-1 -n1) - if [ "$reverse" -eq 1 ]; then - ${pkgs.imagemagick}/bin/convert -rotate 180 "$item" "$card" - else - ${pkgs.coreutils}/bin/cp "$item" "$card" - fi - printf 'HTTP/1.1 200 OK\r\n' - printf 'Content-Type: %s\r\n' "$(${pkgs.file}/bin/file -ib "$card")" - printf 'Server: %s\r\n' "$Server" - printf 'Connection: close\r\n' - printf 'Content-Length: %d\r\n' $(${pkgs.coreutils}/bin/wc -c < "$card") - printf '\r\n' - cat "$card" - exit + scriptFile = pkgs.writers.writeDash "tarot" '' + case "$Method $Request_URI" in + "GET /") + if item=$(${pkgs.findutils}/bin/find ${toString tarotFiles} -type f | ${pkgs.coreutils}/bin/shuf -n1); then + card=$(mktemp --tmpdir tarot.XXX) + trap 'rm $card' EXIT + reverse=$(${pkgs.coreutils}/bin/shuf -i0-1 -n1) + if [ "$reverse" -eq 1 ]; then + ${pkgs.imagemagick}/bin/convert -rotate 180 "$item" "$card" + else + ${pkgs.coreutils}/bin/cp "$item" "$card" fi - ;; - esac - ''}''; + printf 'HTTP/1.1 200 OK\r\n' + printf 'Content-Type: %s\r\n' "$(${pkgs.file}/bin/file -ib "$card")" + printf 'Server: %s\r\n' "$Server" + printf 'Connection: close\r\n' + printf 'Content-Length: %d\r\n' $(${pkgs.coreutils}/bin/wc -c < "$card") + printf '\r\n' + cat "$card" + exit + fi + ;; + esac + ''; }; niveum.passport.services = [ diff --git a/systems/makanek/weechat.nix b/systems/makanek/weechat.nix index 14f1c02..9402249 100644 --- a/systems/makanek/weechat.nix +++ b/systems/makanek/weechat.nix @@ -1,11 +1,11 @@ { lib, pkgs, + inputs, ... }: let inherit (import ../../lib) kieran; weechatHome = "/var/lib/weechat"; - weechat-declarative = pkgs.callPackage ../../packages/weechat-declarative.nix {}; in { systemd.services.weechat = let tmux = pkgs.writers.writeDash "tmux" '' @@ -26,7 +26,7 @@ in { '' } "$@" ''; - weechat = weechat-declarative.override { + weechat = inputs.stockholm.packages.x86_64-linux.weechat-declarative.override { config = { scripts = [ pkgs.weechatScripts.weechat-autosort