nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit 483b364274fa9631bcb66ebf4d3909d7b2ccea27
parent c9e14de156f61bd82a3a33370c4a71ebd803f250
Author: mtmn <miro@haravara.org>
Date:   Sat, 27 Jun 2026 16:07:11 +0200

void: elvish, shaarli, etc.

Diffstat:
Mflake.lock | 6+++---
Mhosts/nixaran/configuration.nix | 0
Mhosts/void/default.nix | 2++
Amodules/mixins/dotfiles/config/elvish/lib/aliases.elv | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/config/elvish/lib/git.elv | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/config/elvish/rc.elv | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/services/shaarli.nix | 162+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 410 insertions(+), 3 deletions(-)

diff --git a/flake.lock b/flake.lock @@ -162,11 +162,11 @@ ] }, "locked": { - "lastModified": 1782423922, - "narHash": "sha256-qPNd6lUohHP5gcJhqQ7rLV87RwIx0xYR2A4Frb9Zjc4=", + "lastModified": 1782522538, + "narHash": "sha256-CvOaUvJ+mXlxU3m2cPWKcOAhtKETsPUYhq+Xa5ewBp4=", "owner": "nix-community", "repo": "home-manager", - "rev": "5d320ab301cfaaca7d32514f13815d19d109f5f4", + "rev": "8d8a6cc50ddc60748791a14ee1163c865ec57635", "type": "github" }, "original": { diff --git a/hosts/nixaran/configuration.nix b/hosts/nixaran/configuration.nix Binary files differ. diff --git a/hosts/void/default.nix b/hosts/void/default.nix @@ -81,6 +81,7 @@ bore-cli ldns bind + vnstat ] (with python314Packages; [yt-dlp-ejs]) ]; @@ -133,6 +134,7 @@ fswatch lf fontpreview + elvish ]; nix = [ diff --git a/modules/mixins/dotfiles/config/elvish/lib/aliases.elv b/modules/mixins/dotfiles/config/elvish/lib/aliases.elv @@ -0,0 +1,127 @@ +fn ls { |@rest| e:eza -a --sort=modified $@rest } +fn eza { |@rest| e:eza -a --sort=modified $@rest } +fn fd { |@rest| e:fd --color never --hidden --exclude .git --exclude $E:HOME/misc/mnt --exclude /nix $@rest } +fn rg { |@rest| e:rg --hidden -i $@rest } +fn vim { |@rest| e:nvim $@rest } +fn less { |@rest| e:less -R $@rest } +fn cp { |@rest| e:cp --backup=numbered --reflink=auto --sparse=always $@rest } +fn mv { |@rest| e:mv --backup=numbered $@rest } +fn ln { |@rest| e:ln --backup=numbered $@rest } +fn sudo { |@rest| e:sudo $@rest } +fn watch { |@rest| e:watch $@rest } +fn bazel { |@rest| e:bazelisk $@rest } +fn wl-copy { |@rest| e:wl-copy -n $@rest } +fn wl-paste { |@rest| e:wl-paste -n $@rest } + +fn l { |@rest| ls $@rest } +fn la { |@rest| ls -a $@rest } +fn ll { |@rest| ls -l $@rest } + +fn f { |@rest| magdalena look-file $@rest } +fn m { |@rest| mntmenu $@rest } +fn p { |@rest| pmn $@rest } +fn q { |@rest| sudo $@rest } + +fn tst { |@rest| e:tmux set status $@rest } +fn tls { e:tmux list-sessions } +fn tms { e:tmux display-message -p '#{session_name}' } + +fn mgr { |@rest| magdalena grep $@rest } +fn mrd { magdalena recent-dirs } +fn mrf { magdalena recent-files } + +fn alt { |@rest| aaltomuoto $@rest } +fn vrt { |@rest| virittaa $@rest } +fn hkn { |@rest| hakuna $@rest } + +fn mach { |@rest| matcha $@rest } +fn machp { |@rest| matcha --playlist $@rest } + +fn duh { |@rest| du -hs $@rest } +fn dfh { df -h } + +fn lopri { |@rest| nice -n 19 ionice -c2 -n7 $@rest } + +fn pps { podman ps } +fn plo { |@rest| podman logs $@rest } +fn pst { podman stats } +fn pbu { |@rest| podman build $@rest } +fn pcu { |@rest| podman-compose up $@rest } +fn pcd { |@rest| podman-compose down $@rest } +fn pcs { |@rest| podman-compose stop $@rest } + +fn mpva { |@rest| mpv --no-video $@rest } +fn pp { mpc toggle } +fn qq { mpc playlist } +fn mpa { |@rest| mpc add $@rest } + +fn n { |@rest| nota $@rest } +fn no { |@rest| nota $@rest } +fn to { nota today } +fn ye { nota yesterday } +fn tom { nota tomorrow } +fn todo { nota todo } +fn wish { nota wishlist } + +fn kat { |@rest| khal at $@rest } +fn khi { khal interactive } +fn khl { |@rest| khal list $@rest } +fn khlw { khal list now 7d } + +fn bpp { backup -t git:pass -p } +fn bnp { backup -t git:nota -p } +fn brr { backup -t git:releases -p } +fn bak { |@rest| backup $@rest } +fn bakg { |@rest| backup -t git $@rest } +fn bakm { |@rest| backup -t mobius $@rest } + +fn nr { newsraft } +fn nre { e:nvim ~/src/sr.ht/nix/modules/mixins/dotfiles/config/newsraft/feeds } + +fn cbd { |@rest| cargo build $@rest } +fn cbr { |@rest| cargo build --release $@rest } +fn cip { |@rest| cargo install --path $@rest } +fn cup { |@rest| cargo update --recursive $@rest } + +fn ap { |@rest| ansible-playbook --diff $@rest } +fn apc { |@rest| ansible-playbook --check --diff $@rest } + +fn nd { |@rest| nix develop $@rest } +fn hms { just --justfile ~/src/sr.ht/nix/justfile home } +fn hmd { just --justfile ~/src/sr.ht/nix/justfile diff } +fn nmdr { just --justfile ~/src/sr.ht/nix/justfile diffr } +fn ndpj { just --justfile ~/src/sr.ht/nix/justfile deploy } + +fn ju { |@rest| just $@rest } +fn rnj { just run } +fn dfj { just diff } +fn chj { just check } +fn bdj { just build } +fn dpj { just deploy } + +fn amsp { mpv --no-video https://radio.stereoscenic.com/asp-s --no-resume-playback } +fn nts1 { mpv --no-video https://stream-relay-geo.ntslive.net/stream --no-resume-playback } +fn nts2 { mpv --no-video https://stream-relay-geo.ntslive.net/stream2 --no-resume-playback } + +fn mf { monofetch } +fn sr { |@rest| speedread -w 400 $@rest } +fn jlr { |@rest| jless --mode line $@rest } + +fn chop { perl -pe chop } +fn chomp { perl -pe chomp } + +fn bexec { |@rest| bundle exec $@rest } +fn brake { |@rest| bexec rake $@rest } + +fn chav { |@rest| cha --visual $@rest } +fn pwc { pwd | wl-copy -n } + +fn tt { rg -N -B 1 "^todo:" ~/.nb/notes/todo.txt } +fn tn { todo-notify } + +fn tww { |channel| e:mpv https://twitch.tv/$channel --no-terminal --no-resume-playback & } + +fn dmesg { e:dmesg -T --color=always | e:less -R +G } +fn ncdu { e:sudo ncdu -x --exclude /nix --exclude $E:HOME/misc/mnt / } +fn gdb { |@rest| e:gdb -q $@rest } +fn ipython { |@rest| e:ipython --no-banner $@rest } diff --git a/modules/mixins/dotfiles/config/elvish/lib/git.elv b/modules/mixins/dotfiles/config/elvish/lib/git.elv @@ -0,0 +1,50 @@ +fn cdg { cd (git rev-parse --show-toplevel) } +fn gst { |@rest| git status $@rest } +fn ng { e:nvim -c :Neogit } + +fn gprl { |@rest| git-prole $@rest } +fn gprla { |@rest| git-prole add $@rest } +fn gprlc { |@rest| git-prole convert $@rest } + +fn gn { |@rest| git number --column $@rest } +fn ga { |@rest| git number add $@rest } +fn gc { |@rest| git commit -v $@rest } +fn gcp { |@rest| git cherry-pick --strategy=recursive --strategy-option=diff-algorithm=histogram $@rest } +fn gd { |@rest| git diff --no-prefix $@rest } +fn gl { |@rest| git gol $@rest } +fn gm { |@rest| git merge $@rest } +fn gmc { |@rest| git merge --no-ff $@rest } +fn gp { |@rest| git push $@rest } +fn gs { |@rest| git show --no-prefix $@rest } +fn gref { git reflog --date=iso } + +fn grr { |@rest| git rebase -r $@rest } +fn gri { |@rest| grr -i $@rest } +fn grrm { grr master@{u} } +fn gru { grr @{u} } +fn gabs { git absorb --and-rebase } + +fn gdm { git diff --no-prefix (git merge-base master@{u} HEAD)..HEAD } +fn gdma { git diff --no-prefix (git merge-base main@{u} HEAD)..HEAD } +fn gdd { git diff --no-prefix (git merge-base develop@{u} HEAD)..HEAD } +fn gdu { git diff --no-prefix @{u}.. } +fn gdc { git diff --no-prefix --cached } +fn gdw { git diff --no-prefix --color-words } + +fn ghr { |@rest| git history reword $@rest } +fn ghs { |@rest| git history split $@rest } + +fn gco { |@rest| git checkout $@rest } +fn gsw { |@rest| git switch $@rest } + +fn glm { gl master@{u}.. } +fn glma { gl main@{u}.. } +fn glu { gl @{u}.. } + +fn gap { ga -p } +fn gca { |@rest| gc -a $@rest } +fn gcaa { gca --amend } +fn grh { |@rest| git reset --hard $@rest } +fn grhu { grh @{u} } +fn gpf { gp -f } +fn gcl { git clean -dffx } diff --git a/modules/mixins/dotfiles/config/elvish/rc.elv b/modules/mixins/dotfiles/config/elvish/rc.elv @@ -0,0 +1,66 @@ +use path +use str + +# env +set E:LC_COLLATE = C +set E:EDITOR = nvim +set E:PAGER = less +set E:LESS = -R +set E:VISUAL = nvim +set E:PYTHONDONTWRITEBYTECODE = 1 +set E:PYTHONSTARTUP = $E:HOME/.pythonrc +set E:BROWSER = firefox +set E:NSS_DEFAULT_DB_TYPE = sql +set E:BC_ENV_ARGS = $E:HOME/.config/bcrc +set E:SSH_AUTH_SOCK = $E:XDG_RUNTIME_DIR/ssh-agent.socket +set E:GOPATH = $E:HOME/src/misc/go +set E:MPD_HOST = 127.0.0.1 +set E:MPD_PORT = 6695 +set E:CARGO_TERM_COLOR = always +set E:ZVM_INSTALL = $E:HOME/.zvm/self +set E:MANPAGER = 'nvim +Man!' +set E:FZF_DEFAULT_OPTS = '--highlight-line --ansi --layout=reverse --border=rounded + --color=bg+:#1d3b2e,bg:-1,spinner:#7fdbca,hl:#7fdbca + --color=fg:#d6deeb,header:#637777,info:#637777,pointer:#7fdbca + --color=marker:#7fdbca,fg+:#d6deeb,prompt:#7fdbca,hl+:#7fdbca + --color=border:#0d1612' + +set paths = [ + $E:HOME/.local/share/tools + $E:HOME/.local/share/gem/ruby/3.4.0/bin + $E:HOME/src/go/bin + $E:HOME/.zvm/bin + $E:HOME/.zvm/self + $E:HOME/src/misc/go/bin + $E:HOME/.node_modules/bin + /usr/bin/vendor_perl + /usr/bin/core_perl + /usr/bin/site_perl + $E:HOME/bin + $E:HOME/.local/bin + $E:HOME/.cargo/bin + $E:HOME/go/bin + /usr/local/sbin + /usr/local/bin + /usr/sbin + /usr/bin + /sbin + /bin + /usr/share/bcc + /nix/var/nix/profiles/default/bin + $E:HOME/.nix-profile/bin + $@paths +] + +# load aliases and functions into current namespace +fn -load { |f| eval (slurp < $f) } + +var lib = $E:HOME/.config/elvish/lib +-load $lib/aliases.elv +-load $lib/git.elv + +# stty +try { e:stty -ixon -ixoff } catch { } + +# zoxide +eval (zoxide init elvish | slurp) diff --git a/modules/services/shaarli.nix b/modules/services/shaarli.nix @@ -0,0 +1,162 @@ +{ + config, + lib, + pkgs, + haravara, + ... +}: let + cfg = config.services.haravara.shaarli; + stateDir = "/var/lib/shaarli"; + webRoot = "${stateDir}/www"; + user = "shaarli"; + group = "shaarli"; + pool = "shaarli"; + socket = "/run/phpfpm/${pool}.sock"; + + phpWithExtensions = pkgs.php.withExtensions ({ + enabled, + all, + }: + enabled + ++ [ + all.curl + all.gd + all.gettext + all.intl + all.mbstring + all.zlib + ]); + + theme = pkgs.fetchFromGitHub { + owner = "ManufacturaInd"; + repo = "shaarli-2004licious-theme"; + rev = "075833c547c6ca281e7ad31591f5ab0e9a99efcc"; + sha256 = "16qzzshlyhdrawa3g8jg22j2fb6acmd0smg0ca5ilhjxakip3h81"; + }; +in { + options.services.haravara.shaarli = { + enable = lib.mkEnableOption "Shaarli bookmark manager"; + domain = lib.mkOption { + type = lib.types.str; + }; + authLabel = haravara.authLabelOption; + }; + + config = lib.mkIf cfg.enable { + users.users.${user} = { + isSystemUser = true; + inherit group; + home = stateDir; + createHome = false; + }; + users.groups.${group} = {}; + + systemd.tmpfiles.rules = [ + "d ${stateDir} 0755 ${user} ${group} -" + ]; + + systemd.services.shaarli-init = { + description = "Initialize Shaarli webroot"; + after = ["systemd-tmpfiles-setup.service"]; + before = ["phpfpm-${pool}.service"]; + requiredBy = ["phpfpm-${pool}.service"]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + User = user; + Group = group; + + CapabilityBoundingSet = ""; + LockPersonality = true; + NoNewPrivileges = true; + PrivateDevices = true; + PrivateMounts = true; + PrivateTmp = true; + PrivateUsers = true; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectSystem = "strict"; + ReadWritePaths = [stateDir]; + RestrictAddressFamilies = "AF_UNIX"; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; + SystemCallArchitectures = "native"; + SystemCallFilter = ["@system-service" "~@privileged"]; + }; + script = '' + set -euo pipefail + + pkg="${pkgs.shaarli}" + themeSrc="${theme}/2004licious" + stamp="${stateDir}/.src" + themeStamp="${stateDir}/.theme-src" + + rm -rf "${stateDir}/.www-new" "${stateDir}/.www-old" + + if [ ! -f "$stamp" ] || [ "$(cat "$stamp")" != "$pkg" ]; then + cp -r "$pkg" "${stateDir}/.www-new" + chmod -R u+w "${stateDir}/.www-new" + + for dir in data pagecache cache tmp; do + rm -rf "${stateDir}/.www-new/$dir" + if [ -d "${webRoot}/$dir" ]; then + cp -r "${webRoot}/$dir" "${stateDir}/.www-new/$dir" + fi + done + + chmod -R a+rX "${stateDir}/.www-new" + + [ -d "${webRoot}" ] && mv "${webRoot}" "${stateDir}/.www-old" + mv "${stateDir}/.www-new" "${webRoot}" + rm -rf "${stateDir}/.www-old" + + printf '%s' "$pkg" > "$stamp" + rm -f "$themeStamp" + fi + + for dir in data pagecache cache tmp; do + mkdir -p "${webRoot}/$dir" + chmod 0750 "${webRoot}/$dir" + done + + if [ ! -f "$themeStamp" ] || [ "$(cat "$themeStamp")" != "$themeSrc" ]; then + rm -rf "${webRoot}/tpl/2004licious" + mkdir -p "${webRoot}/tpl" + cp -r "$themeSrc" "${webRoot}/tpl/2004licious" + chmod -R u+w,a+rX "${webRoot}/tpl/2004licious" + printf '%s' "$themeSrc" > "$themeStamp" + fi + ''; + }; + + services.phpfpm.pools.${pool} = { + inherit user group; + phpPackage = phpWithExtensions; + settings = { + "listen" = socket; + "listen.owner" = "caddy"; + "listen.group" = "caddy"; + "listen.mode" = "0660"; + "pm" = "dynamic"; + "pm.max_children" = 5; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 1; + "pm.max_spare_servers" = 3; + }; + }; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' + ${haravara.mkAuthImport cfg.authLabel} + root * ${webRoot} + php_fastcgi unix/${socket} + file_server + ''; + }; +}