From 01c6dccc9ca3ad756aa9cba1c2cc31e6ee4a5776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Wed, 10 Jun 2020 16:36:52 +0200 Subject: [PATCH] feat(i3): configure klem --- configs/i3.nix | 40 +++++++++++++++++++++++++++++++++++++-- packages/scripts/klem.nix | 4 ++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/configs/i3.nix b/configs/i3.nix index 815440a..6fae7e2 100644 --- a/configs/i3.nix +++ b/configs/i3.nix @@ -1,7 +1,43 @@ { config, pkgs, lib, ... }: let - klem = pkgs.callPackage { - inherit pkgs; + klem = import { + inherit pkgs lib; + config.scripts = { + "p.r" = pkgs.writers.writeDash "p.r" '' + ${pkgs.curl}/bin/curl -fSs http://p.r --data-binary @- \ + | ${pkgs.coreutils}/bin/tail --lines=1 \ + | ${pkgs.gnused}/bin/sed 's/\\/krebsco.de/' + ''; + "ix.io" = pkgs.writers.writeDash "ix.io" '' + ${pkgs.curl}/bin/curl -fSs -F 'f:1=<-' ix.io + ''; + "go.r" = pkgs.writers.writeDash "go.r" '' + ${pkgs.curl}/bin/curl -fSs http://go.r -F "uri=$(${pkgs.coreutils}/bin/cat)" + ''; + "0x0.st" = pkgs.writers.writeDash "0x0.st" '' + ${pkgs.curl}/bin/curl -fSs https://0x0.st -F "shorten=$(${pkgs.coreutils}/bin/cat)" + ''; + "rot13" = pkgs.writers.writeDash "rot13" '' + ${pkgs.coreutils}/bin/tr '[A-Za-z]' '[N-ZA-Mn-za-m]' + ''; + "ipa" = pkgs.writers.writeDash "ipa" '' + ${scripts.ipa}/bin/ipa + ''; + "rot13.hs" = pkgs.writers.writeHaskell "rot13.hs" {} '' + import Data.Char (chr, isAlpha, ord, toLower) + import Data.Bool (bool) + + main = interact $ map $ \c -> + if isAlpha c + then chr $ bool (-) (+) ('m' >= toLower c) (ord c) 13 + else c + ''; + "rot13.py" = pkgs.writers.writePython3 "rot13.py" {} '' + import codecs + import sys + sys.stdout.write(codecs.encode(sys.stdin.read(), "rot13")) + ''; + }; }; scripts = import { inherit pkgs lib; }; diff --git a/packages/scripts/klem.nix b/packages/scripts/klem.nix index 5d5d693..91b01fa 100644 --- a/packages/scripts/klem.nix +++ b/packages/scripts/klem.nix @@ -18,14 +18,14 @@ let shorten = ''${pkgs.curl}/bin/curl -fSs -F "shorten=$(${pkgs.coreutils}/bin/cat)" https://0x0.st''; "replace p.r" = "${pkgs.gnused}/bin/sed 's/\\/krebsco.de/'"; }; - type = lib.types.attrsOf lib.types.str; + type = lib.types.attrs; }; }; } ]; }; scriptCase = option: script: '' - '${option}') ${script} ;; + '${option}') ${toString script} ;; ''; in pkgs.writers.writeDashBin "klem" ''