summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/5pkgs/simple')
-rw-r--r--krebs/5pkgs/simple/K_belwagen.nix38
-rw-r--r--krebs/5pkgs/simple/TabFS/src.json2
-rw-r--r--krebs/5pkgs/simple/airdcpp-webclient/default.nix2
-rw-r--r--krebs/5pkgs/simple/certaids.nix114
-rw-r--r--krebs/5pkgs/simple/collectd-connect-time/default.nix6
-rw-r--r--krebs/5pkgs/simple/default.nix10
-rw-r--r--krebs/5pkgs/simple/dic/default.nix39
-rw-r--r--krebs/5pkgs/simple/ecrypt/default.nix111
-rw-r--r--krebs/5pkgs/simple/eximlog.nix28
-rw-r--r--krebs/5pkgs/simple/font-size.nix1
-rw-r--r--krebs/5pkgs/simple/git-hooks/default.nix232
-rw-r--r--krebs/5pkgs/simple/gitignore.nix42
-rw-r--r--krebs/5pkgs/simple/hashPassword/default.nix15
-rw-r--r--krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur36
-rw-r--r--krebs/5pkgs/simple/htgen/default.nix2
-rw-r--r--krebs/5pkgs/simple/logf/default.nix112
-rw-r--r--krebs/5pkgs/simple/netcup/default.nix33
-rw-r--r--krebs/5pkgs/simple/nixos-format-error.nix107
-rw-r--r--krebs/5pkgs/simple/reaktor2-plugins/default.nix2
-rw-r--r--krebs/5pkgs/simple/repo-sync/default.nix2
-rw-r--r--krebs/5pkgs/simple/treq/default.nix8
-rw-r--r--krebs/5pkgs/simple/with-tmpdir/default.nix29
22 files changed, 172 insertions, 799 deletions
diff --git a/krebs/5pkgs/simple/K_belwagen.nix b/krebs/5pkgs/simple/K_belwagen.nix
deleted file mode 100644
index 2f64bb09d..000000000
--- a/krebs/5pkgs/simple/K_belwagen.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-{ lib, pkgs, stdenv }:
-
-stdenv.mkDerivation {
- pname = "K_belwagen";
- version = "1.0";
-
- src = pkgs.painload;
- sourceRoot = "source/K_belwagen";
-
- buildInputs = [
- pkgs.jack1
- pkgs.pkg-config
- ];
-
- patchPhase = ''
- sed -i '
- s@^cd@# &@
- s@^make@# &@
- s@^jackd@# &@
- s@^trap@# &@
-
- s@^set.*@&\nPATH=${lib.makeBinPath [
- pkgs.bc
- pkgs.coreutils
- ]}; export PATH@
-
- s@\./a\.out@'"$out"'/lib/a.out@
- ' alarm
- '';
-
- installPhase = ''
- mkdir -p $out/lib
- mkdir -p $out/bin
-
- cp alarm $out/bin
- cp a.out $out/lib
- '';
-}
diff --git a/krebs/5pkgs/simple/TabFS/src.json b/krebs/5pkgs/simple/TabFS/src.json
index 24e36aef3..931c9ecb8 100644
--- a/krebs/5pkgs/simple/TabFS/src.json
+++ b/krebs/5pkgs/simple/TabFS/src.json
@@ -1,8 +1,6 @@
{
"url": "https://cgit.krebsco.de/TabFS",
"rev": "a6045e0e29b85e3e66c468f3561009ded1db6ec5",
- "date": "2021-01-14T23:56:09+01:00",
- "path": "/nix/store/mbcywm1yq5vr7awxqb533faz34minfax-TabFS",
"sha256": "1z0kj95zh0jl8laa0whra1jys8pws3199sy29vmlv2nxrkz13blv",
"fetchSubmodules": false,
"deepClone": false,
diff --git a/krebs/5pkgs/simple/airdcpp-webclient/default.nix b/krebs/5pkgs/simple/airdcpp-webclient/default.nix
index 754fecf9c..f4634b595 100644
--- a/krebs/5pkgs/simple/airdcpp-webclient/default.nix
+++ b/krebs/5pkgs/simple/airdcpp-webclient/default.nix
@@ -4,7 +4,7 @@
stdenv.mkDerivation rec {
name = "airdcpp-webclient-${version}";
version = "2.3.0";
-
+
src = fetchurl {
url = http://web-builds.airdcpp.net/stable/airdcpp_2.3.0_webui-2.3.0_64-bit_portable.tar.gz;
sha256 = "0yvcl0nc70fghc7vfsgvbpryi5q97arld8adql4way4qa0mdnyv1";
diff --git a/krebs/5pkgs/simple/certaids.nix b/krebs/5pkgs/simple/certaids.nix
deleted file mode 100644
index 094868680..000000000
--- a/krebs/5pkgs/simple/certaids.nix
+++ /dev/null
@@ -1,114 +0,0 @@
-{ pkgs }:
-
-let
- cert2json = pkgs.writeDash "cert2json" ''
- # usage: cert2json < CERT > JSON
- set -efu
-
- ${pkgs.openssl}/bin/openssl crl2pkcs7 -nocrl -certfile /dev/stdin |
- ${pkgs.openssl}/bin/openssl pkcs7 -print_certs -text |
- ${pkgs.gawk}/bin/awk -F, -f ${pkgs.writeText "cert2json.awk" ''
- function abort(msg) {
- print(msg) > "/dev/stderr"
- exit 1
- }
-
- function toJSON(x, type, ret) {
- type = typeof(x)
- switch (type) {
- case "array":
- if (isArray(x)) return arrayToJSON(x)
- if (isObject(x)) return objectToJSON(x)
- abort("cannot render array to JSON", x)
- case "number":
- return numberToJSON(x)
- case "string":
- return stringToJSON(x)
- case "strnum":
- case "unassigned":
- case "regexp":
- case "untyped":
- default:
- abort("cannot render type: " type)
- }
- }
-
- function isArray(x, i, k) {
- i = 1
- for (k in x) {
- if (k != i++) return 0
- i++
- }
- return 1
- }
-
- function isObject(x, k) {
- for (k in x) {
- if (typeof(k) != "string") return 0
- }
- return 1
- }
-
- function arrayToJSON(x, k, ret) {
- ret = "["
- for (k in x) {
- ret=ret toJSON(x[k]) ","
- }
- sub(/,$/,"",ret)
- ret=ret "]"
- return ret
- }
-
- function objectToJSON(x, k,ret) {
- ret = "{"
- for (k in x) {
- ret = ret toJSON(k) ":" toJSON(x[k]) ","
- }
- sub(/,$/, "", ret)
- ret = ret "}"
- return ret
- }
-
- function numberToJSON(x) {
- return x
- }
-
- function stringToJSON(x) {
- gsub(/\\/, "&&",x)
- gsub(/\n/, "\\n", x)
- return "\"" x "\""
- }
-
- $1 ~ /^ *(Subject|Issuer):/ {
- sub(/^ */, "")
- sub(/: */, ",")
- key=tolower($1)
- sub(/[^,]*,/, "")
-
- # Normalize separators between relative distinguished names.
- # [1]: RFC2253, 3. Parsing a String back to a Distinguished Name
- # TODO support any distinguished name
- gsub(/ *[;,] */, ",")
-
- for(i = 0; i <= NF; i++) {
- split($i, a, "=")
- cache[key][a[1]] = a[2]
- }
- }
-
- /BEGIN CERTIFICATE/,/END CERTIFICATE/{
- cache["certificate"] = cache["certificate"] $0 "\n"
- }
-
- /END CERTIFICATE/{
- print toJSON(cache)
- delete cache
- }
- ''}
- '';
-in
-
-pkgs.runCommand "certaids" {} ''
- mkdir -p $out/bin
- ln -s ${cert2json} $out/bin/cert2json
-''
diff --git a/krebs/5pkgs/simple/collectd-connect-time/default.nix b/krebs/5pkgs/simple/collectd-connect-time/default.nix
index 525388029..abbfae40a 100644
--- a/krebs/5pkgs/simple/collectd-connect-time/default.nix
+++ b/krebs/5pkgs/simple/collectd-connect-time/default.nix
@@ -1,8 +1,10 @@
-{lib, pkgs, pythonPackages, fetchurl, ... }:
+{lib, pkgs, python3Packages, fetchurl, ... }:
-pythonPackages.buildPythonPackage rec {
+python3Packages.buildPythonPackage rec {
name = "collectd-connect-time-${version}";
version = "0.3.0";
+ pyproject = true;
+ build-system = [ python3Packages.setuptools ];
src = fetchurl {
url = "https://pypi.python.org/packages/source/c/collectd-connect-time/collectd-connect-time-${version}.tar.gz";
sha256 = "0vvrf9py9bwc8hk3scxwg4x2j8jlp2qva0mv4q8d9m4b4mk99c95";
diff --git a/krebs/5pkgs/simple/default.nix b/krebs/5pkgs/simple/default.nix
index a07e88c3b..e0b9ffdae 100644
--- a/krebs/5pkgs/simple/default.nix
+++ b/krebs/5pkgs/simple/default.nix
@@ -13,5 +13,15 @@ let
lib.compareVersions upstream.name override.name != -1
then lib.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override
else override;
+
+ ## This callPackage will try to detect obsolete overrides.
+ #callPackage = path: args: let
+ # pname = (parseDrvName override.name).name;
+ # override = self.callPackage path args;
+ # upstream = super.${pname} or { name = ""; };
+ #in
+ # override.overrideAttrs (old: {
+ # name = warnOldVersion upstream.name old.name;
+ # });
in
lib.mapNixDir (path: callPackage path {}) ./.
diff --git a/krebs/5pkgs/simple/dic/default.nix b/krebs/5pkgs/simple/dic/default.nix
deleted file mode 100644
index 39402c012..000000000
--- a/krebs/5pkgs/simple/dic/default.nix
+++ /dev/null
@@ -1,39 +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/krebs/5pkgs/simple/ecrypt/default.nix b/krebs/5pkgs/simple/ecrypt/default.nix
deleted file mode 100644
index f83f8cfe7..000000000
--- a/krebs/5pkgs/simple/ecrypt/default.nix
+++ /dev/null
@@ -1,111 +0,0 @@
-{ pkgs, lib }:
-
-#usage: ecrypt mount /var/crypted /var/unencrypted
-pkgs.writers.writeDashBin "ecrypt" ''
- set -euf
-
- PATH=${lib.makeBinPath (with pkgs; [
- coreutils
- ecryptfs
- gnused
- gnugrep
- jq
- mount
- keyutils
- umount
- ])}
-
- # turn echo back on if killed
- trap 'stty echo' INT
-
- case "$1" in
- init)
- shift
- mkdir -p "$1" "$2"
-
- # abort if src or dest are not empty
- if [ -e "$1"/.cfg.json ]; then
- echo 'source dir is already configured, aborting'
- exit 1
- elif ls -1qA "$2" | grep -q .; then
- echo 'destination dir is not empty, aborting'
- exit 1
- else
- # we start and exit ecryptfs-manager again to circumvent a bug where mounting the ecryptfs fails
- echo 4 | ecryptfs-manager
- stty -echo
- printf "passphrase: "
- read passphrase
- stty echo
- sig=$(echo "$passphrase" | ecryptfs-add-passphrase | grep 'Inserted auth tok' | sed 's/.*\[\(.*\)\].*/\1/')
- mount -t ecryptfs \
- -o ecryptfs_unlink_sigs,ecryptfs_fnek_sig="$sig",ecryptfs_key_bytes=16,ecryptfs_cipher=aes,ecryptfs_sig="$sig" \
- "$1" "$2"
-
- # add sig to json state file
- jq -n --arg sig "$sig" '{ "sig": $sig }' > "$1"/.cfg.json
- fi
- ;;
-
- mount)
- shift
- if ! [ -e "$1"/.cfg.json ]; then
- echo '.cfg.json missing in src'
- exit 1
- fi
- old_sig=$(cat "$1"/.cfg.json | jq -r .sig)
-
- # check if key is already in keyring, otherwise add it
-
- if keyctl list @u | grep -q "$old_sig"; then
- echo 'pw already saved'
- else
- # we start and exit ecryptfs-manager again to circumvent a bug where mounting the ecryptfs fails
- echo 4 | ecryptfs-manager
- stty -echo
- printf "passphrase: "
- read passphrase
- stty echo
- new_sig=$(echo "$passphrase" | ecryptfs-add-passphrase | grep 'Inserted auth tok' | sed 's/.*\[\(.*\)\].*/\1/')
-
- # check if passphrase matches sig
- if [ "$old_sig" != "$new_sig" ]; then
- echo 'passphrase does not match sig, bailing out'
- new_keyid=$(keyctl list @u | grep "$new_sig" | sed 's/\([0-9]*\).*/\1/')
- keyctl revoke "$new_keyid"
- keyctl unlink "$new_keyid"
- exit 1
- fi
- fi
-
- sig=$old_sig
- keyid=$(keyctl list @u | grep "$sig" | sed 's/\([0-9]*\).*/\1/')
- if (ls -1qA "$2" | grep -q .); then
- echo 'destination is not empty, bailing out'
- exit 1
- else
- mount -i -t ecryptfs \
- -o ecryptfs_passthrough=no,verbose=no,ecryptfs_unlink_sigs,ecryptfs_fnek_sig="$sig",ecryptfs_key_bytes=16,ecryptfs_cipher=aes,ecryptfs_sig="$sig" \
- "$1" "$2"
- fi
- ;;
-
- unmount)
- shift
-
- sig=$(cat "$1"/.cfg.json | jq -r .sig)
- keyid=$(keyctl list @u | grep "$sig" | sed 's/\s*\([0-9]*\).*/\1/')
-
- umount "$2" || :
- keyctl revoke "$keyid"
- keyctl unlink "$keyid"
- ;;
-
- *)
- echo 'usage:
- ecrypt init /tmp/src/ /tmp/dst/
- ecrypt mount /tmp/src/ /tmp/dst/
- ecrypt unmount /tmp/src/ /tmp/dst/
- '
- esac
-''
diff --git a/krebs/5pkgs/simple/eximlog.nix b/krebs/5pkgs/simple/eximlog.nix
deleted file mode 100644
index 4abbcfc5a..000000000
--- a/krebs/5pkgs/simple/eximlog.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ jq, lib, systemd, writeDashBin }:
-
-let
- stockholm.lib = import ../../../lib/pure.nix { inherit lib; };
- user = "exim"; # TODO make this configurable
-in
-
-# TODO execute eximlog only if journalctl doesn't fail
-# bash's set -o pipefail isn't enough
-
-writeDashBin "eximlog" ''
- ${systemd}/bin/journalctl \
- -u ${stockholm.lib.shell.escape user} \
- -o short-unix \
- "$@" \
- |
- ${jq}/bin/jq -Rr '
- # Only select lines that start with a timestamp
- select(test("^[0-9]")) |
-
- split(" ") |
- (.[0] | tonumber) as $time |
- (.[3:] | join(" ")) as $message |
-
- "\($time | strftime("%Y-%m-%d %H:%M:%S %z")) \($message)"
-
- '
-''
diff --git a/krebs/5pkgs/simple/font-size.nix b/krebs/5pkgs/simple/font-size.nix
index 21097ed6a..829325192 100644
--- a/krebs/5pkgs/simple/font-size.nix
+++ b/krebs/5pkgs/simple/font-size.nix
@@ -1,3 +1,4 @@
+# TODO kill me in favor of urxvt-resize-font
{ writeDashBin }:
writeDashBin "font-size" ''
set -efu
diff --git a/krebs/5pkgs/simple/git-hooks/default.nix b/krebs/5pkgs/simple/git-hooks/default.nix
index e6cde671e..fe159c833 100644
--- a/krebs/5pkgs/simple/git-hooks/default.nix
+++ b/krebs/5pkgs/simple/git-hooks/default.nix
@@ -1,108 +1,132 @@
-{ pkgs, lib, writeDash, ... }:
-
+{ pkgs, lib, ... }:
let
stockholm.lib = import ../../../../lib/pure.nix { inherit lib; };
- inherit (stockholm.lib) makeBinPath;
in
-
-pkgs.runCommand "irc-announce-git-hook" {} ''
- mkdir -p $out/bin
- cat > $out/bin/irc-announce-git-hook << 'OUTER'
-#!${pkgs.dash}/bin/dash
-set -euf
-
-# Required environment variables:
-# IRC_SERVER, IRC_PORT, IRC_NICK, IRC_CHANNEL
-# Optional: IRC_TLS (set to "true" for TLS), CGIT_ENDPOINT, VERBOSE
-
-export PATH=${makeBinPath (with pkgs; [
- coreutils
- git
- gnugrep
- gnused
-])}:$PATH
-
-green() { printf '\x0303,99%s\x0F' "$1"; }
-red() { printf '\x0304,99%s\x0F' "$1"; }
-orange() { printf '\x0307,99%s\x0F' "$1"; }
-pink() { printf '\x0313,99%s\x0F' "$1"; }
-gray() { printf '\x0314,99%s\x0F' "$1"; }
-
-unset message
-add_message() {
- message="''${message+$message
-}$*"
+with stockholm.lib;
+
+{
+ # TODO irc-announce should return a derivation
+ # but it cannot because krebs.git.repos.*.hooks :: attrsOf str
+ irc-announce =
+ { cgit_endpoint ? "http://cgit.${nick}.r"
+ , channel
+ , nick
+ , port ? 6667
+ , refs ? []
+ , server
+ , tls ? false
+ , verbose ? false
+ }: /* sh */ ''
+ #! /bin/sh
+ set -euf
+
+ export PATH=${makeBinPath (with pkgs; [
+ coreutils
+ git
+ gnugrep
+ gnused
+ ])}
+
+ green() { printf '\x0303,99%s\x0F' "$1"; }
+ red() { printf '\x0304,99%s\x0F' "$1"; }
+ orange() { printf '\x0307,99%s\x0F' "$1"; }
+ pink() { printf '\x0313,99%s\x0F' "$1"; }
+ gray() { printf '\x0314,99%s\x0F' "$1"; }
+
+ unset message
+ add_message() {
+ message="''${message+$message
+ }$*"
+ }
+
+ nick=${escapeShellArg nick}
+ channel=${escapeShellArg channel}
+ server=${escapeShellArg server}
+ tls=${escapeShellArg tls}
+ port=${toString port}
+
+ host=$nick
+
+ empty=0000000000000000000000000000000000000000
+
+ while read oldrev newrev ref; do
+
+ if [ $oldrev = $empty ]; then
+ receive_mode=create
+ elif [ $newrev = $empty ]; then
+ receive_mode=delete
+ elif [ "$(git merge-base $oldrev $newrev)" = $oldrev ]; then
+ receive_mode=fast-forward
+ else
+ receive_mode=non-fast-forward
+ fi
+
+ ${optionalString (refs != []) ''
+ if ! { echo "$ref" | grep -qE "${concatStringsSep "|" refs}"; }; then
+ echo "we are not announcing this ref: $h"
+ exit 0
+ fi
+ ''}
+
+ h=$(echo $ref | sed 's:^refs/heads/::')
+
+ # empty_tree=$(git hash-object -t tree /dev/null)
+ empty_tree=4b825dc6
+
+ id=$(echo $newrev | cut -b-7)
+ id2=$(echo $oldrev | cut -b-7)
+ if [ $newrev = $empty ]; then id=$empty_tree; fi
+ if [ $oldrev = $empty ]; then id2=$empty_tree; fi
+
+ ${if cgit_endpoint != null then /* sh */ ''
+ cgit_endpoint=${escapeShellArg cgit_endpoint}
+ case $receive_mode in
+ create)
+ link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h"
+ ;;
+ delete)
+ link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)"
+ ;;
+ fast-forward|non-fast-forward)
+ link="$cgit_endpoint/$GIT_SSH_REPO/diff/?h=$h&id=$id&id2=$id2"
+ ;;
+ esac
+ '' else /* sh */ ''
+ link="$GIT_SSH_REPO $h"
+ ''}
+
+ #$host $GIT_SSH_REPO $ref $link
+ add_message $(pink push) $link $(gray "($receive_mode)")
+
+ ${optionalString (verbose == true || typeOf verbose == "set") /* sh */ ''
+ ${optionalString (verbose.exclude or [] != []) /* sh */ ''
+ case $ref in (${concatStringsSep "|" verbose.exclude})
+ continue
+ esac
+ ''}
+ add_message "$(
+ git log \
+ --format="$(orange %h) %s $(gray '(%ar)')" \
+ --no-merges \
+ --reverse \
+ $id2..$id
+
+ git diff --stat $id2..$id \
+ | sed '$!s/\(+*\)\(-*\)$/'$(green '\1')$(red '\2')'/'
+ )"
+ echo "$(red "$message")"
+ ''}
+
+ done
+
+ if test -n "''${message-}"; then
+ exec ${pkgs.irc-announce}/bin/irc-announce \
+ "$server" \
+ "$port" \
+ "$nick" \
+ "$channel" \
+ "$tls" \
+ "$message"
+ fi
+ '';
}
-
-empty=0000000000000000000000000000000000000000
-
-while read oldrev newrev ref; do
-
- if [ $oldrev = $empty ]; then
- receive_mode=create
- elif [ $newrev = $empty ]; then
- receive_mode=delete
- elif [ "$(git merge-base $oldrev $newrev)" = $oldrev ]; then
- receive_mode=fast-forward
- else
- receive_mode=non-fast-forward
- fi
-
- h=$(echo $ref | sed 's:^refs/heads/::')
-
- empty_tree=4b825dc6
-
- id=$(echo $newrev | cut -b-7)
- id2=$(echo $oldrev | cut -b-7)
- if [ $newrev = $empty ]; then id=$empty_tree; fi
- if [ $oldrev = $empty ]; then id2=$empty_tree; fi
-
- if [ -n "''${CGIT_ENDPOINT:-}" ]; then
- case $receive_mode in
- create)
- link="$CGIT_ENDPOINT/$GIT_SSH_REPO/?h=$h"
- ;;
- delete)
- link="$CGIT_ENDPOINT/$GIT_SSH_REPO/ ($h)"
- ;;
- fast-forward|non-fast-forward)
- link="$CGIT_ENDPOINT/$GIT_SSH_REPO/diff/?h=$h&id=$id&id2=$id2"
- ;;
- esac
- else
- link="$GIT_SSH_REPO $h"
- fi
-
- add_message $(pink push) $link $(gray "($receive_mode)")
-
- if [ "''${VERBOSE:-}" = "true" ]; then
- add_message "$(
- git log \
- --format="$(orange %h) %s $(gray '(%ar)')" \
- --no-merges \
- --reverse \
- $id2..$id
-
- git diff --stat $id2..$id \
- | sed '$!s/\(+*\)\(-*\)$/'"$(green '\1')$(red '\2')"'/'
- )"
- fi
-
-done
-
-if test -n "''${message-}"; then
- tls_flag=""
- if [ "''${IRC_TLS:-}" = "true" ]; then
- tls_flag="1"
- fi
- exec ${pkgs.irc-announce}/bin/irc-announce \
- "$IRC_SERVER" \
- "$IRC_PORT" \
- "$IRC_NICK" \
- "$IRC_CHANNEL" \
- "$tls_flag" \
- "$message"
-fi
-OUTER
- chmod +x $out/bin/irc-announce-git-hook
-''
diff --git a/krebs/5pkgs/simple/gitignore.nix b/krebs/5pkgs/simple/gitignore.nix
deleted file mode 100644
index b7a9f7eb5..000000000
--- a/krebs/5pkgs/simple/gitignore.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{ pkgs, writeDash }:
-
-/* gitignore - Filter for intentionally untracked lines or blocks of code
-
-This is a filter that allows specifying intentionally untracked lines and
-blocks of code that Git should ignore.
-
-Example:
-
- int main(void) {
- printf("I would never say derp.\n");
- //#gitignore-begin
- printf("DERP!\n");
- //#gitignore-end
- printf("DERP!\n"); //#gitignore
- return 0;
- }
-
-Installation:
-
- Define a filter, e.g. in ~/.config/git/config[1]:
-
- [filter "gitignore"]
- clean = gitignore
- smudge = cat
-
- Assing that filter to some paths, e.g. in ~/.config/git/attributes[2]:
-
- *.hs filter=gitignore
- *.c filter=gitignore
- ...
-
- [1]: For more information about defining filters see git-config(1).
- [2]: For more information about assigning filters see gitattributes(5).
-*/
-
-writeDash "gitignore" ''
- exec ${pkgs.gnused}/bin/sed '
- /#gitignore-begin/,/#gitignore-end/d
- /#gitignore/d
- '
-''
diff --git a/krebs/5pkgs/simple/hashPassword/default.nix b/krebs/5pkgs/simple/hashPassword/default.nix
deleted file mode 100644
index 8d3ba2525..000000000
--- a/krebs/5pkgs/simple/hashPassword/default.nix
+++ /dev/null
@@ -1,15 +0,0 @@
-{ lib, pkgs, ... }:
-
-pkgs.writers.writeDashBin "hashPassword" ''
- # usage: hashPassword [...]
- set -euf
-
- export PATH=${lib.makeBinPath (with pkgs; [
- coreutils
- mkpasswd
- openssl
- ])}
-
- salt=$(openssl rand -base64 16 | tr -d '+=' | head -c 16)
- exec mkpasswd -m sha-512 -S "$salt" "$@"
-''
diff --git a/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur b/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur
index 696d1c00d..bdfb3eb61 100644
--- a/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur
+++ b/krebs/5pkgs/simple/htgen-imgur/src/htgen-imgur
@@ -1,3 +1,4 @@
+# TODO dedup with paste
find_item() {
if test ${#1} -ge 7; then
set -- "$(find "$STATEDIR/items" -mindepth 1 -maxdepth 1 \
@@ -58,6 +59,9 @@ read_uri() {
$uri |
capture("^((?<scheme>[^:]*):)?(//(?<authority>[^/]*))?(?<path>[^?#]*)([?](?<query>[^#]*))?([#](?<fragment>.*))?$") |
. + {
+ #authority: (.authority | if . != null then
+ # capture("^((?<userinfo>[^@]*)@)?(?<host>[^:]*)(:(?<port>.*))?$")
+ #else . end),
query: (.query | if . != null then
split("&") |
map(split("=") | {key:.[0],value:.[1]}) |
@@ -141,26 +145,26 @@ case "$Method $path" in
description: $uri.query.description,
datetime: now,
type: $info["MIME type"],
- animated: false,
+ animated: false, # TODO
width: $info.width,
height: $info.height,
size: $info.size,
- views: 0,
- bandwidth: 0,
- vote: null,
- favorite: false,
- nsfw: null,
- section: null,
- account_url: null,
- acount_id: 0,
- is_ad: false,
- is_most_viral: false,
- tags: [],
- ad_type: 0,
- ad_url: "",
- in_gallery: false,
+ views: 0, # TODO
+ bandwidth: 0, # TODO
+ vote: null, # TODO
+ favorite: false, # TODO
+ nsfw: null, # TODO
+ section: null, # TODO
+ account_url: null, # TODO
+ acount_id: 0, # TODO
+ is_ad: false, # TODO
+ is_most_viral: false, # TODO
+ tags: [], # TODO
+ ad_type: 0, # TODO
+ ad_url: "", # TODO
+ in_gallery: false, # TODO
deletehash: @uri "\($id)?deletehash=\($deletehash)",
- name: "",
+ name: "", # TODO
link: $link,
}
')
diff --git a/krebs/5pkgs/simple/htgen/default.nix b/krebs/5pkgs/simple/htgen/default.nix
index 1ee13783b..945801bfe 100644
--- a/krebs/5pkgs/simple/htgen/default.nix
+++ b/krebs/5pkgs/simple/htgen/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/bin
{
- echo '#! ${pkgs.dash}/bin/dash'
+ echo '#! ${pkgs.busybox}/bin/sh'
echo 'export PATH=${lib.makeBinPath [
pkgs.coreutils
pkgs.jq
diff --git a/krebs/5pkgs/simple/logf/default.nix b/krebs/5pkgs/simple/logf/default.nix
deleted file mode 100644
index 3a4c84de2..000000000
--- a/krebs/5pkgs/simple/logf/default.nix
+++ /dev/null
@@ -1,112 +0,0 @@
-{ lib, pkgs, writeDash, writeDashBin, writeJSON, writeJq, ... }:
-
-let
- default-host-colors = writeJSON "logf.default-host-colors.json" {
- };
- default-prio-colors = writeJSON "logf.default-prio-colors.json" {
- "0" = 196; # emerg
- "1" = 160; # alert
- "2" = 124; # crit
- "3" = 009; # err
- "4" = 011; # warning
- "5" = 255; # notice
- "6" = 250; # info
- "7" = 139; # debug
- "-" = 005; # undefined priority
- };
- default-urgent = writeJSON "logf.default-urgent.json" [
- ];
-in
-
-writeDashBin "logf" ''
- export LOGF_HOST_COLORS LOGF_PRIO_COLORS LOGF_URGENT
- LOGF_HOST_COLORS=$(cat "''${LOGF_HOST_COLORS-${default-host-colors}}")
- LOGF_PRIO_COLORS=$(cat "''${LOGF_PRIO_COLORS-${default-prio-colors}}")
- LOGF_URGENT=$(cat "''${LOGF_URGENT-${default-urgent}}")
- printf '%s\0' "$@" \
- | ${pkgs.findutils}/bin/xargs -0 -P 0 -n 1 ${writeDash "logf-remote" ''
- target=$1
- target_host=$(echo "$1" | sed 's/^.*@//;s/\..*//')
- exec 3>&1
- 2>&1 1>&3 ssh "$target" -T \
- -o PreferredAuthentications=publickey \
- -o StrictHostKeyChecking=yes \
- exec journalctl -af -n 0 -o json \
- | stdbuf -oL jq -Rcf ${writeJq "logf-remote-error.jq" ''
- {
- PRIORITY: "4",
- MESSAGE: .,
- SYSLOG_IDENTIFIER: env.target_host,
- }
- ''}
- sleep 10m
- exec "$0" "$@"
- ''} \
- | ${pkgs.jq}/bin/jq -Rrf ${writeJq "logf-filter.jq" ''
- (env.LOGF_HOST_COLORS | fromjson) as $host_colors |
- (env.LOGF_PRIO_COLORS | fromjson) as $prio_colors |
- (env.LOGF_URGENT | fromjson | map("(\(.))") | join("|"))
- as $urgent_regex |
-
- def when(c; f): if c then f else . end;
-
- # anaphoric gsub
- def agsub(re; f):
- # Don't try empty regex: https://github.com/stedolan/jq/issues/1206
- when(re != ""; gsub("(?<it>\(re))"; .it | f));
-
- # :: [int] -> sgr
- def sgr: "\u001b[\(map(tostring) | join(";"))m";
-
- # :: sgr
- def rst: [] | sgr;
-
- # :: int -> sgr
- def fg(i): [38,5,i]|sgr;
- # TODO def fg(r;g;b): [38,2,r,g,b]|sgr;
- # http://cvs.schmorp.de/rxvt-unicode/src/command.C?revision=1.570&view=markup&sortby=log&sortdir=down
-
- # (sgr; sgr) | (null; any) :: str -> str
- def col(a; b): when(a != null; a + . + b);
- def col(a): col(a; rst);
-
-
- def p_time:
- ._SOURCE_REALTIME_TIMESTAMP
- | if . != null then . | fromjson | . / 1000000 else now end
- | gmtime
- | todateiso8601
- | col(fg(237));
-
- def p_host:
- ._HOSTNAME
- | if . != null then . else "-" end
- | col($host_colors[.]|when(. != null; fg(.)));
-
- def p_ident:
- if .SYSLOG_IDENTIFIER != null then .SYSLOG_IDENTIFIER
- else ._COMM end
- | col(fg(244));
-
- def p_message:
- fg($prio_colors[if has("PRIORITY") then .PRIORITY else "-" end])
- as $prio_c |
- .MESSAGE
- | sub("\r$"; "")
- | agsub($urgent_regex; "\(.)\u0007" | col(fg(219); $prio_c))
- | col($prio_c);
-
- try fromjson catch {
- _SOURCE_REALTIME_TIMESTAMP: now | tostring | sub("[.]