Add modules for personal (CLI) machines

(NixOS + Home Manager)
This commit is contained in:
Quentin Boyer 2023-03-26 16:04:43 +02:00
parent 4fece8d5d7
commit ceff26b4e1
8 changed files with 69 additions and 46 deletions

29
personal-cli/hm.nix Normal file
View file

@ -0,0 +1,29 @@
{pkgs, ...}: {
home.packages = with pkgs; [
bitwarden-cli
hbw
kabalist_cli
nix-alien
nvfetcher
tokei
xdg-ninja
];
services.syncthing.enable = true;
programs.ssh.enable = true;
programs.zsh.initExtraBeforeCompInit = ''
fpath+="$HOME/.zfunc"
'';
home.file = {
bin = {
source = ./scripts;
recursive = true;
};
".zfunc" = {
source = ./zfunc;
recursive = true;
};
};
}

36
personal-cli/nixos.nix Normal file
View file

@ -0,0 +1,36 @@
{
pkgs,
config,
...
}: {
environment.systemPackages = [config.boot.kernelPackages.perf];
services.fwupd.enable = true;
services.openssh.enable = true;
virtualisation = {
libvirtd = {
enable = true;
qemu.swtpm.enable = true;
qemu.ovmf = {
enable = true;
packages = [pkgs.OVMFFull];
};
};
podman.enable = true;
docker = {
enable = true;
storageDriver = "btrfs";
};
};
networking.networkmanager.enable = true;
users.users."${config.extraInfo.username}".extraGroups = [
"networkmanager"
"libvirtd"
"kvm"
"qemu-libvirtd"
"docker"
];
}

View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
id=$(pw-dump | jq '
map(
select(
.info.props."application.name" == "spotify" and
.type == "PipeWire:Interface:Node")
)[-1].id'
)
current_volume=$(pw-dump | jq "
.[] |
select(.id == $id) |
.info.params.Props[0].volume"
)
new_volume=current_volume
case $1 in
*+)
if [ "$(bc <<< "$current_volume < 1")" -eq 1 ]; then
new_volume=$(bc <<< "$current_volume + ${1%+}")
fi
;;
*-)
if [ "$(bc <<< "$current_volume > 0")" -eq 1 ]; then
new_volume=$(bc <<< "$current_volume - ${1%-}")
fi
;;
*)
new_volume=$1
;;
esac
pw-cli set-param "$id" Props "{volume: $new_volume}"

View file

@ -0,0 +1,555 @@
#compdef kabalist_cli
autoload -U is-at-least
_kabalist_cli() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'-u+[]:URL: ' \
'--url=[]:URL: ' \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli_commands" \
"*::: :->kabalist_cli" \
&& ret=0
case $state in
(kabalist_cli)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-command-$line[1]:"
case $line[1] in
(account)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli__account_commands" \
"*::: :->account" \
&& ret=0
case $state in
(account)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-account-command-$line[1]:"
case $line[1] in
(login)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':name:' \
'::password:' \
&& ret=0
;;
(recover)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':id:' \
'::password:' \
&& ret=0
;;
(register)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':id:' \
':username:' \
'::password:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(list)
_arguments "${_arguments_options[@]}" \
'-t+[]:TOKEN: ' \
'--token=[]:TOKEN: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':list:' \
":: :_kabalist_cli__list_commands" \
"*::: :->list" \
&& ret=0
case $state in
(list)
words=($line[2] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-list-command-$line[2]:"
case $line[2] in
(delete)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(add)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':name:' \
'::amount:' \
&& ret=0
;;
(item)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':item:' \
":: :_kabalist_cli__list__item_commands" \
"*::: :->item" \
&& ret=0
case $state in
(item)
words=($line[2] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-list-item-command-$line[2]:"
case $line[2] in
(tick)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::name:' \
'::amount:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(share)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli__list__share_commands" \
"*::: :->share" \
&& ret=0
case $state in
(share)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-list-share-command-$line[1]:"
case $line[1] in
(add)
_arguments "${_arguments_options[@]}" \
'-r[]' \
'--readonly[]' \
'-h[Print help information]' \
'--help[Print help information]' \
':name:' \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" \
'--all[]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::names:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(public)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli__list__public_commands" \
"*::: :->public" \
&& ret=0
case $state in
(public)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-list-public-command-$line[1]:"
case $line[1] in
(set)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(history)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::search:' \
&& ret=0
;;
(pantry)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli__list__pantry_commands" \
"*::: :->pantry" \
&& ret=0
case $state in
(pantry)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-list-pantry-command-$line[1]:"
case $line[1] in
(add)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':name:' \
':target:' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" \
'-t+[]:TARGET: ' \
'--target=[]:TARGET: ' \
'-a+[]:AMOUNT: ' \
'--amount=[]:AMOUNT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':item:' \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':item:' \
&& ret=0
;;
(refill)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(lists)
_arguments "${_arguments_options[@]}" \
'-t+[]:TOKEN: ' \
'--token=[]:TOKEN: ' \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_kabalist_cli__lists_commands" \
"*::: :->lists" \
&& ret=0
case $state in
(lists)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:kabalist_cli-lists-command-$line[1]:"
case $line[1] in
(create)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':list:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(completions)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':shell:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
}
(( $+functions[_kabalist_cli_commands] )) ||
_kabalist_cli_commands() {
local commands; commands=(
'account:' \
'list:' \
'lists:' \
'completions:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli commands' commands "$@"
}
(( $+functions[_kabalist_cli__account_commands] )) ||
_kabalist_cli__account_commands() {
local commands; commands=(
'login:' \
'recover:' \
'register:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli account commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__add_commands] )) ||
_kabalist_cli__list__add_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list add commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry__add_commands] )) ||
_kabalist_cli__list__pantry__add_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list pantry add commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__share__add_commands] )) ||
_kabalist_cli__list__share__add_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list share add commands' commands "$@"
}
(( $+functions[_kabalist_cli__completions_commands] )) ||
_kabalist_cli__completions_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli completions commands' commands "$@"
}
(( $+functions[_kabalist_cli__lists__create_commands] )) ||
_kabalist_cli__lists__create_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli lists create commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__delete_commands] )) ||
_kabalist_cli__list__delete_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list delete commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry__delete_commands] )) ||
_kabalist_cli__list__pantry__delete_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list pantry delete commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__share__delete_commands] )) ||
_kabalist_cli__list__share__delete_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list share delete commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry__edit_commands] )) ||
_kabalist_cli__list__pantry__edit_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list pantry edit commands' commands "$@"
}
(( $+functions[_kabalist_cli__account__help_commands] )) ||
_kabalist_cli__account__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli account help commands' commands "$@"
}
(( $+functions[_kabalist_cli__help_commands] )) ||
_kabalist_cli__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__help_commands] )) ||
_kabalist_cli__list__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__item__help_commands] )) ||
_kabalist_cli__list__item__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list item help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry__help_commands] )) ||
_kabalist_cli__list__pantry__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list pantry help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__public__help_commands] )) ||
_kabalist_cli__list__public__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list public help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__share__help_commands] )) ||
_kabalist_cli__list__share__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list share help commands' commands "$@"
}
(( $+functions[_kabalist_cli__lists__help_commands] )) ||
_kabalist_cli__lists__help_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli lists help commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__history_commands] )) ||
_kabalist_cli__list__history_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list history commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__item_commands] )) ||
_kabalist_cli__list__item_commands() {
local commands; commands=(
'tick:' \
'update:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli list item commands' commands "$@"
}
(( $+functions[_kabalist_cli__list_commands] )) ||
_kabalist_cli__list_commands() {
local commands; commands=(
'delete:' \
'add:' \
'item:' \
'share:' \
'public:' \
'history:' \
'pantry:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli list commands' commands "$@"
}
(( $+functions[_kabalist_cli__lists_commands] )) ||
_kabalist_cli__lists_commands() {
local commands; commands=(
'create:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli lists commands' commands "$@"
}
(( $+functions[_kabalist_cli__account__login_commands] )) ||
_kabalist_cli__account__login_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli account login commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry_commands] )) ||
_kabalist_cli__list__pantry_commands() {
local commands; commands=(
'add:' \
'edit:' \
'delete:' \
'refill:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli list pantry commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__public_commands] )) ||
_kabalist_cli__list__public_commands() {
local commands; commands=(
'set:' \
'remove:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli list public commands' commands "$@"
}
(( $+functions[_kabalist_cli__account__recover_commands] )) ||
_kabalist_cli__account__recover_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli account recover commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__pantry__refill_commands] )) ||
_kabalist_cli__list__pantry__refill_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list pantry refill commands' commands "$@"
}
(( $+functions[_kabalist_cli__account__register_commands] )) ||
_kabalist_cli__account__register_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli account register commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__public__remove_commands] )) ||
_kabalist_cli__list__public__remove_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list public remove commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__public__set_commands] )) ||
_kabalist_cli__list__public__set_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list public set commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__share_commands] )) ||
_kabalist_cli__list__share_commands() {
local commands; commands=(
'add:' \
'delete:' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'kabalist_cli list share commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__item__tick_commands] )) ||
_kabalist_cli__list__item__tick_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list item tick commands' commands "$@"
}
(( $+functions[_kabalist_cli__list__item__update_commands] )) ||
_kabalist_cli__list__item__update_commands() {
local commands; commands=()
_describe -t commands 'kabalist_cli list item update commands' commands "$@"
}
_kabalist_cli "$@"