1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00

MASSIVE restructuring

This commit is contained in:
Kierán Meinhardt
2019-01-30 10:58:34 +01:00
parent bc05f2e736
commit b94da2d550
23 changed files with 504 additions and 418 deletions

139
configs/base/default.nix Normal file
View File

@@ -0,0 +1,139 @@
{ config, pkgs, ... }:
{
imports = [
"${builtins.fetchTarball https://github.com/rycee/home-manager/archive/master.tar.gz}/nixos"
./editors.nix
./networks.nix
./scripts.nix
./shells.nix
../../options.nix
];
time.timeZone = "Europe/Berlin";
sound.enable = true;
hardware.pulseaudio = {
enable = true;
package = pkgs.pulseaudioFull; # for bluetooth sound output
};
hardware.bluetooth = {
enable = true;
extraConfig = ''
[General]
Enable=Source,Sink,Media,Socket
'';
};
i18n = {
defaultLocale = "en_GB.UTF-8";
consoleKeyMap = "de";
# consoleColors = with import ../theme.nix; map (c: lib.strings.removePrefix "#" c) colorPalette;
};
services.printing = {
enable = true;
drivers = [ pkgs.hplipWithPlugin ];
};
security.sudo = {
enable = true;
extraConfig = ''
Defaults pwfeedback
'';
};
users.mutableUsers = false;
users.users.kfm = {
name = "kfm";
description = config.constants.user.name;
home = "/home/kfm";
createHome = true;
group = "users";
extraGroups = [ "wheel" "audio" ];
hashedPassword = "$6$w9hXyGFl/.IZBXk$5OiWzS1G.5hImhh1YQmZiCXYNAJhi3X6Y3uSLupJNYYXPLMsQpx2fwF4Xr2uYzGMV8Foqh8TgUavx1APD9rcb/";
shell = pkgs.zsh;
};
home-manager.users.kfm = {
programs.git = {
enable = true;
userName = config.constants.user.name;
userEmail = config.constants.user.email;
aliases = {
br = "branch";
co = "checkout";
ci = "commit";
amend = "commit --amend";
st = "status";
unstage = "reset HEAD --";
sdiff = "diff --staged";
last = "log -1 HEAD";
pull-all = "!pull-all"; # from dot/scripts.nix
};
ignores = config.constants.ignore;
};
home.file = {
".config/htop/htoprc".text = import ../../dot/htop.nix;
".zshrc".text = "# nothing to see here";
};
};
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
] ++ [ # internet
aria2
w3m
wget
curl
httpie
whois
] ++ [ # media
imagemagick
] ++ [ # archive
unzip
unrar
p7zip
zip
] ++ [ # monitor
htop
iotop
iftop
lsof
psmisc
] ++ [ # shell
bat
dos2unix
fd
file
git
gitAndTools.hub
gitstats
jo
jq
manpages
patch
patchutils
posix_man_pages
most
ranger
ripgrep
rlwrap
tree
] ++ [ # hardware
pmount
usbutils
pciutils
];
programs.command-not-found.enable = true;
programs.java = {
enable = true;
package = pkgs.openjdk;
};
}

View File

@@ -1,5 +1,4 @@
{ pkgs, config, ... }:
with import ../helpers.nix;
let vim_conf = ''
" if tabular
vmap a= :Tabularize /=<CR>
@@ -16,7 +15,7 @@ let vim_conf = ''
set number
set path=$PWD/**
set completeopt=menu,longest
set wildmode=list:full wildignore+=${commaSep config.constants.ignore}
set wildmode=list:full wildignore+=${builtins.concatStringsSep "," config.constants.ignore}
set shortmess+=aI
set nowritebackup noswapfile
set mouse=a

57
configs/base/networks.nix Normal file
View File

@@ -0,0 +1,57 @@
{ pkgs, config, lib, ... }:
let
sshPort = 22022;
sshKey = {
homeros = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDn13Y6CznabMvKJPIrr/dj1TX4boe8F98yc3FDElJeprQo2RXlDzjg/po9/lHTHaoC5yQUjlRg/AnI4vizYkn2sqJebAeSPahmpS+l0eFnjZgsqds2cCFqSPB6Qc5YEkGRhN4aq/ABz0jdFJLBYOYGxuuXowYxyNrqrItxDR7tF7upG+kVjYiDoP/qFm8C7zv6Zy8aoehNbzf8HlIJd0ITbMr/vUftNsQ8C84QmbZljReHmchPgE8GUfVLTlCORkhndbvNX3jXo+75y7JOIZZ6193FZHM4seg/VSDWYLJtpnhttD1w6qmiLrlimqbJB9ihoXq2eDmQ+4zo6hxQ6pFH6P0xQClJ0hxVWn6hEM3rkMwoMfbq4v54gKJsYxcGdnwjAX6d9DQv/QVjmVZffKWsGGoC7uz7bdmc0akVKi+GLSPOx8sJwXqvyvFStfqLaweVcuikUqQ72JLK7pZyliA7na6KuQ1PE3LTpfSr0lbBJ73xtS2rU1nF/Oe5zwA4LX5s/QeDVmS86D8acUrSCO62pBB3Yv8go0KR4mEvfxLiUWV6gR2uTeIPXvo4ouYFZqyABAGybjUATlGCXJaeHd/y/VWkpIB8ocqNESlRMCEe4TrYjw91AEmYBL6kWIeop3dyhovm3dTB3fQvC97kbL16wuXBrOcN4lEc+56ShhmvdQ== kieran.meinhardt@gmail.com";
scardanelli = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC19H0FhSNWcfBRPKzbTVSMJikIWZl0CoM8zCm+/3fdMgoaLRpeZWe/AfDK6b4qOjk/sez/J0JUFCGr+JbMwjsduoazsuQowu9L9DLP9Q5UkJje4BD7MHznaeu9/XfVng/MvyaEWArA/VUJeKQesHe76tR511/+n3+bdzlIh8Zw/3wfFxmg1OTNA99/vLkXrQzHDTuV/yj1pxykL4xFtN0OIssW1IKncJeKtkO/OHGT55ypz52Daj6bNKqvxiTuzeEhv5M+5ppyIPcRf1uj/7IaPKttCgZAntEqBTIR9MbyXFeAZVayzaFnLl2okeam5XreeZbj+Y1h2ZjxiIuWoab3MLndSekVfLtfa63gtcWIf8CIvZO2wJoH8v73y0U78JsfWVaTM09ZCfFlHHA/bWqZ6laAjW+mWLO/c77DcYkB3IBzaMVNfc6mfTcGFIC+biWeYpKgA0zC6rByUPbmbIoMueP9zqJwqUaM90Nwd6559inBB107/BK3Ktb3b+37mMCstetIPB9e4EFpGMjhmnL/G81jS53ACWLXJYzt7mKU/fEsiW93MtaB+Le46OEC18y/4G8F7p/nnH7i0kO74ukxbnc4PlpiM7iWT6ra2Cyy+nzEgdXCNXywIxr05TbCQDwX6/NY8k7Hokgdfyz+1Pq3sX0yCcWRPaoB26YF12KYFQ== kieran.meinhardt@gmail.com";
};
in {
networking.hosts = lib.mapAttrs (_: value: [ (value + ".local") ]) {
"192.168.178.1" = "router";
"192.168.178.21" = "scardanelli";
"192.168.178.22" = "homeros";
"192.168.178.24" = "catullus";
"192.168.178.27" = "printer";
};
home-manager.users.kfm = {
programs.ssh = {
enable = true;
matchBlocks = {
catullus = {
hostname = "catullus.local";
user = "kfm";
port = sshPort;
};
scardanelli = {
hostname = "scardanelli.local";
user = "kfm";
port = sshPort;
};
homeros = {
hostname = "homeros.local";
user = "kfm";
port = sshPort;
};
};
};
};
programs.ssh = {
startAgent = true;
forwardX11 = true;
};
services.openssh = {
ports = [ sshPort ];
enable = true;
forwardX11 = true;
passwordAuthentication = false;
};
users.users.kfm.openssh.authorizedKeys.keys = [
sshKey.homeros
sshKey.scardanelli
];
}

501
configs/base/scripts.nix Normal file
View File

@@ -0,0 +1,501 @@
{ pkgs, lib, ... }:
let
theme = import ../../theme.nix;
unstable = import <nixos-unstable> {};
bingWallpaper = unstable.writers.writeBash "bing-wallpaper.sh" ''
PICTURE_DIR="$HOME/pictures/external/bing/"
mkdir -p $PICTURE_DIR
urls=( $(${pkgs.curl}/bin/curl -s http://www.bing.com \
| grep -Eo "url:'.*?'" \
| sed -e "s/url:'\([^']*\)'.*/http:\/\/bing.com\1/" \
| sed -e "s/\\\//g") )
for p in ''${urls[@]}; do
filename=$(echo $p | sed -e "s/.*\/\(.*\)/\1/")
if [ ! -f $PICTURE_DIR/$filename ]; then
${pkgs.curl}/bin/curl -Lo "$PICTURE_DIR/$filename" $p
fi
done
'';
scripts.easy-backup = unstable.writers.writeDash "easy-backup" ''
if [ -d "$1" ]; then
OUTPUT_ROOT=''${1}/backup/current
rsync -hav --delete --stats --progress --exclude-from=$HOME/bin/backup.exclude $HOME/* $OUTPUT_ROOT/
else
echo "No backup directory supplied"
exit 1
fi
'';
scripts.pull-all = unstable.writers.writeDashBin "pull-all" ''
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo -e "\033[33m"+$i+"\033[0m";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# finally pull
git pull origin master;
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo -e "\n\033[32mComplete!\033[0m\n"
'';
scripts.sp = unstable.writers.writeBashBin "sp" ''
# 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
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#
# As an added bonus, it also works with ssh, at and cron.
#
# Example:
# $ sp weather girls raining men
# $ sp current
# Album 100 Hits Of The '80s
# Artist The Weather Girls
# Title It's Raining Men
# $ sp pause
#
# Alarm clock example:
# $ at 7:45 <<< 'sp bangarang'
#
# Remote example:
# $ ssh vader@prod02.nomoon.ta 'sp imperial march'
#
#
# Copyright (C) 2013 Wander Nauta
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software, to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# The software is provided "as is", without warranty of any kind, express or
# implied, including but not limited to the warranties of merchantability,
# fitness for a particular purpose and noninfringement. In no event shall the
# authors or copyright holders be liable for any claim, damages or other
# liability, whether in an action of contract, tort or otherwise, arising from,
# out of or in connection with the software or the use or other dealings in the
# software.
#
# CONSTANTS
SP_VERSION="0.1"
SP_DEST="org.mpris.MediaPlayer2.spotify"
SP_PATH="/org/mpris/MediaPlayer2"
SP_MEMB="org.mpris.MediaPlayer2.Player"
# SHELL OPTIONS
shopt -s expand_aliases
# UTILITY FUNCTIONS
function require {
hash $1 2>/dev/null || {
echo >&2 "Error: '$1' is required, but was not found."; exit 1;
}
}
# COMMON REQUIRED BINARIES
# We need dbus-send to talk to Spotify.
require dbus-send
# Assert standard Unix utilities are available.
require grep
require sed
require cut
require tr
# 'SPECIAL' (NON-DBUS-ALIAS) COMMANDS
function sp-dbus {
# Sends the given method to Spotify over dbus.
dbus-send --print-reply --dest=$SP_DEST $SP_PATH $SP_MEMB.$1 ''${*:2} > /dev/null
}
function sp-open {
# Opens the given spotify: URI in Spotify.
sp-dbus OpenUri string:$1
}
function sp-metadata {
# Prints the currently playing track in a parseable format.
dbus-send \
--print-reply `# We need the reply.` \
--dest=$SP_DEST \
$SP_PATH \
org.freedesktop.DBus.Properties.Get \
string:"$SP_MEMB" string:'Metadata' \
| grep -Ev "^method" `# Ignore the first line.` \
| grep -Eo '("(.*)")|(\b[0-9][a-zA-Z0-9.]*\b)' `# Filter interesting fiels.`\
| sed -E '2~2 a|' `# Mark odd fields.` \
| tr -d '\n' `# Remove all newlines.` \
| sed -E 's/\|/\n/g' `# Restore newlines.` \
| sed -E 's/(xesam:)|(mpris:)//' `# Remove ns prefixes.` \
| sed -E 's/^"//' `# Strip leading...` \
| sed -E 's/"$//' `# ...and trailing quotes.` \
| sed -E 's/"+/|/' `# Regard "" as seperator.` \
| sed -E 's/ +/ /g' `# Merge consecutive spaces.`
}
function sp-current {
# Prints the currently playing track in a friendly format.
require column
sp-metadata \
| grep --color=never -E "(title)|(album)|(artist)" \
| sed 's/^\(.\)/\U\1/' \
| column -t -s'|'
}
function sp-eval {
# Prints the currently playing track as shell variables, ready to be eval'ed
require sort
sp-metadata \
| grep --color=never -E "(title)|(album)|(artist)|(trackid)|(trackNumber)" \
| sort -r \
| sed 's/^\([^|]*\)\|/\U\1/' \
| sed -E 's/\|/="/' \
| sed -E 's/$/"/' \
| sed -E 's/^/SPOTIFY_/'
}
function sp-art {
# Prints the artUrl.
sp-metadata | grep "artUrl" | cut -d'|' -f2
}
function sp-display {
# Calls display on the artUrl.
require display
display $(sp-art)
}
function sp-feh {
# Calls feh on the artURl.
require feh
feh $(sp-art)
}
function sp-url {
# Prints the HTTP url.
TRACK=$(sp-metadata | grep "url" | cut -d'|' -f2 | cut -d':' -f3)
echo "http://open.spotify.com/track/$TRACK"
}
function sp-clip {
# Copies the HTTP url.
require xclip
sp-url | xclip
}
function sp-http {
# xdg-opens the HTTP url.
require xdg-open
xdg-open $(sp-url)
}
function sp-help {
# Prints usage information.
echo "Usage: sp [command]"
echo "Control a running Spotify instance from the command line."
echo ""
echo " sp play - Play/pause Spotify"
echo " sp pause - Pause Spotify"
echo " sp next - Go to next track"
echo " sp prev - Go to previous track"
echo ""
echo " sp current - Format the currently playing track"
echo " sp metadata - Dump the current track's metadata"
echo " sp eval - Return the metadata as a shell script"
echo ""
echo " sp art - Print the URL to the current track's album artwork"
echo " sp display - Display the current album artwork with \`display\`"
echo " sp feh - Display the current album artwork with \`feh\`"
echo ""
echo " sp url - Print the HTTP URL for the currently playing track"
echo " sp clip - Copy the HTTP URL to the X clipboard"
echo " sp http - Open the HTTP URL in a web browser"
echo ""
echo " sp open <uri> - Open a spotify: uri"
echo " sp search <q> - Start playing the best search result for the given query"
echo ""
echo " sp version - Show version information"
echo " sp help - Show this information"
echo ""
echo "Any other argument will start a search (i.e. 'sp foo' will search for foo)."
}
function sp-search {
# Searches for tracks, plays the first result.
require curl
Q="$@"
SPTFY_URI=$( \
curl -s -G --data-urlencode "q=$Q" ws.spotify.com/search/1/track \
| grep -E -o "spotify:track:[a-zA-Z0-9]+" -m 1 \
)
sp-open $SPTFY_URI
}
function sp-version {
# Prints version information.
echo "sp $SP_VERSION"
echo "Copyright (C) 2013 Wander Nauta"
echo "License MIT"
}
# 'SIMPLE' (DBUS-ALIAS) COMMANDS
alias sp-play=" sp-dbus PlayPause"
alias sp-pause=" sp-dbus Pause"
alias sp-next=" sp-dbus Next"
alias sp-prev=" sp-dbus Previous"
# DISPATCHER
# First, we connect to the dbus session spotify is on. This isn't really needed
# when running locally, but is crucial when we don't have an X display handy
# (for instance, when running sp over ssh.)
SPOTIFY_PID="$(pidof -s spotify)"
if [[ -z "$SPOTIFY_PID" ]]; then
echo "Error: Spotify is not running."
exit 1
fi
QUERY_ENVIRON="$(cat /proc/''${SPOTIFY_PID}/environ | tr '\0' '\n' | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
if [[ "''${QUERY_ENVIRON}" != "" ]]; then
export DBUS_SESSION_BUS_ADDRESS="''${QUERY_ENVIRON}"
fi
# Then we dispatch the command.
subcommand="$1"
if [[ -z "$subcommand" ]]; then
# No arguments given, print help.
sp-help
else
# Arguments given, check if it's a command.
if $(type sp-$subcommand > /dev/null 2> /dev/null); then
# It is. Run it.
shift
eval "sp-$subcommand $@"
else
# It's not. Try a search.
eval "sp-search $@"
fi
fi
'';
spotifyGenius = unstable.writers.writeDashBin "spgenius.sh" ''
function normalise {
echo "$1" | tr ' ' -
}
eval $(${scripts.sp} eval)
${pkgs.xdg_utils}/bin/xdg-open "http://genius.com/$(normalise "$SPOTIFY_ARTIST")-$(normalise "$SPOTIFY_TITLE")-lyrics"
'';
scripts.genius = unstable.writers.writeDashBin "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 | ${pkgs.gnused}/bin/sed 's/./\U&/')
TITLE=$(echo "$2" | normalize)
GENIUS_URL="https://genius.com/$ARTIST-$TITLE-lyrics"
${pkgs.curl}/bin/curl -s "$GENIUS_URL" \
| ${pkgs.gnused}/bin/sed -ne '/class="lyrics"/,/<\/p>/p' \
| ${pkgs.pandoc}/bin/pandoc -f html -s -t plain \
| ${pkgs.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
'';
scripts.generate-shell-nix =
let generateShellNixPath = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/kmein/generate-shell-nix/81f77661705ee628d1566f2dea01f2d731fda79d/generate-shell-nix";
sha256 = "0r661z9s5zw0gas2f73aakplfblj1jjlbijmm7gf513xkq61jxm8";
executable = true;
};
in unstable.writers.writeDashBin "generate-shell-nix" ''${generateShellNixPath} $*'';
scripts.dic =
let dicPath = pkgs.fetchurl {
url = "https://cgit.krebsco.de/dic/plain/dic?id=beeca40313f68874e05568f4041423c16202e9da";
sha256 = "1d25pm420fnbrr273i96syrcd8jkh8qnflpfgxlsbzmbmfizfzld";
executable = true;
};
in unstable.writers.writeDashBin "dic" ''${dicPath} $*'';
scripts.font-size = unstable.writers.writeDashBin "font-size" ''
set -efu
# set_font NORMAL_FONT BOLD_FONT
set_font() {
printf '\033]710;%s\007' "$1"
printf '\033]711;%s\007' "$2"
}
case ''${1-} in
'''|0|--reset)
set_font \
"xft:${theme.terminalFont.name}:size=${toString theme.terminalFont.size}" \
"xft:${theme.terminalFont.name}:size=${toString theme.terminalFont.size}:bold" \
;;
[2-9]|[1-9][0-9]|[1-9][0-9][0-9])
set_font \
"xft:${theme.terminalFont.name}:size=$1" \
"xft:${theme.terminalFont.name}:size=$1:bold" \
;;
*)
echo "$0: bad argument: $1" >&2
exit 1
esac
'';
scripts.wttr = unstable.writers.writeDashBin "wttr" ''
${pkgs.curl}/bin/curl -s -H "Accept-Language: ''${LANG%_*}" --compressed "wttr.in/''${1-$(${pkgs.curl}/bin/curl -s ipinfo.io | ${pkgs.jq}/bin/jq .loc)}?0"
'';
scripts.nix-git = unstable.writers.writeDashBin "nix-git" ''
${pkgs.nix-prefetch-git}/bin/nix-prefetch-git "$@" 2> /dev/null | ${pkgs.jq}/bin/jq -r '"rev = \"\(.rev)\";\nsha256 = \"\(.sha256)\";"'
'';
scripts.q =
let
q-performance = ''
show_load() {
${pkgs.coreutils}/bin/cat /proc/loadavg | ${pkgs.gawk}/bin/gawk '{ print $1, $2, $3}'
}
show_memory() {
${pkgs.procps}/bin/free -h | ${pkgs.gnugrep}/bin/grep "Mem" | ${pkgs.gawk}/bin/gawk '{print $3}'
}
printf "\x1b[33m%s \x1b[1m%s\x1b[0m\n" "$(show_load)" "$(show_memory)"
'';
q-isodate = ''
${pkgs.coreutils}/bin/date '+%Y-%m-%d %H:%M:%S%:z'
'';
q-volume = ''
is_mute() {
if $(${pkgs.pamixer}/bin/pamixer --get-mute); then
echo "(Mute)"
else
echo
fi
}
current_volume() {
${pkgs.pamixer}/bin/pamixer --get-volume
}
printf "\x1b[36m%d%%\x1b[0m %s\n" "$(current_volume)" "$(is_mute)"
'';
q-online = ''
if ${pkgs.curl}/bin/curl -s google.com >/dev/null; then
echo 'online'
else
echo 'offline'
fi
'';
q-battery = ''
BAT_DIR="/sys/class/power_supply/BAT1/"
if test ! -d "$BAT_DIR"; then
exit 1
fi
if test -e "$BAT_DIR/charge_now" -a -e "$BAT_DIR/charge_full"; then
FULL_CHARGE="$BAT_DIR/charge_full"
CURR_CHARGE="$BAT_DIR/charge_now"
elif test -e "$BAT_DIR/energy_now" -a -e "$BAT_DIR/energy_full"; then
FULL_CHARGE="$BAT_DIR/energy_full"
CURR_CHARGE="$BAT_DIR/energy_now"
else
ls >&2
exit 1
fi
STATUS="$BAT_DIR/status"
charge_d=$((100 * $(${pkgs.coreutils}/bin/cat $CURR_CHARGE) / $(${pkgs.coreutils}/bin/cat $FULL_CHARGE)))
if [[ "$charge_d" -lt 10 ]]; then
printf "\x1b[31m"
elif [[ "$charge_d" -lt 20 ]]; then
printf "\x1b[33m"
else
printf "\x1b[32m"
fi
printf '%s%%\x1b[0m (%s)\n' "$charge_d" $(${pkgs.coreutils}/bin/cat "$STATUS")
'';
q-todo = ''
TODO_file=$PWD/.todo
if test -e "$TODO_file"; then
printf "\n\x1b[1mTodo\x1b[0m\n"
${pkgs.coreutils}/bin/cat "$TODO_file" \
| ${pkgs.gawk}/bin/gawk -v now=$(${pkgs.coreutils}/bin/date +%s) '
BEGIN { print "remind=0" }
/^[0-9]/{
x = $1
gsub(".", "\\\\&", x)
rest = substr($0, index($0, " "))
rest = $0
sub(" *", "", rest)
gsub(".", "\\\\&", rest)
print "test $(${pkgs.coreutils}/bin/date +%s -d"x") -lt "now" && \
echo \"\x1b[93m\""rest esc "\"\x1b[m\" && \
(( remind++ ))"
}
END { print "test $remind = 0 && echo \"nothing to remind\"" }
' \
| {
# bash needed for (( ... ))
${pkgs.bash}/bin/bash
}
fi
'';
in unstable.writers.writeBashBin "q" ''
set -eu
export PATH=/var/empty
${q-isodate}
${q-performance}
(${q-volume}) &
(${q-battery}) &
(${q-online}) &
wait
${q-todo}
'';
in {
users.users.kfm.packages = lib.attrsets.attrValues scripts;
}

View File

@@ -52,4 +52,10 @@
enableCompletion = true;
};
programs.tmux = {
enable = true;
extraTmuxConf = import ../../dot/tmux.nix;
keyMode = "vi";
terminal = "screen-256color";
};
}

5
configs/docker.nix Normal file
View File

@@ -0,0 +1,5 @@
{ config, pkgs, ... }:
{
virtualisation.docker.enable = true;
users.users.kfm.extraGroups = [ "docker" ];
}

15
configs/google-drive.nix Normal file
View File

@@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
systemd.services.google-drive = {
description = "Google Drive synchronisation service";
wants = [ "network-online.target" ];
script = ''
${pkgs.grive2}/bin/grive -p ${config.users.users.kfm.home}/cloud/gdrive
'';
startAt = "*:0/5";
serviceConfig = {
Restart = "on-failure";
User = "kfm";
};
};
}

View File

@@ -1,6 +1,6 @@
{ pkgs, lib, config, ... }:
{
services.xserver = with import ../helpers.nix; with import ../theme.nix; {
services.xserver = let commaSep = builtins.concatStringsSep ","; in with import ../theme.nix; {
enable = true;
layout = commaSep [ "de" "gr" "ru" ];
xkbVariant = commaSep [ "T3" "polytonic" "phonetic_winkeys" ];
@@ -37,12 +37,6 @@
}.${config.networking.hostName};
};
i18n = {
defaultLocale = "en_GB.UTF-8";
consoleKeyMap = "de";
consoleColors = with import ../theme.nix; map (c: lib.strings.removePrefix "#" c) colorPalette;
};
services.compton = {
enable = true;
shadow = true;
@@ -63,30 +57,78 @@
timeout = 10;
};
fonts.enableDefaultFonts = true;
fonts.fonts = with pkgs; [
cantarell-fonts
corefonts
eb-garamond
fira
libertine
lmodern
noto-fonts
powerline-fonts
roboto
xlibs.fontschumachermisc
ubuntu_font_family
];
# packages for X
environment.systemPackages = with pkgs; [
config.constants.theme.gtk.package
config.constants.theme.icon.package
config.constants.theme.cursor.package
arandr
libnotify
xclip
xorg.xkill
wpa_supplicant_gui
] ++ [ # office
abiword
gnumeric
# typora
] ++ [ # internet
chromium
firefox
tor-browser-bundle-bin
thunderbird
] ++ [ # media
ffmpeg
mpv
pamixer
pavucontrol
gthumb
sxiv
blueman
zathura
];
services.urxvtd.enable = true;
services.dbus.packages = [ pkgs.gnome3.dconf ];
home-manager.users.kfm = {
gtk = {
enable = true;
# font = with import ../theme.nix; { package = pkgs.noto-fonts; name = uiFont.name; };
iconTheme = config.constants.theme.icon;
theme = config.constants.theme.gtk;
};
qt = {
enable = true;
useGtkTheme = true;
};
xsession.pointerCursor = config.constants.theme.cursor // { size = 16; };
xsession.windowManager.i3 = {
enable = true;
config = import ../dot/i3.nix { inherit lib pkgs config; };
};
xresources.properties = import ../dot/xresources.nix { inherit lib; };
programs.rofi = import ../dot/rofi.nix { inherit config; };
services.dunst = import ../dot/dunst.nix { inherit pkgs config; };
programs.urxvt = import ../dot/urxvt.nix { inherit pkgs; };
programs.zathura = import ../dot/zathura.nix;
home.file = {
".config/mpv/input.conf".text = import ../dot/mpv.nix;
# ".config/Typora/themes/base.user.css".text = import ../dot/typora.nix;
};
};
}

36
configs/haskell.nix Normal file
View File

@@ -0,0 +1,36 @@
{ config, pkgs, ... }:
let
executables = pkgs.haskell.lib.justStaticExecutables;
haskells = import ../dot/haskells.nix;
in {
users.users.kfm.packages = with pkgs; [
(haskellPackages.ghcWithHoogle haskells)
(executables haskellPackages.cabal-install)
(executables haskellPackages.ghcid)
(executables haskellPackages.hasktags)
(executables haskellPackages.hindent)
(executables haskellPackages.pointfree)
(executables haskellPackages.pointful)
(executables haskellPackages.hlint)
(executables haskellPackages.hpack)
];
home-manager.users.kfm.home.file = {
".ghc/ghci.conf".text = ''
:set editor vim
:def hoogle \s -> return $ ":!${pkgs.haskellPackages.hoogle}/bin/hoogle search --color -l --count=15 \"" ++ s ++ "\""
:def doc \s -> return $ ":!${pkgs.haskellPackages.hoogle}/bin/hoogle search --color -l --info \"" ++ s ++ "\""
:def pl \x -> return $ ":!${pkgs.haskellPackages.pointfree}/bin/pointfree -v \"" ++ x ++ "\""
:def unpl \x -> return $ ":!${pkgs.haskellPackages.pointful}/bin/pointful \"" ++ x ++ "\""
:set prompt "\o033[1m%s\o033[1;34m λ\o033[0m "
'';
".stack/config.yaml".text = let user = config.constants.user; in ''
templates:
params:
author-name: ${user.name}
author-email: ${user.email}
copyright: 'Copyright: (c) 2018 ${user.name}'
github-username: ${user.github}
'';
};
}

15
configs/kdeconnect.nix Normal file
View File

@@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
# for kdeconnect
networking.firewall = {
allowedTCPPortRanges = [ { from = 1714; to = 1764; } ];
allowedUDPPortRanges = [ { from = 1714; to = 1764; } ];
};
home-manager.users.kfm = {
services.kdeconnect = {
enable = true;
indicator = true;
};
};
}

View File

@@ -1,92 +0,0 @@
{ pkgs, config, lib, ... }:
let
sshPort = 22022;
secrets = import ../secrets.nix;
in {
networking.hosts = lib.mapAttrs (_: value: [ (value + ".local") ]) {
"192.168.178.1" = "router";
"192.168.178.21" = "scardanelli";
"192.168.178.22" = "homeros";
"192.168.178.24" = "lestrade";
"192.168.178.27" = "printer";
} // {
"42:0:ca48:f98f:63d7:31ce:922b:245d" = [ "go" ];
};
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
Aether = { pskRaw = "e1b18af54036c5c9a747fe681c6a694636d60a5f8450f7dec0d76bc93e2ec85a"; };
EasyBox-927376 = { pskRaw = "dbd490ab69b39bd67cfa06daf70fc3ef3ee90f482972a668ed758f90f5577c22"; };
"Asoziales Netzwerk" = { pskRaw = "8e234041ec5f0cd1b6a14e9adeee9840ed51b2f18856a52137485523e46b0cb6"; };
c-base-public = {};
};
};
# for kdeconnect
networking.firewall = {
allowedTCPPortRanges = [ { from = 1714; to = 1764; } ];
allowedUDPPortRanges = [ { from = 1714; to = 1764; } ];
};
home-manager.users.kfm = {
services.kdeconnect = {
enable = true;
indicator = true;
};
programs.ssh = {
enable = true;
matchBlocks = {
lestrade = {
hostname = "lestrade.local";
user = "pi";
};
scardanelli = {
hostname = "scardanelli.local";
user = "kfm";
port = sshPort;
};
homeros = {
hostname = "homeros.local";
user = "kfm";
port = sshPort;
};
};
};
};
programs.ssh = {
startAgent = true;
forwardX11 = true;
};
services.openssh = {
ports = [ sshPort ];
enable = true;
forwardX11 = true;
passwordAuthentication = false;
};
users.users.kfm.openssh.authorizedKeys.keys = let sshKey = secrets.ssh.publicKey; in [
sshKey.homeros
sshKey.scardanelli
];
networking.retiolum = {
scardanelli = {
ipv4 = "10.243.2.2";
ipv6 = "42:0:3c46:4007:5bce:f1bc:606b:2b18";
};
homeros = {
ipv4 = "10.243.2.1";
ipv6 = "42:0:3c46:53e:e63d:e62a:56ea:c705";
};
}.${config.networking.hostName};
environment.etc."tinc/retiolum/rsa_key.priv" = {
text = secrets.retiolum.privateKey.${config.networking.hostName};
mode = "400";
};
}

View File

@@ -1,181 +0,0 @@
{ config, pkgs, lib, ... }:
let
scripts = import ../dot/scripts.nix { inherit pkgs lib; };
daybook = pkgs.callPackage ../packages/daybook.nix {};
iolanguage = pkgs.callPackage ../packages/iolanguage.nix {};
todoist = pkgs.callPackage ../packages/todoist {};
haskells = import ../dot/haskells.nix;
unstable = import <nixos-unstable> {};
executables = pkgs.haskell.lib.justStaticExecutables;
in with pkgs;
{
nixpkgs.config.allowUnfree = true;
fonts.enableDefaultFonts = true;
fonts.fonts = [
cantarell-fonts
corefonts
eb-garamond
fira
libertine
lmodern
noto-fonts
powerline-fonts
roboto
xlibs.fontschumachermisc
ubuntu_font_family
];
environment.systemPackages = [
] ++ [ # office
abiword
gnumeric
# typora
] ++ [ # theme
config.constants.theme.gtk.package
config.constants.theme.icon.package
config.constants.theme.cursor.package
] ++ [ # internet
aria2
chromium
firefox
tor-browser-bundle-bin
thunderbird
w3m
wget
httpie
whois
] ++ [ # media
ffmpeg
mpv
pamixer
pavucontrol
gthumb
imagemagick
sxiv
blueman
zathura
] ++ [ # archive
unzip
unrar
p7zip
zip
] ++ [ # monitor
htop
iotop
iftop
lsof
psmisc
] ++ [ # shell
bat
dos2unix
fd
file
git
gitAndTools.hub
gitstats
manpages
patch
patchutils
posix_man_pages
most
ranger
ripgrep
rlwrap
tree
] ++ [ # hardware
pmount
usbutils
pciutils
] ++ [ # graphical
arandr
libnotify
xclip
xorg.xkill
wpa_supplicant_gui
];
programs.command-not-found.enable = true;
programs.java = {
enable = true;
package = pkgs.openjdk;
};
virtualisation.docker.enable = true;
services.urxvtd.enable = true;
services.dbus.packages = [ pkgs.gnome3.dconf ];
users.users.kfm.packages = scripts ++ [
] ++ [ # typesetting
(texlive.combine {
inherit (pkgs.texlive) scheme-full texdoc latex2e-help-texinfo;
pkgFilter = pkg: pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "latex2e-help-texinfo";
})
pandoc
(executables haskellPackages.pandoc-citeproc)
asciidoctor
] ++ [ # programming
tokei
gnumake
cabal2nix
chicken
clojure
gcc
(haskellPackages.ghcWithHoogle haskells)
(executables haskellPackages.cabal-install)
(executables haskellPackages.ghcid)
(executables haskellPackages.hakyll)
(executables haskellPackages.hasktags)
(executables haskellPackages.hindent)
(executables haskellPackages.pointfree)
(executables haskellPackages.pointful)
(executables haskellPackages.hlint)
(executables haskellPackages.hpack)
htmlTidy
iolanguage
lua
mypy
nix-prefetch-git
nodejs
nodePackages.eslint
nodePackages.csslint
nodePackages.prettier
ocaml
python3
python36Packages.black
python36Packages.flake8
ruby
rustup
scala
shellcheck
] ++ [ # media
audacity
calibre
inkscape
poppler_utils
spotify
youtubeDL
] ++ [ # cloud
dropbox-cli
grive2
seafile-client
] ++ [ # math
bc
graphviz
maxima
] ++ [ # shell
# todoist
aspell
aspellDicts.de
aspellDicts.en
aspellDicts.la
daybook
jo
jq
memo
par
qrencode
unstable.hledger
wordnet
xsv
];
}

View File

@@ -1,72 +1,25 @@
{ config, pkgs, lib, ... }:
with lib;
let
netname = "retiolum";
cfg = config.networking.retiolum;
{ config, pkgs, ... }:
let retiolumKey = (import ../secrets.nix).retiolum.privateKey;
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;
extraConfig = ''
LocalDiscovery = yes
ConnectTo = gum
ConnectTo = ni
ConnectTo = prism
ConnectTo = eve
AutoConnect = yes
'';
};
imports = [ ../modules/retiolum.nix ];
networking.extraHosts = builtins.readFile (pkgs.fetchurl {
name = "retiolum.hosts";
url = "https://lassul.us/retiolum.hosts";
# FIXME
sha256 = "0q8f5gw12hf9dhwcs4fni8jrvb2a1g6jskz28qcbd10p2xlkja58";
});
environment.systemPackages = [ config.services.tinc.networks.${netname}.package ];
systemd.services."tinc.${netname}" = {
path = with pkgs; [ curl gnutar bzip2 ];
preStart = ''
curl https://lassul.us/retiolum-hosts.tar.bz2 | tar -xjvf - -C /etc/tinc/${netname}/ || true
'';
};
networking.firewall.allowedTCPPorts = [ 655 ];
networking.firewall.allowedUDPPorts = [ 655 ];
systemd.network.enable = true;
systemd.network.networks = {
"${netname}".extraConfig = ''
[Match]
Name = tinc.${netname}
[Network]
Address=${cfg.ipv4}/12
Address=${cfg.ipv6}/16
'';
};
networking.hosts = {
"42:0:ca48:f98f:63d7:31ce:922b:245d" = [ "go" ];
};
networking.retiolum = {
scardanelli = {
ipv4 = "10.243.2.2";
ipv6 = "42:0:3c46:4007:5bce:f1bc:606b:2b18";
};
homeros = {
ipv4 = "10.243.2.1";
ipv6 = "42:0:3c46:53e:e63d:e62a:56ea:c705";
};
}.${config.networking.hostName};
environment.etc."tinc/retiolum/rsa_key.priv" = {
text = retiolumKey.${config.networking.hostName};
mode = "400";
};
}

13
configs/wifi.nix Normal file
View File

@@ -0,0 +1,13 @@
{ config, ... }:
{
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
Aether = { pskRaw = "e1b18af54036c5c9a747fe681c6a694636d60a5f8450f7dec0d76bc93e2ec85a"; };
EasyBox-927376 = { pskRaw = "dbd490ab69b39bd67cfa06daf70fc3ef3ee90f482972a668ed758f90f5577c22"; };
"Asoziales Netzwerk" = { pskRaw = "8e234041ec5f0cd1b6a14e9adeee9840ed51b2f18856a52137485523e46b0cb6"; };
c-base-public = {};
};
};
}