home and away

This commit is contained in:
2025-11-29 05:20:22 +01:00
parent 2af0e99c76
commit 24d6516e1b
45 changed files with 486 additions and 336 deletions

View File

@@ -21,7 +21,7 @@
programs.bash.shellAliases."ed" = "\${EDITOR:-micro}";
environment.variables."EDITOR" = "micro";
# autologin:
# autologin: (put in host config)
# services.displayManager.autoLogin.enable = true;
# services.displayManager.autoLogin.user = "pbsds";
@@ -29,9 +29,19 @@
#nix.trusted-users = [ "pbsds" ];
home-manager.users.pbsds = if config.services.xserver.desktopManager.gnome.enable
then ./home/gnome.nix
else ./home;
# ./home/profiles/minimal
# ./home/profiles/headless
# ./home/profiles/comfy
# ./home/profiles/desktop (gnome)
home-manager.users.pbsds = lib.mkMerge [
(
if config.services.xserver.desktopManager.gnome.enable then
./home/profiles/desktop/gnome
else
./home/profiles/comfy
)
{ home.stateVersion = config.system.stateVersion; }
];
nix.settings.allowed-users = [ "pbsds" ];
nix.settings.trusted-users = [ "pbsds" ];

View File

@@ -1,9 +0,0 @@
# https://nix-community.github.io/home-manager/options.html
{ pkgs, config, ... }:
{
imports = [
./default.nix
./profiles/desktop
./profiles/desktop/gnome
];
}

View File

@@ -1,38 +0,0 @@
# https://nix-community.github.io/home-manager/options.html
{ pkgs, lib, config, ... }:
{
#nixpkgs.config.allowUnfree = true;
home.stateVersion = "23.11";
home.preferXdgDirectories = true;
imports = [
./profiles/bashrc.d
#./profiles/sops.nix
./profiles/bat.nix
#./profiles/xdg-ninja.nix
./profiles/git.nix
./profiles/nix.nix
./profiles/pueue.nix
./profiles/micro.nix
./profiles/shell.nix
./profiles/ssh.nix
/* ./profiles/tmate.nix */
./profiles/update-diff.nix
];
home.packages = [
pkgs.android-tools
];
# https://docs.astral.sh/uv/configuration/files/
# https://docs.astral.sh/uv/reference/settings/
xdg.configFile."uv/uv.toml".source = (pkgs.formats.toml { }).generate "uv-config" {
python-downloads = "never";
python-preference = "only-system";
pip.index-url = "https://test.pypi.org/simple";
};
home.enableNixpkgsReleaseCheck = true;
}

View File

@@ -1,71 +0,0 @@
_nix_fd() (
set -euo pipefail
declare nix="${1:-}"; shift
if [[ $# -lt 2 ]]; then
printf >&2 "%s\n" "ERROR: not enough args"
false
fi
target_nix=0
in_fd_nargs=false
fd_pattern=()
fd_flags=()
nix_args=()
nix_flags=()
# set -x
for arg in "$@"; do
# separator
if [[ "$arg" = "--" ]]; then
if "$in_fd_nargs"; then
in_fd_nargs=false
fi
(( target_nix ^= 1 )) ||:
# flag
elif [[ "$arg" =~ ^- ]]; then
if [[ $target_nix -eq 0 ]] || $in_fd_nargs; then
fd_flags+=("$arg")
if [[ "$arg" = "-x" ]]; then
in_fd_nargs=true
fi
else
nix_flags+=("$arg")
fi
# arg
elif [[ ! -v fd_pattern[0] ]]; then
fd_pattern+=("$arg")
elif $in_fd_nargs; then
fd_flags+=("$arg")
elif [[ $target_nix -ne 0 ]]; then
nix_flags+=("$arg")
elif [[ "${arg}" =~ ^.*[#:/].*$ ]]; then
nix_args+=("$arg")
else
nix_args+=("nixpkgs#$arg")
fi
done
# echo + "$nix" build "${nix_args[@]}" "${nix_flags[@]}"
# echo + fd "${fd_pattern[@]}" ... "${fd_flags[@]}"
# return
readarray -d $'\n' -t storepaths < <(
"$nix" build "${nix_args[@]}" "${nix_flags[@]}" --print-out-paths --no-link
)
if [[ "${#storepaths[@]}" -gt 0 ]]; then
fd "${fd_pattern[@]}" "${storepaths[@]}" "${fd_flags[@]}"
fi
)
nix-fd() { _nix_fd "nix" "$@"; }
if command -v nom >/dev/null; then
nom-fd() { _nix_fd "nom" "$@"; }
fi
nixfd() {
echo >&2 "did you mean 'nix-fd'?"
false
}

View File

@@ -4,7 +4,7 @@
(lib.filterAttrs (k: v: v == "regular"))
(lib.filterAttrs (k: v: lib.hasSuffix ".sh" k))
lib.attrNames
/* (map (x: builtins.readFile ./${x})) */
# (map (x: builtins.readFile ./${x}))
(map (x: "source ${./${x}}"))
lib.concatLines
];

View File

@@ -0,0 +1,141 @@
_nix_storepath_in_cmd() (
set -euo pipefail
declare nix="${1:-}"
declare cmd="${2:-}"
# declare arg2narg="${3:-}"
declare nth
# for nth in 1st 2nd 3rd; do
for nth in 1st 2nd; do
if [[ -z "${1:-}" ]] && ! shift; then
echo >&2 "_nix_storepath_in_cmd() ERROR: missing $nth param"
false
fi
done
if [[ $# -lt 2 ]]; then
printf >&2 "%s\n" "ERROR: not enough args"
false
fi
target_nix=0
in_cmd_nargs=false # TODO: turn into countdown
cmd_pattern=()
cmd_flags=()
nix_args=()
nix_flags=()
# set -x
for arg in "$@"; do
# separator - swaps target
if [[ "$arg" = "--" ]]; then
if "$in_cmd_nargs"; then
in_cmd_nargs=false
fi
((target_nix ^= 1)) || :
# flag
elif [[ "$arg" =~ ^- ]]; then
if [[ $target_nix -eq 0 ]] || $in_cmd_nargs; then
cmd_flags+=("$arg")
if [[ "$arg" = "-x" ]]; then
in_cmd_nargs=true
fi
else
nix_flags+=("$arg")
fi
# arg
elif [[ ! -v cmd_pattern[0] ]]; then
cmd_pattern+=("$arg")
elif $in_cmd_nargs; then
cmd_flags+=("$arg")
elif [[ $target_nix -ne 0 ]]; then
nix_flags+=("$arg")
elif [[ "${arg}" =~ ^.*[#:/].*$ ]]; then
nix_args+=("$arg")
else
nix_args+=("nixpkgs#$arg")
fi
done
# echo + "$nix" build "${nix_args[@]}" "${nix_flags[@]}"
# echo + fd "${cmd_pattern[@]}" ... "${cmd_flags[@]}"
# return
readarray -d $'\n' -t storepaths < <(
"$nix" build "${nix_args[@]}" "${nix_flags[@]}" --print-out-paths --no-link
)
if [[ "${#storepaths[@]}" -gt 0 ]]; then
fd "${cmd_pattern[@]}" "${storepaths[@]}" "${cmd_flags[@]}"
fi
)
if command -v fd >/dev/null; then
__fd_arg2narg() {
case "$1" in
-x) echo '+' ;;
# TODO:
# ) echo 1 ;;
*) ;;
esac
}
# nix-fd() { _nix_storepath_in_cmd "nix" "fd" __fd_arg2narg "$@"; }
nix-fd() { _nix_storepath_in_cmd "nix" "fd" "$@"; }
if command -v nom >/dev/null; then
nom-fd() { _nix_storepath_in_cmd "nom" "fd" "$@"; }
fi
fi
if command -v rg >/dev/null; then
__rg_arg2narg() {
case "$1" in
-e | --regexp) echo 1 ;;
-f | --file) echo 1 ;;
--pre) echo 1 ;;
--dfa-size-limit) echo 1 ;;
-E | --encoding) echo 1 ;;
--engine) echo 1 ;;
-m | --max-count) echo 1 ;;
--regex-size-limit) echo 1 ;;
-j | --threads) echo 1 ;;
-g | --glob | --iglob) echo 1 ;;
--ignore-file) echo 1 ;;
-d | --max-depth) echo 1 ;;
--max-filesize) echo 1 ;;
-t | --type) echo 1 ;;
-T | --type-not) echo 1 ;;
--type-add) echo 1 ;;
--type-clear) echo 1 ;;
-A | --after-context) echo 1 ;;
-B | --before-context) echo 1 ;;
--color) echo 1 ;;
--colors) echo 1 ;;
--colors) echo 1 ;;
-C | --context) echo 1 ;;
--context-separator) echo 1 ;;
--field-context-separator) echo 1 ;;
--field-match-separator) echo 1 ;;
--hostname-bin) echo 1 ;;
--hyperlink-format) echo 1 ;;
-M | --max-columns) echo 1 ;;
--path-separator) echo 1 ;;
-r | --replace) echo 1 ;;
--sort) echo 1 ;;
--sortr) echo 1 ;;
--generate) echo 1 ;;
*) ;;
esac
}
# nix-rg() { _nix_storepath_in_cmd "nix" "rg" __rg_arg2narg "$@"; }
nix-rg() { _nix_storepath_in_cmd "nix" "rg" "$@"; }
if command -v nom >/dev/null; then
# nom-rg() { _nix_storepath_in_cmd "nom" "rg" __rg_arg2narg "$@"; }
nom-rg() { _nix_storepath_in_cmd "nom" "rg" "$@"; }
fi
fi
nixfd() {
echo >&2 "did you mean 'nix-fd'?"
false
}

View File

@@ -164,3 +164,5 @@ nix-search() (
fi
fi
)
# TODO: add a bash keybind, like the fzf file picker?

View File

@@ -1,16 +1,26 @@
# https://nix-community.github.io/home-manager/options.html
{ pkgs, lib, config, ... }:
{ pkgs, ... }:
{
imports = [
./minimal.nix
./profiles/gtk.nix
# ./profiles/beets.nix
./profiles/ast-grep.nix
./profiles/desktop/zed/remote.nix # lsps for remote zed development
# ../../minimal.nix
../minimal
../headless
./bashrc.d
./nix.nix
./nix-index.nix
./ast-grep.nix
./gtk-theme.nix # TODO: move to headless?
# ./beets.nix
../desktop/zed/remote.nix # lsps for remote zed development
];
#TODO: xdg.desktopEntries
# TODO: only applies to nox...
home.shellAliases.flexget = "ssh -t noximilien sudo --user=flexget flexget -c /var/lib/flexget/flexget.yml";
home.packages = with pkgs; [
xclip
android-tools
shpool
@@ -43,12 +53,13 @@
boxes
tewisay
ponysay
krabby
# TODO: move to graphical? kiosk?
cage
mesa-demos
librespeed-cli
# librespeed-cli # provides `speedtest-cli`
#cargo
#cargo-update
@@ -74,13 +85,9 @@
]))
];
xdg.enable = true;
#TODO: xdg.desktopEntries
xdg.configFile."ptpython/config.py" = {
source = ./files/ptpython-config.py;
force = true;
};
}

View File

@@ -0,0 +1,5 @@
{
programs.nix-index.enable = true;
programs.nix-index-database.comma.enable = true; # via nix-index-database flake
#programs.command-not-found.enable = false; # mutex with nix-index
}

View File

@@ -0,0 +1,39 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
# flox
# devenv
# cachix
# nix-template
nix-output-monitor
nix-du
nix-tree
nix-visualize
nix-inspect
nix-btm
unstable.nixpkgs-review bubblewrap
unstable.nixpkgs-hammering
unstable.nix-update
unstable.nix-init
unstable.deadnix
unstable.statix
# unstable.nixtract
unstable.nixfmt-rfc-style
nurl
# manix
# comma # collides with nix-index-database
# devenv
nix-fast-build
nix-eval-jobs
];
# TODO: move to bashrc.d
programs.bash.initExtra = ''
nix-prefetch-sri() {
url="$1"; shift
nix hash to-sri --type sha256 "$@" "$(nix-prefetch-url "$url")"
}
'';
}

View File

@@ -0,0 +1,11 @@
{ lib, ... }:
{
programs.bash.initExtra = lib.pipe (builtins.readDir ./.) [
(lib.filterAttrs (k: v: v == "regular"))
(lib.filterAttrs (k: v: lib.hasSuffix ".sh" k))
lib.attrNames
# (map (x: builtins.readFile ./${x}))
(map (x: "source ${./${x}}"))
lib.concatLines
];
}

View File

@@ -1,8 +1,9 @@
{ pkgs, lib, ... }:
{
imports = [
../comfy
./bashrc.d
./lxterminal
./ghostty
./pulsar

View File

@@ -28,6 +28,14 @@ let
in
{
imports = [
../. # desktop
./dconf-gnome-bindings.nix
./dconf-gnome-behaviour.nix
./dconf-gnome-extensions.nix
./dconf-gnome-theme.nix
];
# TODO: move or remove
home.file.".local/opt/open-microsoft-url-files.py".source = ../../../files/opt/open-microsoft-url-files.py;
home.file.".local/opt/python-interactive-imports.py".source = ../../../files/opt/python-interactive-imports.py;
@@ -46,13 +54,6 @@ in
qt.style.name = "Vimix-dark-doder"; # TODO: build ruby variant
qt.style.package = pkgs.vimix-gtk-themes;
imports = [
./dconf-gnome-bindings.nix
./dconf-gnome-behaviour.nix
./dconf-gnome-extensions.nix
./dconf-gnome-theme.nix
];
home.packages = [
(pkgs.gnome-tweaks or pkgs.gnome.gnome-tweaks)
pkgs.vimix-gtk-themes # shell theme
@@ -60,6 +61,7 @@ in
dconf.settings = with lib.hm.gvariant; {
# extensions:
# kinda manual lol
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = lib.forEach gnomeExtensions (pkg: pkg.extensionUuid);

View File

@@ -0,0 +1,13 @@
# https://nix-community.github.io/home-manager/options.html
{ pkgs, lib, config, ... }:
{
imports = [
../minimal
./shell.nix
./git.nix
./fzf.nix
./eza.nix
./pueue.nix
./update-diff.nix
];
}

View File

@@ -0,0 +1,12 @@
{ lib, config, ... }:
{
# TODO: slow when colors are enabled, use lsd instead?
# https://github.com/eza-community/eza/issues/922
programs.eza.enable = true;
programs.eza.enableAliases = lib.mkIf (lib.versionOlder config.home.version.release "24.05") true;
programs.eza.enableBashIntegration = true;
programs.eza.enableZshIntegration = true;
#programs.eza.icons = "auto"; # --icons=auto
programs.eza.extraOptions = [ "--group" "--group-directories-first" ];
}

View File

@@ -0,0 +1,37 @@
{
programs.fzf = {
enable = true; # TODO: does this conflict with system-wide setup?
# alt-c
changeDirWidgetCommand = "fd --type d"; # respects .gitignore
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];
# ctrl-t
# fileWidgetCommand = "fd . --type file"; # respects .gitignore
fileWidgetCommand = "fd . | sort --ignore-case --general-numeric-sort"; # respects .gitignore
fileWidgetOptions = [
"--bind 'home:first'"
"--bind 'end:last'"
"--cycle"
# https://man.archlinux.org/man/extra/fzf/fzf.1.en#PREVIEW_WINDOW
# bat is installed in bat.nix
# this goes into home.sessionVariables.FZF_CTRL_T_OPTS which goes into a 'export ""' statement, i.e. it will eval bash variables
#"--preview 'head {}'"
# "--preview 'bat {}'"
# "--preview 'tail -n\\$FZF_PREVIEW_LINES {} | bat --file-name {} --paging never --style plain'"
# "--preview 'bat {} --paging never --style plain' --preview-window follow"
"--preview 'if [[ -f {} ]]; then tail -n\\$FZF_PREVIEW_LINES {} | bat --paging=never --style=plain --color=always --file-name {} ; elif [[ -e {}/.git ]]; then git -C {} status else file {} ; fi' --preview-window follow"
# TODO: add viu to ^
# https://github.com/junegunn/fzf/discussions/3363#discussioncomment-6419463
"--bind 'ctrl-a:reload:eval \\$FZF_DEFAULT_COMMAND --no-ignore'"
];
# ctrl-r
#historyWidgetOptions = [ "--sort" "--exact" ];
};
}

View File

@@ -0,0 +1,40 @@
{ pkgs, ... }:
{
imports = [
../minimal/git.nix
];
# programs.gh.enable = true; # adds read-only config to .config
# programs.git.gitui.enable = true;
programs.git.lfs.enable = true;
home.packages = with pkgs; [
git-wait
colordiff
diffnav
gh
tea
#hub
(pkgs.symlinkJoin {
inherit (pkgs.hub) name meta;
paths = [ pkgs.hub ];
# TODO: this could be a pre-command added with makeWrapper
postBuild = ''
rm $out/bin/hub
cat <<"EOF" >$out/bin/hub
#!${pkgs.runtimeShell}
# https://hub.github.com/hub.1.html#github-oauth-authentication
if [[ ! -d ~/.config/hub ]]; then
export GITHUB_TOKEN=$(${pkgs.gh}/bin/gh auth token 2>/dev/null)
fi
exec -a "$0" ${pkgs.hub}/bin/hub "$@"
EOF
chmod +x $out/bin/hub
'';
})
];
}

View File

@@ -0,0 +1,62 @@
{ pkgs, lib, config, ... }:
let
# why not just use functions normally? ctrl-alt-e is why!
_tmpfn_name_ = "_tmpfn_ex4aiNgu_"; # pwgen ftw
mkArgsAlias = alias: ''${_tmpfn_name_}() { unset -f ${_tmpfn_name_}; ${alias}; }; ${_tmpfn_name_}'';
in
{
programs.tealdeer.enable = true;
programs.tealdeer.settings.updates.auto_update = true;
home.packages = lib.filter (x: x != null) (with pkgs; [
wakeonlan
android-tools # adb
xclip # fairly minimal
#tldr
stress # brrr
retry # retry command with optional backoff
glances # yet another htop
# bottom # yet another htop
# axel aria aria2 # brrr
# silver-searcher # 'ag'
# comby # ast-based source code rewrite
gron fastgron # grep-able json
xq gojq # faster jq alternatives
# yq # jq wrapper with more formats, includes yq (yaml), xq (xml) and tomlq
(pkgs.linkFarm yq {
# jq wrapper with more formats, includes yq (yaml), xq (xml) and tomlq
"bin/yq" = lib.getExe' pkgs.yq "yq";
"bin/tomlq" = lib.getExe' pkgs.yq "tomlq";
# "bin/xq" = lib.getExe' pkgs.yq "xq"; # conflict with the speedy xq
})
fx # jq tui viewer
ijq # interactive jq
#fq # jq for binaries
xh # "friendly fast curl"
# mdq # markdown queries
(pkgs.xan or null) # a jq for csv, zsv
# xee # xml xpath queries
pkgs.unstable.just # justfile
gum
mprocs
systemctl-tui
# sysz
duf # df alternative
#dust # better du
hexyl # better hexdump
#xplr # tui file explorer
aha # ansi colors to html
(pkgs.colorized-logs or unstable.colorized-logs) # ansi2txt, pipetty
viu # kitty icat/chafa alternative
]);
#TODO: sshuttle "vpn"
home.shellAliases.icat = "viu";
}

View File

@@ -0,0 +1,11 @@
{ lib, ... }:
{
programs.bash.initExtra = lib.pipe (builtins.readDir ./.) [
(lib.filterAttrs (k: v: v == "regular"))
(lib.filterAttrs (k: v: lib.hasSuffix ".sh" k))
lib.attrNames
# (map (x: builtins.readFile ./${x}))
(map (x: "source ${./${x}}"))
lib.concatLines
];
}

View File

@@ -1,3 +1,5 @@
if [[ -d /run/current-system/specialisation ]]; then
nixos-switch-to-specialization() {
if [[ -z "$(ls /run/current-system/specialisation)" ]]; then
printf >&2 "%s\n" "No specializations found!"
@@ -21,3 +23,5 @@ nixos-switch-to-specialization() {
sudo /run/current-system/specialisation/"$specialization"/bin/switch-to-configuration switch
)
}
fi

View File

@@ -13,3 +13,5 @@ ps1_retcode_color() {
}
# export PS1='\[\033[01;32m\]\u@\h\[\033[01;37m\] \[\033[01;34m\]\W\[\033[33m\]$(ps1_parse_git_branch)$(ps1_retcode_color)\$\[\033[00m\] '
export PS1='\[\033[01;32m\]\u@\h\[\033[01;37m\] \[\033[01;34m\]\W\[\033[33m\]$(ps1_parse_git_branch)\[\033[01;32m\]\$\[\033[00m\] '
# TODO: ^ breaks interactive 'sh' with "sh: ps1_parse_git_branch: command not found"

View File

@@ -20,8 +20,8 @@ in
home.shellAliases.cata = mkArgsAlias ''printf "echo + "$@"; bat --style plain --paging never %q\n" "$@" | xargs -d'\n' ${lib.getExe pkgs.mprocs}'';
home.shellAliases.bata = mkArgsAlias ''printf "echo + "$@"; bat --style plain %q\n" "$@" | xargs -d'\n' ${lib.getExe pkgs.mprocs}'';
home.shellAliases.man = "batman";
#home.shellAliases.man = "PAGER=${pkgs.most}/bin/most man";
home.shellAliases.zbat = mkArgsAliasX ''atool "$1" --cat | bat --file-name "$1"'';
# home.shellAliases.man = "PAGER=${pkgs.most}/bin/most man";
# home.shellAliases.zbat = mkArgsAliasX ''atool "$1" --cat | bat --file-name "$1"'';
# TODO: implement programs.bat.enableAliases
programs.bat = {

View File

@@ -0,0 +1,22 @@
# https://nix-community.github.io/home-manager/options.html
{ pkgs, lib, config, ... }:
{
#nixpkgs.config.allowUnfree = true;
home.enableNixpkgsReleaseCheck = true;
home.preferXdgDirectories = true;
xdg.enable = true;
imports = [
./uv.nix
./bashrc.d
./bat.nix
./git.nix
./micro.nix
./shell.nix
./ssh.nix
./nix.nix
# ./sops.nix
# ./xdg-ninja.nix
# ./tmate.nix
];
}

View File

@@ -1,46 +1,10 @@
{ config, pkgs, lib, ... }:
{ config, lib, ... }:
{
home.packages = with pkgs; [
#git
gh
git-wait
#hub
(pkgs.symlinkJoin {
inherit (pkgs.hub) name meta;
paths = [ pkgs.hub ];
# TODO: this could be a pre-command added with makeWrapper
postBuild = ''
rm $out/bin/hub
cat <<"EOF" >$out/bin/hub
#!${pkgs.runtimeShell}
# https://hub.github.com/hub.1.html#github-oauth-authentication
if [[ ! -d ~/.config/hub ]]; then
export GITHUB_TOKEN=$(${pkgs.gh}/bin/gh auth token 2>/dev/null)
fi
exec -a "$0" ${pkgs.hub}/bin/hub "$@"
EOF
chmod +x $out/bin/hub
'';
})
tea
colordiff
diffnav
];
#programs.gh.enable = true; # adds read-only config to .config
programs.git.enable = true;
#programs.git.userName = "pbsds"
programs.git.userName = "Peder Bergebakken Sundt";
programs.git.userEmail = "pbsds@hotmail.com";
#programs.git.gitui.enable = true;
programs.git.lfs.enable = true;
programs.git.delta.enable = true;
programs.git.delta.options = {
# Delta uses ~/.gitconfig even when not invoked by git
@@ -65,7 +29,7 @@
programs.git.extraConfig.fetch.prune = true;
programs.git.extraConfig.fetch.prunetags = true;
programs.git.extraConfig.log.date = "iso";
/* programs.git.extraConfig.interactive.singleKey = true; */
# programs.git.extraConfig.interactive.singleKey = true;
programs.git.iniContent.init.defaultBranch = "main";
programs.git.ignores = [

View File

@@ -2,22 +2,22 @@
{
# TODO: upstream this
imports = [ ../modules/micro.nix ];
imports = [ ../../modules/micro.nix ];
disabledModules = [ "programs/micro.nix" ];
home.shellAliases.ed = "$EDITOR"; # ed is the standard editor
home.shellAliases.de = "$EDITOR"; # de is the standard typo
home.sessionVariables.EDITOR = "micro";
home.packages = with pkgs; [
micro
aspell
aspellDicts.en
aspellDicts.nb
home.packages = [
pkgs.micro
pkgs.aspell
pkgs.aspellDicts.en
pkgs.aspellDicts.nb
];
programs.bash.initExtra = ''
if [ "$COLORTERM" = "truecolor" ] || [ "$TERM" == "xterm" ]; then
if [ "$COLORTERM" = "truecolor" ] || [ "$TERM" == "xterm" ] || [ "$TERM" == "xterm-256color" ]; then
# export TERM=xterm-256color
export MICRO_TRUECOLOR=1
fi

View File

@@ -1,47 +1,19 @@
{ pkgs, ... }:
{ lib, ... }:
let
# why not just use functions normally? ctrl-alt-e is why!
_tmpfn_name_ = "_tmpfn_ex4aiNgu_"; # pwgen ftw
mkArgsAlias = alias: ''${_tmpfn_name_}() { unset -f ${_tmpfn_name_}; ${alias}; }; ${_tmpfn_name_}'';
in
{
home.packages = with pkgs; [
# flox
# devenv
# cachix
# nix-template
nix-output-monitor
nix-du
nix-tree
nix-visualize
nix-inspect
nix-btm
unstable.nixpkgs-review bubblewrap
unstable.nixpkgs-hammering
unstable.nix-update
unstable.nix-init
unstable.deadnix
unstable.statix
# unstable.nixtract
unstable.nixfmt-rfc-style
nurl
# manix
# comma # collides with nix-index-database
# devenv
nix-fast-build
nix-eval-jobs
];
home.shellAliases = {
# manix-fzf = ''manix "" 2>/dev/null | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview="manix '{}'" | xargs manix'';
denix = "sed -E 's@/nix/store/[^ /]+@@g'";
denix-ellipsis = "sed -E 's@/nix/store/[^ /-]+-?@/nix/store/...@g'";
# nix-eval = "nix eval --impure --expr";
# nix-eval-nixpkgs = mkArgsAlias ''nix eval --impure --expr "with import (builtins.getFlake "nixpkgs") {}; $1" "''${@:2}"'';
# if nom is not in path we rely on bash to let us know that if we attempt to use it
nom-instantiate = "nix-instantiate";
inom = mkArgsAlias ''nom "$@" --system i686-linux -j0'';
@@ -78,12 +50,4 @@ in
danom-build = "nom-build --system aarch64-darwin -j0";
danix-build = "nix-build --system aarch64-darwin -j0";
};
programs.bash.initExtra = ''
nix-prefetch-sri() {
url="$1"; shift
nix hash to-sri --type sha256 "$@" "$(nix-prefetch-url "$url")"
}
'';
}

View File

@@ -56,57 +56,10 @@ in
};
};
imports = [ ../modules/jump.nix ];
# TODO: move out of minimal?
imports = [ ../../modules/jump.nix ];
programs.jump.enableBash = true;
programs.nix-index.enable = true;
programs.nix-index-database.comma.enable = true; # via nix-index-database flake
#programs.command-not-found.enable = false; # mutex with nix-index
programs.fzf = {
enable = true; # TODO: does this conflict with system-wide setup?
# alt-c
changeDirWidgetCommand = "fd --type d"; # respects .gitignore
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];
# ctrl-t
# fileWidgetCommand = "fd . --type file"; # respects .gitignore
fileWidgetCommand = "fd . | sort --ignore-case --general-numeric-sort"; # respects .gitignore
fileWidgetOptions = [
"--bind 'home:first'"
"--bind 'end:last'"
"--cycle"
# https://man.archlinux.org/man/extra/fzf/fzf.1.en#PREVIEW_WINDOW
# bat is installed in bat.nix
# this goes into home.sessionVariables.FZF_CTRL_T_OPTS which goes into a 'export ""' statement, i.e. it will eval bash variables
#"--preview 'head {}'"
# "--preview 'bat {}'"
# "--preview 'tail -n\\$FZF_PREVIEW_LINES {} | bat --file-name {} --paging never --style plain'"
# "--preview 'bat {} --paging never --style plain' --preview-window follow"
"--preview 'if [[ -f {} ]]; then tail -n\\$FZF_PREVIEW_LINES {} | bat --paging=never --style=plain --color=always --file-name {} ; elif [[ -e {}/.git ]]; then git -C {} status else file {} ; fi' --preview-window follow"
# TODO: add viu to ^
# https://github.com/junegunn/fzf/discussions/3363#discussioncomment-6419463
"--bind 'ctrl-a:reload:eval \\$FZF_DEFAULT_COMMAND --no-ignore'"
];
# ctrl-r
#historyWidgetOptions = [ "--sort" "--exact" ];
};
# TODO: slow when colors are enabled, use lsd instead?
# https://github.com/eza-community/eza/issues/922
programs.eza.enable = true;
programs.eza.enableAliases = lib.mkIf (lib.versionOlder config.home.version.release "24.05") true;
programs.eza.enableBashIntegration = true;
programs.eza.enableZshIntegration = true;
#programs.eza.icons = "auto"; # --icons=auto
programs.eza.extraOptions = [ "--group" "--group-directories-first" ];
#programs.zoxide.enable = true;
#programs.zoxide.options = [ "--cmd cd --cmd dc" ];
@@ -123,16 +76,11 @@ in
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.tealdeer.enable = true;
programs.tealdeer.settings.updates.auto_update = true;
home.shellAliases.kaomoji = "curl -s 'https://kaomoji.ru/en/' | htmlq tr td span --text | grep . | shuf | head -n1";
home.shellAliases.flexget = "ssh -t noximilien sudo --user=flexget flexget -c /var/lib/flexget/flexget.yml"; # TODO: only applies to nox...
# home.shellAliases.hman = "man -H "; # HTML opened in a browser
home.shellAliases.tmux = "systemd-run --scope --user tmux"; # detach from ssh scope, surviving logout
/* home.shellAliases.shpool = "systemd-run --scope --user shpool"; # detach from ssh scope, surviving logout */
#TODO: vpn
# home.shellAliases.shpool = "systemd-run --scope --user shpool"; # detach from ssh scope, surviving logout
# TODO: ps1?
home.shellAliases.pwd-fqdn = ''echo "$(whoami)@$(hostname -f):$(printf "%q" "$(realpath .)/")"'';
@@ -150,8 +98,6 @@ in
home.shellAliases.dush = "du -shc * | sort -h";
home.shellAliases.dushd = "du -shc * .[!.]?* | sort -h";
home.shellAliases.icat = "viu";
home.shellAliases.open = "xdg-open";
home.shellAliases.rwhich = mkArgsAlias ''which "$@" | xargs -d"\n" realpath --'';
home.shellAliases.rwhichcd = mkArgsAlias ''
@@ -188,17 +134,16 @@ in
home.shellAliases.afd = "fd --no-ignore --hidden";
home.shellAliases.drg = lib.mkIf (config.programs.git.enable && config.programs.git.delta.enable) (
mkArgsAlias ''rg "$@" --json | delta''
# mkArgsAlias ''rg "$@" --json | delta''
mkArgsAlias ''rg "$@" --json | jq -s 'sort_by(.data.path)|.[]' -c | delta''
);
# via nix-index-with-full-db
#home.shellAliases.nlocate = "nix-locate --top-level --regex";
#home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --top-level --regex "$@" | tr -s ' ' | cut -d' ' -f4'';
# home.shellAliases.nlocate = "nix-locate --top-level --regex";
# home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --top-level --regex "$@" | tr -s ' ' | cut -d' ' -f4'';
home.shellAliases.nlocate = "nix-locate --regex";
home.shellAliases.nlocatea = "nix-locate --minimal --regex";
home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --regex "$@" | tr -s ' ' | cut -d' ' -f4'';
home.shellAliases.kaomoji = "curl -s 'https://kaomoji.ru/en/' | htmlq tr td span --text | grep . | shuf | head -n1";
# home.shellAliases.nlocatea = "nix-locate --minimal --regex";
# home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --regex "$@" | tr -s ' ' | cut -d' ' -f4'';
# home.shellAliases.swgl = "env LIBGL_ALWAYS_SOFTWARE=true GALLIUM_DRIVER=softpipe __GLX_VENDOR_LIBRARY_NAME=mesa ";
home.shellAliases.swgl = "env LIBGL_ALWAYS_SOFTWARE=true GALLIUM_DRIVER=llvmpipe __GLX_VENDOR_LIBRARY_NAME=mesa ";
@@ -211,55 +156,16 @@ in
curl
wget
wakeonlan
android-tools # adb
#tldr
stress # brrr
entr # live reload
retry # retry command with optional backoff
glances
btop # better htop
# bottom # better htop
faketty
# axel aria aria2 # brrr
xe # better xargs
sd # better sed
fd # better find
# silver-searcher # 'ag'
ripgrep # 'rg'
# comby # ast-based source code rewrite
gron fastgron # grep-able json
jq # json query
xq gojq # faster jq alternatives
# yq # jq wrapper with more formats, includes yq (yaml), xq (xml) and tomlq
(pkgs.linkFarm yq {
# jq wrapper with more formats, includes yq (yaml), xq (xml) and tomlq
"bin/yq" = lib.getExe' pkgs.yq "yq";
"bin/tomlq" = lib.getExe' pkgs.yq "tomlq";
# "bin/xq" = lib.getExe' pkgs.yq "xq"; # conflict with the speedy xq
})
fx # jq tui viewer
ijq # interactive jq
#fq # jq for binaries
xh # "friendly fast curl"
htmlq # html css queries
# mdq # markdown queries
(pkgs.xan or null) # a jq for csv, zsv
# xee # xml xpath queries
pkgs.unstable.just # justfile
gum
mprocs
systemctl-tui
# sysz
duf # df alternative
#dust # better du
ncdu # du tui
hexyl # better hexdump
#xplr # tui file explorer
aha # ansi colors to html
(pkgs.colorized-logs or unstable.colorized-logs) # ansi2txt, pipetty
viu # kitty icat/chafa alternative
]);
home.file.".config/ncdu/config".text = ''

View File

@@ -7,14 +7,17 @@
programs.bash.initExtra = ''
# ssh autocomplete
if test -f ~/.ssh/config; then
if [[ -f ~/.ssh/config ]]; then
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" ssh
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" tssh
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" rssh
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" xssh
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" scp
if command -v remote-init >/dev/null; then
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" remote-init
complete -W "$(cat ~/.ssh/config | grep "^Host " | cut -d" " -f2- | grep -v '\*')" remote-add
fi
fi
'';
@@ -37,6 +40,7 @@
"*.tail9aac63.ts.net".forwardX11Trusted = true;
"*.ntnu.no".user = "pederbs";
"*.pvv.org".user = "pederbs";
# TODO: add fingerprint to known hosts
"*.pvv.org !login.pvv.org".proxyJump = "login.pvv.ntnu.no";
"*.pvv.ntnu.no !login.pvv.ntnu.no".proxyJump = "login.pvv.ntnu.no";
"*.hpc.ntnu.no".proxyJump = "login.pvv.ntnu.no";
@@ -155,5 +159,4 @@
/* "fil.fyrkat.no" = {}; */
};
}

View File

@@ -0,0 +1,10 @@
{ pkgs, ... }:
{
# https://docs.astral.sh/uv/configuration/files/
# https://docs.astral.sh/uv/reference/settings/
xdg.configFile."uv/uv.toml".source = (pkgs.formats.toml { }).generate "uv-config" {
python-downloads = "never";
python-preference = "only-system";
pip.index-url = "https://test.pypi.org/simple";
};
}