1
0
mirror of https://github.com/kmein/niveum synced 2026-03-17 18:41:09 +01:00

fix(packages): move to overlays

This commit is contained in:
Kierán Meinhardt
2019-11-09 16:33:59 +01:00
parent e296de9ed1
commit d6dd9f82c4
25 changed files with 55 additions and 93 deletions

View File

@@ -0,0 +1,7 @@
{ writeShellScriptBin, w3m, gnused }:
writeShellScriptBin "autorenkalender" ''
${w3m}/bin/w3m -dump https://gutenberg.spiegel.de/ \
| ${gnused}/bin/sed -n '/Autorenkalender/,//p' \
| head -n -2 \
| tail -n +3
''

24
packages/scripts/bvg.nix Normal file
View File

@@ -0,0 +1,24 @@
{ ruby, stdenv, bundlerEnv, fetchFromGitHub }:
let
src = fetchFromGitHub {
owner = "kmein";
repo = "bvg";
rev = "bbfea2e0fdc91a37a34f581c4623704297275b47";
sha256 = "1iyghksyiy4xkyjw10a7qhy796p88gm9ll6wr7iq55xg98w9mya4";
};
env = bundlerEnv {
name = "bvg-env";
inherit ruby;
gemfile = "${src.out}/Gemfile";
lockfile = "${src.out}/Gemfile.lock";
gemset = "${src.out}/gemset.nix";
};
in stdenv.mkDerivation {
name = "bvg";
buildInputs = [ env.wrappedRuby ];
script = "${src.out}/bvg.rb";
buildCommand = ''
install -D -m755 $script $out/bin/bvg
patchShebangs $out/bin/bvg
'';
}

View File

@@ -0,0 +1,27 @@
{ stdenv, makeWrapper, pandoc, fetchFromGitHub }:
stdenv.mkDerivation {
name = "daybook";
src = fetchFromGitHub {
owner = "kmein";
repo = "daybook";
rev = "cad1aef158b0df36861434eb04c953d99a122e80";
sha256 = "07qippyry0yjf971pnqxm9i0xpvih8mvbhxwfwpwq980jik1hbl1";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ pandoc ];
buildPhase = ''
mkdir -p $out/man/man1
pandoc --standalone --to man daybook.1.md -o $out/man/man1/daybook.1
'';
installPhase = ''
mkdir -p $out/bin
install daybook $out/bin
wrapProgram $out/bin/daybook --prefix PATH ":" ${pandoc}/bin ;
'';
meta = with stdenv.lib; {
homepage = https://github.com/kmein/daybook;
description = "A diary writing utility in sh";
license = licenses.mit;
platforms = platforms.linux;
};
}

View File

@@ -0,0 +1,34 @@
{ pkgs, ... }:
{
autorenkalender = pkgs.callPackage ./autorenkalender.nix {};
bvg = pkgs.callPackage ./bvg.nix {};
daybook = pkgs.callPackage ./daybook.nix {};
depp = pkgs.callPackage ./depp.nix {};
dirmir = pkgs.callPackage ./dirmir.nix {};
favicon = pkgs.callPackage ./favicon.nix {};
genius = pkgs.callPackage ./genius.nix {};
instaget = pkgs.callPackage ./instaget.nix {};
literature-quote = pkgs.callPackage ./literature-quote.nix {};
man-pdf = pkgs.callPackage ./man-pdf.nix {};
n = pkgs.callPackage ./n.nix {};
nav = pkgs.callPackage ./nav.nix {};
odyssey = pkgs.callPackage ./odyssey.nix {};
tolino-screensaver = pkgs.callPackage ./tolino-screensaver.nix {};
wttr = pkgs.callPackage ./wttr.nix {};
slide =
let slide-package = pkgs.fetchFromGitHub {
owner = "kmein";
repo = "slide";
rev = "0470583d22212745eab4f46076267addf4d2346c";
sha256 = "0skcp3va9v4hmxy5ramghpz53gnyxv10wsacgmc2jr0v1wrqlzbh";
};
in pkgs.callPackage slide-package {};
mnemosyne =
let mnemosyne-package = pkgs.fetchFromGitHub {
repo = "mnemosyne";
owner = "kmein";
rev = "6bfa13c88db176af80be90840ff03573d67d679f";
sha256 = "1rimv5c5q9602y501hbkgkfbimqnmdkcr5hp1434q06gcazhjhca";
};
in pkgs.haskellPackages.callPackage mnemosyne-package {};
}

29
packages/scripts/depp.nix Normal file
View File

@@ -0,0 +1,29 @@
{ lib, writeShellScriptBin }:
let
aliasFlag = name: value: "-c alias.${name}=${lib.escapeShellArg value}";
aliases = {
eroeffne = "init";
machnach = "clone";
zieh = "pull";
fueghinzu = "add";
drueck = "push";
pfusch = "push --force";
zweig = "branch";
verzweige = "branch";
uebergib = "commit";
erde = "rebase";
unterscheide = "diff";
vereinige = "merge";
bunkere = "stash";
markiere = "tag";
nimm = "checkout";
tagebuch = "log";
zustand = "status";
};
in writeShellScriptBin "depp" ''
if [ $# -gt 0 ]; then
git ${lib.concatStringsSep " " (lib.attrsets.mapAttrsToList aliasFlag aliases)} "$@"
else
printf "${lib.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: n + " " + v) aliases)}\n"
fi
''

View File

@@ -0,0 +1,27 @@
{ writers, coreutils, findutils }:
let name = "dirmir";
in writers.writeDashBin name ''
export PATH=$PATH:${coreutils}/bin:${findutils}/bin
SOURCE="$1"
TARGET="$2"
if [ ! -d "$SOURCE" ] || [ $# -ne 2 ]; then
echo >/dev/stderr "Usage: ${name} SOURCE TARGET"
exit 1
fi
if [ -e "$TARGET" ]; then
echo >/dev/stderr "$TARGET" already exists. Please use a different name.
exit 1
fi
for entry in $(find "$SOURCE"); do
if [ -d "$entry" ]; then
mkdir -p "$TARGET/$entry"
else
# create a file with the same permissions as $entry
install -m "$(stat -c %a "$entry")" /dev/null "$TARGET/$entry"
fi
done
''

View File

@@ -0,0 +1,4 @@
{ imagemagick, writers }:
writers.writeDashBin "favicon" ''
${imagemagick}/bin/convert "$1" -define icon:auto-resize=64,48,32,16 "''${2-favicon.ico}"
''

View File

@@ -0,0 +1,22 @@
{ writeShellScriptBin, gnused, curl, pandoc }:
writeShellScriptBin "genius" ''
test $# -eq 2 || (
echo "usage: $0 <artist> <song>"
exit 1
)
normalize() {
tr -d -c '0-9A-Za-z ' | tr ' ' - | tr '[:upper:]' '[:lower:]'
}
ARTIST=$(echo "$1" | normalize | ${gnused}/bin/sed 's/./\U&/')
TITLE=$(echo "$2" | normalize)
GENIUS_URL="https://genius.com/$ARTIST-$TITLE-lyrics"
${curl}/bin/curl -s "$GENIUS_URL" \
| ${gnused}/bin/sed -ne '/class="lyrics"/,/<\/p>/p' \
| ${pandoc}/bin/pandoc -f html -s -t plain \
| ${gnused}/bin/sed 's/^_/\x1b[3m/g;s/_$/\x1b[0m/g;s/^\[/\n\x1b\[1m\[/g;s/\]$/\]\x1b[0m/g'
printf "\n(source: $GENIUS_URL)\n" >/dev/stderr
''

View File

@@ -0,0 +1,13 @@
{ writeShellScriptBin, wget, curl, jq }:
writeShellScriptBin "instaget" ''
for url in "$@"; do
${curl}/bin/curl -s "$url" \
| grep display_url \
| grep -o '{.*}' \
| ${jq}/bin/jq -r '
.entry_data.PostPage
| .[].graphql.shortcode_media.edge_sidecar_to_children.edges
| .[].node.display_url' \
| xargs ${wget}/bin/wget
done
''

View File

@@ -0,0 +1,12 @@
{ writeShellScriptBin, curl, xsv, gnused }:
writeShellScriptBin "literature-quote" ''
ROW=$(${curl}/bin/curl -Ls http://kmein.github.io/quotes/quotes.csv | shuf -n1)
(
printf '%s\n(%s: _%s_, %s)\n' \
"$(echo "$ROW" | ${xsv}/bin/xsv select 4)" \
"$(echo "$ROW" | ${xsv}/bin/xsv select 1)" \
"$(echo "$ROW" | ${xsv}/bin/xsv select 2)" \
"$(echo "$ROW" | ${xsv}/bin/xsv select 3 | tr : ,)"
) | ${gnused}/bin/sed 's/ | /\n/g;s/ || /\n\n/g;s/"\(.*\)"/\1/'
''

View File

@@ -0,0 +1,17 @@
{ writeShellScriptBin, ghostscript, man }:
let
name = "man-pdf";
in writeShellScriptBin name ''
if [ $# -eq 1 ]; then
man_entry="$1"
elif [ $# -eq 2 ]; then
man_page="$1"
man_entry="$2"
else
echo >/dev/stderr "Usage: ${name} [MAN-PAGE] ENTRY"
exit 1
fi
echo "${man}/bin/man "''${man_page:-}" "$man_entry" | ${ghostscript}/bin/ps2pdf - "$man_entry.pdf""
${man}/bin/man "''${man_page:-}" "$man_entry" | ${ghostscript}/bin/ps2pdf - "$man_entry.pdf"
''

2
packages/scripts/n.nix Normal file
View File

@@ -0,0 +1,2 @@
{ writeShellScriptBin }:
writeShellScriptBin "n" ''nix-shell -p "$1" --run "''${2:-$1}"''

21
packages/scripts/nav.nix Normal file
View File

@@ -0,0 +1,21 @@
{ fetchFromGitHub, stdenv, fzf }:
stdenv.mkDerivation rec {
name = "nav";
version = "8da22b1";
src = fetchFromGitHub {
owner = "huntrar";
repo = name;
rev = version;
sha256 = "0aw10495901dagyfxn2pj6nh3nl1xgi5p57mwgkgn9g5hi66xa87";
};
installPhase = ''
mkdir -p $out/bin/
install nav $out/bin/
'';
propagatedBuildInputs = [ fzf ];
meta = {
maintainer = [ stdenv.lib.maintainers.kmein ];
description = "JSON data structure navigator";
homepage = "https://github.com/huntrar/nav";
};
}

View File

@@ -0,0 +1,11 @@
{ xmlstarlet, curl, writeShellScriptBin }:
writeShellScriptBin "odyssey" ''
if [ $# -eq 1 ] && (echo "$1" | grep -Eq '[0-9]+\.[0-9]+'); then
${curl}/bin/curl -Gs http://www.perseus.tufts.edu/hopper/CTS \
-d request=GetPassage \
-d "urn=urn:cts:greekLit:tlg0012.tlg002:$1" \
| ${xmlstarlet}/bin/xmlstarlet sel -t -v 'cts:GetPassage//tei:div'
else
echo you must supply BOOK.VERSE
fi
''

View File

@@ -0,0 +1,11 @@
{ writers, imagemagick }:
writers.writeDashBin "tolino-screensaver" ''
source_image="$1"
if [ -e "$source_image" ]; then
${imagemagick}/bin/convert -type Grayscale -resize 758x1024 "$source_image" "suspend.jpg"
else
echo >/dev/stderr "$1 must exist."
exit 1
fi
''

View File

@@ -0,0 +1,4 @@
{ writeShellScriptBin, curl }:
writeShellScriptBin "wttr" ''
${curl}/bin/curl -s -H "Accept-Language: ''${LANG%_*}" --compressed "wttr.in/''${1-}?0"
''