dotfiles

My beautiful configs and dotfiles managed by Nix' home-manager
Log | Files | Refs | README | LICENSE

commit 608eb0ffabd3ce5939ecfceabe50fdb1ecd9e8ad
parent 4d52a8bb4a2987180084f05df991e6b89a2d0774
Author: Friedel Schön <[email protected]>
Date:   Sun, 21 Jul 2024 23:59:38 +0200

dotfiles managed by home-manager

Diffstat:
D.gitmodules | 12------------
D.stow-global-ignore | 7-------
D.xservice/9wm/down | 0
D.xservice/9wm/log/run | 2--
D.xservice/9wm/run | 8--------
D.xservice/background/down | 0
D.xservice/background/log/run | 2--
D.xservice/background/run | 10----------
D.xservice/blueman-applet/log/run | 2--
D.xservice/blueman-applet/run | 7-------
D.xservice/cron/crontab | 1-
D.xservice/cron/down | 0
D.xservice/cron/log.txt | 6------
D.xservice/cron/log/run | 2--
D.xservice/cron/run | 8--------
D.xservice/cron/xbps-status.sh | 17-----------------
D.xservice/dbus/log/run | 2--
D.xservice/dbus/run | 5-----
D.xservice/dwm/log/run | 2--
D.xservice/dwm/run | 8--------
D.xservice/logging | 6------
D.xservice/nm-applet/log/run | 2--
D.xservice/nm-applet/run | 7-------
D.xservice/pa-applet/log/run | 2--
D.xservice/pa-applet/run | 7-------
D.xservice/slstatus-xbps/log/run | 2--
D.xservice/slstatus-xbps/run | 14--------------
D.xservice/slstatus/log/run | 2--
D.xservice/slstatus/run | 12------------
D.xservice/stw-service/run | 3---
D.xservice/stw-xbps/run | 3---
D.xservice/tiramisu/log/run | 2--
D.xservice/tiramisu/run | 8--------
D.xservice/tiramisu/test.txt | 1-
D.xservice/xfce-polkit/log/run | 2--
D.xservice/xfce-polkit/run | 7-------
D.xservice/xserver/log/run | 2--
D.xservice/xserver/run | 9---------
Tdotfiles/vimrc | 0
Mdotfiles/xinitrc | 4+---
Ddotfiles/zshrc | 23-----------------------
Ahome.nix | 242+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkgs/default.nix | 13+++++++++++++
Apkgs/dmenu.nix | 25+++++++++++++++++++++++++
Apkgs/dwm.nix | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkgs/make-service.nix | 40++++++++++++++++++++++++++++++++++++++++
Apkgs/pretty-svstat.nix | 17+++++++++++++++++
Apkgs/slstatus.nix | 21+++++++++++++++++++++
Apkgs/st.nix | 28++++++++++++++++++++++++++++
Apkgs/void-runit.nix | 35+++++++++++++++++++++++++++++++++++
Apkgs/weakbox.nix | 20++++++++++++++++++++
Aservices.nix | 174+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsuckless/dmenu | 1-
Dsuckless/dwm | 1-
Dsuckless/slstatus | 1-
Dsuckless/st | 1-
56 files changed, 740 insertions(+), 222 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -1,12 +0,0 @@ -[submodule "suckless/dwm"] - path = suckless/dwm - url = [email protected]:suckless/dwm -[submodule "suckless/st"] - path = suckless/st - url = [email protected]:suckless/st -[submodule "suckless/slstatus"] - path = suckless/slstatus - url = [email protected]:suckless/slstatus -[submodule "suckless/dmenu"] - path = suckless/dmenu - url = [email protected]:suckless/dmenu diff --git a/.stow-global-ignore b/.stow-global-ignore @@ -1,7 +0,0 @@ -\.git -\.gitignore -Makefile -^/Makefile -^/README.* -^/LICENSE.* -supervise diff --git a/.xservice/9wm/down b/.xservice/9wm/down diff --git a/.xservice/9wm/log/run b/.xservice/9wm/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/9wm/run b/.xservice/9wm/run @@ -1,8 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -cd $HOME -exec 9wm diff --git a/.xservice/background/down b/.xservice/background/down diff --git a/.xservice/background/log/run b/.xservice/background/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/background/run b/.xservice/background/run @@ -1,10 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -#$HOME/.fehbg -xsetroot -solid '#ebdbb2' - -exec chpst -b background pause diff --git a/.xservice/blueman-applet/log/run b/.xservice/blueman-applet/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/blueman-applet/run b/.xservice/blueman-applet/run @@ -1,7 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -exec blueman-applet diff --git a/.xservice/cron/crontab b/.xservice/cron/crontab @@ -1 +0,0 @@ -*/6 * * * * ./xbps-status.sh diff --git a/.xservice/cron/down b/.xservice/cron/down diff --git a/.xservice/cron/log.txt b/.xservice/cron/log.txt @@ -1,6 +0,0 @@ -run: ./xbps-status.sh pid: 22304 at Sat Apr 13 21:48:00 2024 -complete: pid: 22304 returned: 0 time: Sat Apr 13 21:48:00 2024 -run: ./xbps-status.sh pid: 22671 at Sat Apr 13 21:54:00 2024 -complete: pid: 22671 returned: 0 time: Sat Apr 13 21:54:00 2024 -run: ./xbps-status.sh pid: 23188 at Sat Apr 13 22:00:00 2024 -complete: pid: 23188 returned: 0 time: Sat Apr 13 22:00:00 2024 diff --git a/.xservice/cron/log/run b/.xservice/cron/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/cron/run b/.xservice/cron/run @@ -1,8 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -# execute all jobs once -cut -d' ' -f6- crontab | sh - -exec crond -nf crontab diff --git a/.xservice/cron/xbps-status.sh b/.xservice/cron/xbps-status.sh @@ -1,17 +0,0 @@ -#!/bin/bash - -OUTPUT=/tmp/xbps-updates.txt - -#tr -dc A-Za-z0-9 < /dev/urandom | head -c 5 > $OUTPUT -#exit - -echo "checking updates..." >&2 - -updates=$(xbps-install -Mun | wc -l) - -if [ $updates -ne 0 ]; then - echo $updates > $OUTPUT -else - echo up-to-date > $OUTPUT -fi - diff --git a/.xservice/dbus/log/run b/.xservice/dbus/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/dbus/run b/.xservice/dbus/run @@ -1,5 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -exec dbus-daemon --nofork --session diff --git a/.xservice/dwm/log/run b/.xservice/dwm/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/dwm/run b/.xservice/dwm/run @@ -1,8 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -cd $HOME -exec dwm diff --git a/.xservice/logging b/.xservice/logging @@ -1,6 +0,0 @@ -#!/bin/sh - -now=$(date '+%y-%m-%d %H:%M:%S') -name=$(basename $(dirname $PWD)) - -exec sed -e "s/^/[$now] $name: /" >> $XSERVICELOG diff --git a/.xservice/nm-applet/log/run b/.xservice/nm-applet/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/nm-applet/run b/.xservice/nm-applet/run @@ -1,7 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -exec nm-applet diff --git a/.xservice/pa-applet/log/run b/.xservice/pa-applet/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/pa-applet/run b/.xservice/pa-applet/run @@ -1,7 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -exec pa-applet diff --git a/.xservice/slstatus-xbps/log/run b/.xservice/slstatus-xbps/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/slstatus-xbps/run b/.xservice/slstatus-xbps/run @@ -1,14 +0,0 @@ -#!/bin/bash - -OUTPUT=/tmp/xbps-updates.txt - -while true; do - updates=$(xbps-install -Mun | wc -l) - - if [ $updates -ne 0 ]; then - echo $updates > $OUTPUT - else - echo up-to-date > $OUTPUT - fi - sleep 120 -done diff --git a/.xservice/slstatus/log/run b/.xservice/slstatus/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/slstatus/run b/.xservice/slstatus/run @@ -1,12 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -FIFO=/tmp/slstatus.fifo - -[ -p $FIFO ] || rm -f $FIFO -mkfifo $FIFO - -exec slstatus -p $FIFO diff --git a/.xservice/stw-service/run b/.xservice/stw-service/run @@ -1,3 +0,0 @@ -#!/bin/sh - -exec stw -p 1 -b '#ebdbb2' -f '#3c3836' -F 'Source Code Pro:size=9' -B 10 -y 20 sh -c 'echo -- services -- ; psv /var/service/* ~/.xservice/* 2> /dev/null | sort -k2,2 -k1,1' diff --git a/.xservice/stw-xbps/run b/.xservice/stw-xbps/run @@ -1,3 +0,0 @@ -#!/bin/sh - -exec stw -b '#ebdbb2' -f '#3c3836' -F 'Source Code Pro:size=9' -B 10 -p 120 -y 100% -Y -100% sh -c 'echo -- updates -- && xbps-install -Mun | cut -d" " -f1' diff --git a/.xservice/tiramisu/log/run b/.xservice/tiramisu/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/tiramisu/run b/.xservice/tiramisu/run @@ -1,8 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 -SVDIR=.. sv check slstatus > /dev/null || exit 1 - -exec tiramisu -o '\\x04#source\\x05#summary: #body\\n' | xargs -i printf '%b' '{}' > /tmp/slstatus.fifo diff --git a/.xservice/tiramisu/test.txt b/.xservice/tiramisu/test.txt @@ -1 +0,0 @@ - diff --git a/.xservice/xfce-polkit/log/run b/.xservice/xfce-polkit/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/xfce-polkit/run b/.xservice/xfce-polkit/run @@ -1,7 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -SVDIR=.. sv check xserver > /dev/null || exit 1 - -exec /usr/libexec/xfce-polkit diff --git a/.xservice/xserver/log/run b/.xservice/xserver/log/run @@ -1 +0,0 @@ -../../logging -\ No newline at end of file diff --git a/.xservice/xserver/run b/.xservice/xserver/run @@ -1,9 +0,0 @@ -#!/bin/sh - -exec 2>&1 - -if [ -z "$XDG_VTNR" ]; then - exec X -nolisten tcp $DISPLAY -else - exec X -nolisten tcp $DISPLAY vt$XDG_VTNR -fi diff --git a/dotfiles/vimrc b/dotfiles/vimrc diff --git a/dotfiles/xinitrc b/dotfiles/xinitrc @@ -2,8 +2,6 @@ export DISPLAY=:0 export XAUTHORITY=$HOME/.Xauthority -export XSERVICELOG=$HOME/.xservice.log/current - -mv $XSERVICELOG $XSERVICELOG.old +$HOME/.xservice/create-supervise.sh exec runsvdir $HOME/.xservice diff --git a/dotfiles/zshrc b/dotfiles/zshrc @@ -1,23 +0,0 @@ -#!/bin/zsh - -plugins=(zsh-autosuggestions zsh-syntax-highlighting) - -for pl in $plugins; do - source /usr/share/zsh/plugins/$pl/$pl.plugin.zsh -done - -vsv() { - [ "$UID" -eq 0 ] && export SVDIR=/var/service || export SVDIR=$HOME/.xservice - /usr/bin/vsv $@ -} - - -alias ls="exa" -alias clip="xclip -selection clipboard" -alias neofetch="fastfetch" -alias ccat="bat --style=plain --paging=never --theme=OneHalfDark" - -export PLAN9="$HOME/plan9port" -export PATH="$PATH:$HOME/.local/bin:$HOME/.cargo/bin:$PLAN9/bin" -export MANPATH="$MANPATH:$HOME/.local/share/man:$PLAN9/man" -export WEAKBOX="$HOME/.glibc" diff --git a/home.nix b/home.nix @@ -0,0 +1,242 @@ +{ config, pkgs, fetchgit, ... }: + +let + localpkgs = import ./pkgs { inherit pkgs; }; + bitor = builtins.bitOr; + + colors = { + black = "#282828"; + blue = "#83a598"; + gray2 = "#282828"; + gray3 = "#3c3836"; + gray4 = "#282828"; + green = "#8ec07c"; + orange = "#fe8019"; + pink = "#d3869b"; + red = "#fb4934"; + white = "#ebdbb2"; + yellow = "#b8bb26"; + }; + + colorscheme = with colors; [ + { bg = gray3; fg = white; border = gray2; } + { bg = gray3; fg = blue; border = blue; } + { bg = gray3; fg = orange; border = red; } + { bg = gray3; fg = orange; border = gray2; } + { bg = gray3; fg = green; border = gray2; } + ]; + + dwm_util = rec { + mask = { + shift = 1; + lock = 2; + control = 4; + mod1 = 8; + mod2 = 16; + mod3 = 32; + mod4 = 64; + mod5 = 128; + }; + + modkey = mask.mod4; + tagkeys = { tag, key }: [ + { mod = [ modkey ]; inherit key; func = "view"; arg = "{.ui = 1 << ${toString tag}}"; } + { mod = [ modkey mask.control ]; inherit key; func = "toggleview"; arg = "{.ui = 1 << ${toString tag}}"; } + { mod = [ modkey mask.shift ]; inherit key; func = "tag"; arg = "{.ui = 1 << ${toString tag}}"; } + { mod = [ modkey mask.control mask.shift ]; inherit key; func = "toggletag"; arg = "{.ui = 1 << ${toString tag}}"; } + ]; + + shell = cmd: "{ .v = (const char*[]){ \"/bin/sh\", \"-c\", \"${cmd}\", NULL } }"; + command = cmd: "{ .v = (const char*[]){ ${pkgs.lib.strings.concatMapStrings (w: "\"${w}\",") cmd} NULL } }"; + backlight = device: value: command [ "brightnessctl" "-q" "-d" device "set" value ]; + + monitor_backlight = "acpi_video0"; + keyboard_backlight = "smc::kbd_backlight"; + }; +in +rec { + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "friedel"; + home.homeDirectory = "/home/friedel"; + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with localpkgs; [ + (dwm.override (with dwm_util; { + borderpx = 3; + snap = 15; + horizpadbar = 5; + vertpadbar = 5; + showbar = 1; + topbar = 1; + systraypinning = 0; + systrayonleft = 0; + systrayspacing = 2; + systraypinningfailfirst = 1; + showsystray = 1; + fonts = [ "Monaco:size=10" ]; + tags = [ "1" "2" "3" "4" "5" ]; + autostart = "./dwmrc"; + colors = colorscheme; + rules = [ + { class = "\"Firefox\""; tags = "1 << 5"; isfloating = 0; monitor = -1; } + ]; + layouts = [ + { symbol = "[]="; function = "tile"; } + { symbol = "{}"; function = "NULL"; } + { symbol = "[o]"; function = "monocle"; } + ]; + keys = [ + { mod = [ modkey ]; key = "XK_Return"; func = "spawn"; arg = command [ "st" ]; } + { mod = [ modkey mask.shift ]; key = "XK_w"; func = "spawn"; arg = command [ "surf" ]; } + { mod = [ modkey ]; key = "XK_w"; func = "spawn"; arg = command [ "firefox" ]; } + { mod = [ modkey ]; key = "XK_space"; func = "spawn"; arg = command [ "dmenu_run" "-c" "-bh" "5" "-l" "20" "-g" "2" ]; } + { mod = [ modkey ]; key = "XK_m"; func = "spawn"; arg = shell "man -k . | dmenu -c -l 25 | cut -d' ' -f1-2 | sed -E 's/(\S+) \((\S+)\)/\2 \1/' | xargs st -f 'SF Mono' -e man -s"; } + { key = "XF86XK_MonBrightnessUp"; func = "spawn"; arg = backlight monitor_backlight "+5%"; } + { key = "XF86XK_MonBrightnessDown"; func = "spawn"; arg = backlight monitor_backlight "5%-"; } + { key = "XF86XK_KbdBrightnessUp"; func = "spawn"; arg = backlight keyboard_backlight "+5%"; } + { key = "XF86XK_KbdBrightnessDown"; func = "spawn"; arg = backlight keyboard_backlight "5%-"; } + { mod = [ modkey ]; key = "XK_o"; func = "spawn"; arg = command [ "dfm" ]; } + { mod = [ modkey mask.shift ]; key = "XK_o"; func = "spawn"; arg = command [ "dfm" "-c" ]; } + { mod = [ modkey ]; key = "XK_b"; func = "togglebar"; } + { mod = [ modkey ]; key = "XK_j"; func = "focusstack"; arg = 1; } + { mod = [ modkey ]; key = "XK_k"; func = "focusstack"; arg = -1; } + { mod = [ modkey ]; key = "XK_i"; func = "incnmaster"; arg = 1; } + { mod = [ modkey ]; key = "XK_d"; func = "incnmaster"; arg = -1; } + { mod = [ modkey ]; key = "XK_Left"; func = "setmfact"; arg = -0.05; } + { mod = [ modkey ]; key = "XK_Right"; func = "setmfact"; arg = 0.05; } + { mod = [ modkey mask.shift ]; key = "XK_Return"; func = "zoom"; } + { mod = [ modkey ]; key = "XK_Tab"; func = "view"; } + { mod = [ modkey ]; key = "XK_q"; func = "killclient"; } + { mod = [ modkey mask.control ]; key = "XK_comma"; func = "cyclelayout"; arg = -1; } + { mod = [ modkey mask.control ]; key = "XK_period"; func = "cyclelayout"; arg = 1; } + { mod = [ modkey mask.control ]; key = "XK_space"; func = "setlayout"; } + { mod = [ modkey mask.shift ]; key = "XK_space"; func = "togglefloating"; } + { mod = [ modkey ]; key = "XK_0"; func = "view"; arg = "{.ui = ~0 }"; } + { mod = [ modkey mask.shift ]; key = "XK_0"; func = "tag"; arg = "{.ui = ~0 }"; } + { mod = [ modkey ]; key = "XK_comma"; func = "focusmon"; arg = -1; } + { mod = [ modkey ]; key = "XK_period"; func = "focusmon"; arg = 1; } + { mod = [ modkey mask.shift ]; key = "XK_comma"; func = "tagmon"; arg = -1; } + { mod = [ modkey mask.shift ]; key = "XK_period"; func = "tagmon"; arg = 1; } + { mod = [ modkey mask.shift ]; key = "XK_r"; func = "refresh"; } + { mod = [ modkey mask.shift ]; key = "XK_q"; func = "quit"; } + ] + ++ (tagkeys { tag = 0; key = "XK_1"; }) + ++ (tagkeys { tag = 1; key = "XK_2"; }) + ++ (tagkeys { tag = 2; key = "XK_3"; }) + ++ (tagkeys { tag = 3; key = "XK_4"; }) + ++ (tagkeys { tag = 4; key = "XK_5"; }); + buttons = [ + { button = "Button1"; click = "ClkLtSymbol"; func = "cyclelayout"; arg = 1; } + { button = "Button2"; click = "ClkWinTitle"; func = "zoom"; } + { button = "Button2"; click = "ClkStatusText"; func = "spawn"; arg = command [ "st" ]; } + { mod = [ modkey ]; button = "Button1"; click = "ClkClientWin"; func = "movemouse"; } + { mod = [ modkey ]; button = "Button2"; click = "ClkClientWin"; func = "togglefloating"; } + { mod = [ modkey ]; button = "Button3"; click = "ClkClientWin"; func = "resizemouse"; } + { button = "Button1"; click = "ClkTagBar"; func = "view"; } + { button = "Button3"; click = "ClkTagBar"; func = "toggleview"; } + { mod = [ modkey ]; button = "Button1"; click = "ClkTagBar"; func = "tag"; } + { mod = [ modkey ]; button = "Button3"; click = "ClkTagBar"; func = "toggletag"; } + ]; + })) + (dmenu.override { colors = colorscheme; }) + pretty-svstat + slstatus + st + void-runit + weakbox + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" "FiraCode" ]; }) + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + ".xservice".source = localpkgs.make-service rec { + name = "home-service"; + services = import ./services.nix { inherit pkgs; }; + supervise = sv: "/tmp/${name}/supervise.${sv}"; + }; + + ".dwmrc".source = ./dotfiles/dwmrc; + ".xinitrc".source = ./dotfiles/xinitrc; + }; + + home.sessionVariables = { + PLAN9 = "${pkgs.plan9port}"; + WEAKBOX = "$HOME/.glibc"; + EDITOR = "vim"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + programs.nix-index.enable = true; + + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + shellAliases = { + ls = "${pkgs.eza}/bin/eza"; + clip = "${pkgs.xclip}/bin/xclip -selection clipboard"; + neofetch = "${pkgs.fastfetch}/bin/fastfetch"; + ccat = "${pkgs.bat}/bin/bat --style=plain --paging=never --theme=OneHalfDark"; + }; + + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/history"; + }; + + initExtra = '' + source ${pkgs.grml-zsh-config}/etc/zsh/zshrc + + vsv() { + if [ "$UID" -eq 0 ]; then + dir=/var/service + else + dir=$HOME/.xservice + fi + /usr/bin/vsv -d $dir $@ + } + + export PATH="$PATH:$HOME/.local/bin:$HOME/.cargo/bin:$PLAN9/bin" + export MANPATH="$MANPATH:$HOME/.local/share/man:$PLAN9/man" + + if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then + startx + fi + ''; + }; + + programs.vim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + vim-one + vim-airline + vim-airline-themes + auto-pairs + vim-auto-save + ale + ]; + settings = { + background = "dark"; + number = true; + tabstop = 4; + shiftwidth = 4; + relativenumber = true; + }; + extraConfig = builtins.readFile ./dotfiles/vimrc; + }; + + + home.stateVersion = "24.05"; # Please read the comment before changing. +} diff --git a/pkgs/default.nix b/pkgs/default.nix @@ -0,0 +1,13 @@ +{ pkgs ? import <nixpkgs> { } }: + +{ + dmenu = pkgs.callPackage ./dmenu.nix { }; + dwm = pkgs.callPackage ./dwm.nix { }; + pretty-svstat = pkgs.callPackage ./pretty-svstat.nix { }; + slstatus = pkgs.callPackage ./slstatus.nix { }; + st = pkgs.callPackage ./st.nix { }; + void-runit = pkgs.callPackage ./void-runit.nix { }; + weakbox = pkgs.callPackage ./weakbox.nix { }; + + make-service = import ./make-service.nix { inherit pkgs; }; +} diff --git a/pkgs/dmenu.nix b/pkgs/dmenu.nix @@ -0,0 +1,25 @@ +{ pkgs ? import <nixpkgs> { } +, colors ? [ ] +}: + +with pkgs; stdenv.mkDerivation rec { + name = "dmenu"; + src = fetchGit { + url = "https://git.friedelschoen.io/suckless/dmenu"; + rev = "e9bea6daddb02bfdff2915ca781d03a4f071c5dd"; + }; + + buildInputs = [ + xorg.libX11 + xorg.libXinerama + xorg.libXft + ]; + + buildPhase = '' + make all + ''; + + installPhase = '' + make PREFIX=$out install + ''; +} diff --git a/pkgs/dwm.nix b/pkgs/dwm.nix @@ -0,0 +1,124 @@ +{ pkgs ? import <nixpkgs> { } +, colors ? [ ] +, borderpx ? 2 +, snap ? 10 +, horizpadbar ? 10 +, vertpadbar ? 10 +, showbar ? 1 +, topbar ? 1 +, systraypinning ? 0 +, systrayonleft ? 0 +, systrayspacing ? 2 +, systraypinningfailfirst ? 1 +, showsystray ? 1 +, mfact ? 0.6 +, nmaster ? 1 +, resizehints ? 1 +, lockfullscreen ? 1 +, fonts ? [ "Source Code Pro:size=9" ] +, tags ? [ "1" "2" "3" "4" "5" ] +, rules ? [ ] +, autostart ? ".dwmrc" +, layouts ? [ + { symbol = "[]="; function = "tile"; } + { symbol = "{}"; function = "NULL"; } + { symbol = "[o]"; function = "monocle"; } + ] +, keys ? [ ] +, buttons ? [ ] +}: + +let + emptyList = [ ]; + lib = pkgs.lib; + + attrValsStringDef = nameList: default: set: map (x: toString set.${x} or default) nameList; + setToString = names: set: "{ " + (lib.strings.concatStringsSep ", " (attrValsStringDef names "NULL" set)) + " }"; + + # int i; + # unsigned int ui; + # float f; + # const void *v; + + + foldMod = lib.fold builtins.bitOr 0; + funcArg = value: + if builtins.isInt value then "{ .i = ${toString value} }" + else if builtins.isFloat value then "{ .f = ${toString value} }" + else if builtins.isBool value then "{ .i = ${if value then "1" else "0"} }" + #else if builtins.isString value then "{ .v = \"${value}\" }" + else toString value; + + generateConfig = builtins.toFile "config.h" '' + #include <X11/XF86keysym.h> + + static const unsigned int borderpx = ${toString borderpx}; /* border pixel of windows */ + static const unsigned int snap = ${toString snap}; /* snap pixel */ + static const int horizpadbar = ${toString horizpadbar}; /* horizontal padding for statusbar */ + static const int vertpadbar = ${toString vertpadbar}; /* vertical padding for statusbar */ + static const int showbar = ${toString showbar}; /* 0 means no bar */ + static const int topbar = ${toString topbar}; /* 0 means bottom bar */ + static const unsigned int systraypinning = ${toString systraypinning}; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ + static const unsigned int systrayonleft = ${toString systrayonleft}; /* 0: systray in the right corner, >0: systray on left of status text */ + static const unsigned int systrayspacing = ${toString systrayspacing}; /* systray spacing */ + static const int systraypinningfailfirst = ${toString systraypinningfailfirst}; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ + static const int showsystray = ${toString showsystray}; /* 0 means no systray */ + static const char *fonts[] = { ${lib.concatStringsSep ", " (map (f: "\"${f}\"") fonts)} }; + static const float mfact = ${toString mfact}; /* factor of master area size [0.05..0.95] */ + static const int nmaster = ${toString nmaster}; /* number of clients in master area */ + static const int resizehints = ${toString resizehints}; /* 1 means respect size hints in tiled resizals */ + static const int lockfullscreen = ${toString lockfullscreen}; /* 1 will force focus on the fullscreen window */ + static const char dwmrc[] = "${autostart}"; + + static const char *colors[][3] = { // light + /* fg bg border */ + ${lib.concatStringsSep ",\n" (map (f: "{ \"${f.fg}\", \"${f.bg}\", \"${f.border}\" }") colors)} + }; + + static const char *tags[] = { + ${lib.concatStringsSep ", " (map (t: "\"${t}\"") tags)} + }; + + static const Rule rules[] = { + ${lib.concatMapStringsSep ",\n" (setToString [ "class" "instance" "title" "tags" "isfloating" "monitor" ]) rules} + }; + + static const Layout layouts[] = { + ${lib.concatStringsSep ",\n" (map (l: "{ \"${l.symbol}\", ${l.function} }") layouts)} + }; + + static const Key keys[] = { + ${lib.concatMapStringsSep ",\n" (l: "{ ${toString (foldMod (l.mod or emptyList))}, ${l.key}, ${l.func}, ${funcArg (l.arg or "{0}")} }") keys} + }; + + static const Button buttons[] = { + ${lib.concatMapStringsSep ",\n" (l: "{ ${l.click}, ${toString (foldMod (l.mod or emptyList))}, ${l.button}, ${l.func}, ${funcArg (l.arg or "{0}")} }") buttons} + }; + ''; +in + +with pkgs; stdenv.mkDerivation rec { + name = "dwm"; + src = fetchGit { + url = "https://git.friedelschoen.io/suckless/dwm"; + rev = "2f0245c39087b0dfce6bb6a1c5269936ab2106b8"; + }; + + buildInputs = [ + xorg.libX11 + xorg.libXft + xorg.libXinerama + ]; + + configurePhase = '' + cp ${generateConfig} config.h + ''; + + buildPhase = '' + make all + ''; + + installPhase = '' + make PREFIX=$out install + ''; +} diff --git a/pkgs/make-service.nix b/pkgs/make-service.nix @@ -0,0 +1,40 @@ +{ pkgs ? import <nixpkgs> { }, system ? builtins.currentSystem }: + + +{ name, services, supervise }: +with pkgs; let + createSupervise = writeScript "${name}-create-supervise" '' + #!/bin/sh + + # create tmp/supervise.<service> (or whatever is specified) + mkdir -p ${lib.strings.concatStringsSep " " (map (sv: supervise sv.name) services)} + ''; + + linkDir = sv: '' + # create out/<service> (later ./) + mkdir -p $out/${sv.name} + + # change dir to ./out/<service> + cd $out/${sv.name} + + # ./supervise ./run are mandatory, thus just unconditional linking + ln -s ${supervise sv.name} ./supervise + ln -s ${sv.run} ./run + + # if ./setup is specified (not empty), link it + [ -n '${sv.setup}' ] && ln -s ${sv.setup} $out/${sv.name}/setup || true + + # if not enabled, create empty file ./down + [ '${toString sv.enable}' = 'false' ] && touch $out/${sv.name}/down || true + ''; + linkDirs = lib.strings.concatStrings (map linkDir services); + +in +runCommand name { } '' + #!/bin/sh + + mkdir -p $out + ln -s ${createSupervise} $out/create-supervise.sh + + ${linkDirs} +'' diff --git a/pkgs/pretty-svstat.nix b/pkgs/pretty-svstat.nix @@ -0,0 +1,17 @@ +{ pkgs ? import <nixpkgs> { }, config ? { } }: + +with pkgs; stdenv.mkDerivation { + name = "pretty-svstat"; + src = fetchGit { + url = "https://git.friedelschoen.io/pretty-svstat"; + rev = "7de4a8b1d49a5c0a72e17794c536d0b3e003bdcf"; + }; + + buildPhase = '' + make all + ''; + + installPhase = '' + make PREFIX=$out install + ''; +} diff --git a/pkgs/slstatus.nix b/pkgs/slstatus.nix @@ -0,0 +1,21 @@ +{ pkgs ? import <nixpkgs> { }, config ? { } }: + +with pkgs; stdenv.mkDerivation rec { + name = "slstatus"; + src = fetchGit { + url = "https://git.friedelschoen.io/suckless/slstatus"; + rev = "02281e5587b82b790533d7c4bbd146c561ee219c"; + }; + + buildInputs = [ + xorg.libX11 + ]; + + buildPhase = '' + make all + ''; + + installPhase = '' + make PREFIX=$out install + ''; +} diff --git a/pkgs/st.nix b/pkgs/st.nix @@ -0,0 +1,28 @@ +{ pkgs ? import <nixpkgs> { }, config ? { } }: + +with pkgs; stdenv.mkDerivation rec { + name = "st"; + src = fetchGit { + url = "https://git.friedelschoen.io/suckless/st"; + rev = "c9b37cad883f0e811f2a4f11ead78649c0474f73"; + }; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + fontconfig + freetype + xorg.libX11 + xorg.libXft + ]; + + buildPhase = '' + make all + ''; + + installPhase = '' + make PREFIX=$out install + ''; +} diff --git a/pkgs/void-runit.nix b/pkgs/void-runit.nix @@ -0,0 +1,35 @@ +{ pkgs ? import <nixpkgs> { } }: + +with pkgs; stdenv.mkDerivation rec { + name = "runit-utils"; + version = "20231124"; + + src = pkgs.fetchzip { + url = "https://github.com/void-linux/void-runit/archive/refs/tags/${version}.tar.gz"; + hash = "sha256-XGQcRaaGntAx4HFLTLZRjMGcejtJyJQEF/yXfQmzrZs="; + }; + + installPhase = '' + install -d $out/bin + install -m755 halt $out/bin + install -m755 pause $out/bin + install -m755 vlogger $out/bin + install -m755 shutdown $out/bin/shutdown + install -m755 modules-load $out/bin/modules-load + install -m755 seedrng $out/bin/seedrng + install -m755 zzz $out/bin + ln -sf zzz $out/bin/ZZZ + ln -sf halt $out/bin/poweroff + ln -sf halt $out/bin/reboot + install -d $out/share/man/man1 + install -m644 pause.1 $out/share/man/man1 + install -d $out/share/man/man8 + install -m644 zzz.8 $out/share/man/man8 + install -m644 shutdown.8 $out/share/man/man8 + install -m644 halt.8 $out/share/man/man8 + install -m644 modules-load.8 $out/share/man/man8 + install -m644 vlogger.8 $out/share/man/man8 + ln -sf halt.8 $out/share/man/man8/poweroff.8 + ln -sf halt.8 $out/share/man/man8/reboot.8 + ''; +} diff --git a/pkgs/weakbox.nix b/pkgs/weakbox.nix @@ -0,0 +1,20 @@ +{ pkgs ? import <nixpkgs> { }, config ? { } }: + +with pkgs; stdenv.mkDerivation rec { + name = "weakbox"; + src = fetchGit { + url = "https://git.friedelschoen.io/weakbox"; + rev = "8f7e0468e1fc92e57c8a77f1a49a67846fcce114"; + }; + + buildInputs = [ ]; + + buildPhase = '' + make all + ''; + + installPhase = '' + mkdir -p $out/bin/ $out/share/man/man1/ + make PREFIX=$out install + ''; +} diff --git a/services.nix b/services.nix @@ -0,0 +1,174 @@ +{ pkgs ? import <nixpkgs> { } }: + +with pkgs; [ + { + name = "9wm"; + enable = false; + setup = ""; + run = writeScript "9wm-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + cd $HOMEs + exec 9wm + ''; + } + { + name = "blueman-applet"; + enable = true; + setup = ""; + run = writeScript "blueman-applet-run" '' + #!/bin/sh + + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + exec blueman-applet + ''; + } + { + name = "dbus-session"; + enable = true; + setup = ""; + run = writeScript "dbus-session-run" '' + #!/bin/sh + + exec dbus-daemon --nofork --session + ''; + } + { + name = "dwm"; + enable = true; + setup = ""; + run = writeScript "dwm-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + cd $HOME + exec dwm + ''; + } + { + name = "nm-applet"; + enable = true; + setup = ""; + run = writeScript "nm-applet-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + exec nm-applet + ''; + } + { + name = "pa-applet"; + enable = true; + setup = ""; + run = writeScript "pa-applet-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + exec pa-applet + ''; + } + { + name = "slstatus"; + enable = true; + setup = ""; + run = writeScript "slstatus-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + FIFO=/tmp/slstatus.fifo + + [ -p $FIFO ] || rm -f $FIFO + mkfifo $FIFO + + exec slstatus -p $FIFO + ''; + } + { + name = "slstatus-xbps"; + enable = true; + setup = ""; + run = writeScript "slstatus-xbps-run" '' + #!/bin/bash + + OUTPUT=/tmp/xbps-updates.txt + + while true; do + updates=$(xbps-install -Mun | wc -l) + + if [ $updates -ne 0 ]; then + echo $updates > $OUTPUT + else + echo up-to-date > $OUTPUT + fi + sleep 120 + done + ''; + } + { + name = "stw-service"; + enable = true; + setup = ""; + run = writeScript "stw-service-run" '' + #!/bin/sh + + exec stw -p 1 -b '#ebdbb2' -f '#3c3836' -F 'Source Code Pro:size=9' -B 10 -y 20 sh -c 'echo -- services -- ; psv /var/service/* ~/.xservice/* 2> /dev/null | sort -k2,2 -k1,1' + ''; + } + { + name = "stw-xbps"; + enable = true; + setup = ""; + run = writeScript "stw-xbps-run" '' + #!/bin/sh + + exec stw -b '#ebdbb2' -f '#3c3836' -F 'Source Code Pro:size=9' -B 10 -p 120 -y 100% -Y -100% sh -c 'echo -- updates -- && xbps-install -Mun | cut -d" " -f1' + ''; + } + { + name = "tiramisu"; + enable = true; + setup = ""; + run = writeScript "tiramisu-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + SVDIR=.. sv check slstatus > /dev/null || exit 1 + + exec tiramisu -o '\\x04#source\\x05#summary: #body\\n' | xargs -i printf '%b' '{}' > /tmp/slstatus.fifo + ''; + } + { + name = "xfce-polkit"; + enable = true; + setup = ""; + run = writeScript "xfce-polkit-run" '' + #!/bin/sh + + SVDIR=.. sv check xserver > /dev/null || exit 1 + + exec /usr/libexec/xfce-polkit + ''; + } + { + name = "xserver"; + enable = true; + setup = ""; + run = writeScript "xserver-run" '' + #!/bin/sh + + if [ -z "$XDG_VTNR" ]; then + exec X -nolisten tcp $DISPLAY + else + exec X -nolisten tcp $DISPLAY vt$XDG_VTNR + fi + ''; + } +] diff --git a/suckless/dmenu b/suckless/dmenu @@ -1 +0,0 @@ -Subproject commit e9bea6daddb02bfdff2915ca781d03a4f071c5dd diff --git a/suckless/dwm b/suckless/dwm @@ -1 +0,0 @@ -Subproject commit 2233c02b84b2ad8c65ce7e809496eeb7dfaf3286 diff --git a/suckless/slstatus b/suckless/slstatus @@ -1 +0,0 @@ -Subproject commit 02281e5587b82b790533d7c4bbd146c561ee219c diff --git a/suckless/st b/suckless/st @@ -1 +0,0 @@ -Subproject commit 30e8006760a13f26d9d43341c846ab0dc401f4ab