1
0
mirror of https://github.com/kmein/niveum synced 2026-03-22 12:51:08 +01:00

Use nix-writers from nixpkgs

This commit is contained in:
Kierán Meinhardt
2018-12-04 21:07:13 +01:00
parent 1aba50b398
commit d72e037039
3 changed files with 20 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
let let
spotify_info = pkgs.writeBash "spotify.info" '' spotify_info = pkgs.writers.writeBash "spotify.info" ''
if $(pgrep spotify); then if $(pgrep spotify); then
STATUS=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$) STATUS=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$)
@@ -26,7 +26,7 @@ let
printf "%s \u2237 %s" "$ARTIST" "$TITLE" printf "%s \u2237 %s" "$ARTIST" "$TITLE"
fi fi
''; '';
battery_info = pkgs.writeBash "battery.info" '' battery_info = pkgs.writers.writeBash "battery.info" ''
BAT_DIR="/sys/class/power_supply/$BLOCK_INSTANCE/" BAT_DIR="/sys/class/power_supply/$BLOCK_INSTANCE/"
if [ -d "$BAT_DIR" ]; then if [ -d "$BAT_DIR" ]; then
cd "$BAT_DIR" cd "$BAT_DIR"
@@ -91,7 +91,7 @@ let
fi fi
fi fi
''; '';
volume_info = pkgs.writeBash "volume.info" '' volume_info = pkgs.writers.writeBash "volume.info" ''
if [[ "$BLOCK_BUTTON" == 1 ]]; then if [[ "$BLOCK_BUTTON" == 1 ]]; then
${pkgs.pamixer}/bin/pamixer -i 5 ${pkgs.pamixer}/bin/pamixer -i 5
elif [[ "$BLOCK_BUTTON" == 3 ]]; then elif [[ "$BLOCK_BUTTON" == 3 ]]; then
@@ -107,7 +107,7 @@ let
printf '\uf028 %s%%' "$volume" printf '\uf028 %s%%' "$volume"
fi fi
''; '';
fancyDate = pkgs.writeC "fancy_date.c" {} '' fancyDate = pkgs.writers.writeC "fancy_date.c" {} ''
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <wchar.h> #include <wchar.h>

View File

@@ -1,14 +1,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
with pkgs; with pkgs;
{ {
nixpkgs.config = { nixpkgs.config.allowUnfree = true;
allowUnfree = true;
packageOverrides =
let nix-writers = builtins.fetchGit {
url = https://cgit.krebsco.de/nix-writers/;
rev = "0660cc1a1169e799bda356c6fadb245a96345816";
}; in import "${nix-writers}/pkgs" pkgs;
};
fonts.enableDefaultFonts = true; fonts.enableDefaultFonts = true;
fonts.fonts = [ fonts.fonts = [

View File

@@ -1,6 +1,6 @@
{ pkgs }: { pkgs }:
let let
bingWallpaper = pkgs.writeBash "bing-wallpaper.sh" '' bingWallpaper = pkgs.writers.writeBash "bing-wallpaper.sh" ''
PICTURE_DIR="$HOME/pictures/external/bing/" PICTURE_DIR="$HOME/pictures/external/bing/"
mkdir -p $PICTURE_DIR mkdir -p $PICTURE_DIR
@@ -17,7 +17,7 @@ let
fi fi
done done
''; '';
colorize = pkgs.writeDash "colorize.sh" '' colorize = pkgs.writers.writeDash "colorize.sh" ''
highlight=$(which highlight 2>/dev/null) highlight=$(which highlight 2>/dev/null)
pygmentize=$(which pygmentize 2>/dev/null) pygmentize=$(which pygmentize 2>/dev/null)
@@ -40,7 +40,7 @@ let
cat "$2" | colorize "$1" cat "$2" | colorize "$1"
fi fi
''; '';
easyBackup = pkgs.writeDash "easy-backup.sh" '' easyBackup = pkgs.writers.writeDash "easy-backup.sh" ''
if [ -d "$1" ]; then if [ -d "$1" ]; then
OUTPUT_ROOT=''${1}/backup/current OUTPUT_ROOT=''${1}/backup/current
rsync -hav --delete --stats --progress --exclude-from=$HOME/bin/backup.exclude $HOME/* $OUTPUT_ROOT/ rsync -hav --delete --stats --progress --exclude-from=$HOME/bin/backup.exclude $HOME/* $OUTPUT_ROOT/
@@ -49,7 +49,7 @@ let
exit 1 exit 1
fi fi
''; '';
compile = pkgs.writeBash "compile.sh" '' compile = pkgs.writers.writeBash "compile.sh" ''
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "Usage: compile <source file>" echo "Usage: compile <source file>"
fi fi
@@ -149,7 +149,7 @@ let
echo Compiler for "$ext" not found!;; echo Compiler for "$ext" not found!;;
esac esac
''; '';
gitPullAll = pkgs.writeDash "git-pull-all.sh" '' gitPullAll = pkgs.writers.writeDash "git-pull-all.sh" ''
# store the current dir # store the current dir
CUR_DIR=$(pwd) CUR_DIR=$(pwd)
# Let the person running the script know what's going on. # Let the person running the script know what's going on.
@@ -168,8 +168,8 @@ let
done done
echo -e "\n\033[32mComplete!\033[0m\n" echo -e "\n\033[32mComplete!\033[0m\n"
''; '';
gripe = pkgs.writeBash "gripe.sh" ''${sidepipe} '(:\d+:|-\d+-|--)(\x1b[[]K)?' "$@"''; gripe = pkgs.writers.writeBash "gripe.sh" ''${sidepipe} '(:\d+:|-\d+-|--)(\x1b[[]K)?' "$@"'';
haskellDefinition = pkgs.writeBash "hdef.sh" '' haskellDefinition = pkgs.writers.writeBash "hdef.sh" ''
paths="" paths=""
while true; do while true; do
if [ -d "$1" ]; then if [ -d "$1" ]; then
@@ -193,7 +193,7 @@ let
${haskellFind} $paths -print0 | xargs -0 grep -En --colour=never -A10 "$@" "^$expr" | ${gripe} hcol | ${highlight} $str ${haskellFind} $paths -print0 | xargs -0 grep -En --colour=never -A10 "$@" "^$expr" | ${gripe} hcol | ${highlight} $str
''; '';
haskellFind = pkgs.writeDash "hfind.sh" '' haskellFind = pkgs.writers.writeDash "hfind.sh" ''
paths="" paths=""
while true; do while true; do
if [ -d "$1" ]; then if [ -d "$1" ]; then
@@ -205,7 +205,7 @@ let
done done
find $paths \( -name "*.hs" -or -name "*.hsi" -or -name "*.lhs" -or -name "*.hs-boot" \) -a -not \( -name ".*" -or -path "*/_darcs/*" -o -name '.£*' \) "$@" find $paths \( -name "*.hs" -or -name "*.hsi" -or -name "*.lhs" -or -name "*.hs-boot" \) -a -not \( -name ".*" -or -path "*/_darcs/*" -o -name '.£*' \) "$@"
''; '';
haskellGrep = pkgs.writeDash "hgrep.sh" '' haskellGrep = pkgs.writers.writeDash "hgrep.sh" ''
if [ -z "$1" -o "$1" == "--help" -o "$1" == "-h" ]; then if [ -z "$1" -o "$1" == "--help" -o "$1" == "-h" ]; then
echo "Usage: hg [PATH] IDENTIFIER [GREP OPTIONS...]" echo "Usage: hg [PATH] IDENTIFIER [GREP OPTIONS...]"
echo "Seaches for uses of the given Haskell identifier." echo "Seaches for uses of the given Haskell identifier."
@@ -228,8 +228,8 @@ let
fi fi
${haskellFind} $paths -print0 | xargs -0 grep -nw --colour=$colour "$@" ${haskellFind} $paths -print0 | xargs -0 grep -nw --colour=$colour "$@"
''; '';
highlight = pkgs.writePython3 "hl.py" { highlight = pkgs.writers.writePython3 "hl.py" {
deps = [ pkgs.python36Packages.ansicolors ]; libraries = [ pkgs.python36Packages.ansicolors ];
flakeIgnore = [ "E302" "E999" "E231" "E701" "W605" "E231" "E305" ]; flakeIgnore = [ "E302" "E999" "E231" "E701" "W605" "E231" "E305" ];
} '' } ''
import os import os
@@ -278,7 +278,7 @@ let
for line in sys.stdin: for line in sys.stdin:
sys.stdout.write(reduce(lambda s, f: f(s), hlfuns, line)) sys.stdout.write(reduce(lambda s, f: f(s), hlfuns, line))
''; '';
haskellTags = pkgs.writeDash "htags.sh" '' haskellTags = pkgs.writers.writeDash "htags.sh" ''
id="[a-z_][a-zA-Z0-9_\']*" id="[a-z_][a-zA-Z0-9_\']*"
ws="[ \\t]" ws="[ \\t]"
ID="[A-Z][a-zA-Z0-9_\']*" ID="[A-Z][a-zA-Z0-9_\']*"
@@ -293,7 +293,7 @@ let
"--regex-haskell=/^($id)/\1/" \ "--regex-haskell=/^($id)/\1/" \
"$@" "$@"
''; '';
sidepipe = pkgs.writePython3 "sidepipe.py" { flakeIgnore = [ "E302" "E231" "E999" "E265" "E305" ]; } '' sidepipe = pkgs.writers.writePython3 "sidepipe.py" { flakeIgnore = [ "E302" "E231" "E999" "E265" "E305" ]; } ''
import sys import sys
import re import re
import os.path import os.path
@@ -357,7 +357,7 @@ let
t2.start() t2.start()
t2.join() t2.join()
''; '';
spotifyCli = pkgs.writeBash "sp.sh" '' spotifyCli = pkgs.writers.writeBash "sp.sh" ''
# This is sp, the command-line Spotify controller. It talks to a running # This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not # instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc. # unlike mpc.
@@ -628,7 +628,7 @@ let
fi fi
fi fi
''; '';
spotifyGenius = pkgs.writeBash "spgenius.sh" '' spotifyGenius = pkgs.writers.writeBash "spgenius.sh" ''
function normalise { function normalise {
echo ''${1// /-} echo ''${1// /-}
} }