1
0
Fork 0
nixos/configuration.nix

262 lines
7.9 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2023-02-14 22:16:43 +01:00
{
environment.systemPackages = with pkgs;
[ # development
gnumake
postgresql
strace
valgrind
] ++ [ # utilities
acpi
cloak
man-pages
mdcat
unzip
wget
] ++ [ # applications
pulsemixer
R
] ++ [ # other
cifs-utils
ffmpeg
libcxx
libinput
ntfs3g
openal
];
2023-11-23 11:48:22 +01:00
home-manager = {
useGlobalPkgs = true;
users.${config.lwad.definitions.username}.programs = {
bash = {
enable = true;
sessionVariables.BOOKMARKS_FILE = "\${HOME}/Documents/bookmarks";
};
git = {
enable = true;
userEmail = "toolbox.0-kindred@icloud.com";
userName = "lwad";
2023-11-23 11:48:22 +01:00
};
};
2023-02-14 22:16:43 +01:00
};
2024-03-15 12:16:41 +01:00
imports = [ ./lwad ];
2024-03-12 00:02:59 +01:00
lwad = {
applications = {
btop.enable = true;
git.enable = true;
2024-03-26 23:46:53 +01:00
kmscon.enable = true;
2024-03-15 00:28:39 +01:00
neovim = {
commentary.enable = true;
completion.enable = true;
enable = true;
formatting = {
enable = true;
formatters =
[ "beautysh" "clang_format" "nixfmt" "prettier" "rustfmt" "yapf" ];
};
fugitive.enable = true;
harpoon.enable = true;
lsp = {
enable = true;
servers = [
"bash"
"clangd"
"jedi"
"nil"
"ruff"
"rust-analyzer"
"typescript"
];
};
2024-03-21 18:04:30 +01:00
markdown-preview.enable = true;
2024-03-15 00:28:39 +01:00
snippets.enable = true;
telescope.enable = true;
undotree.enable = true;
zenmode.enable = true;
treeSitter = {
enable = true;
languages = [
"bash"
"c"
"css"
"elm"
"erlang"
"haskell"
"html"
"java"
"javascript"
"lua"
"markdown"
"nix"
"python"
"r"
"rust"
"typescript"
];
};
};
projectManager.enable = true;
starship.enable = true;
task = {
dataDir =
config.home-manager.users.${config.lwad.definitions.username}.home.homeDirectory
+ "/Documents/tasks";
enable = true;
};
2024-03-12 00:02:59 +01:00
};
2024-03-14 18:36:30 +01:00
core.enable = true;
2024-03-12 00:02:59 +01:00
development.languages = {
bash.enable = true;
c.enable = true;
erlang.enable = true;
java.enable = true;
python.enable = true;
rust.enable = true;
typescript.enable = true;
};
filesystems.btrfs.compressDrives = [ "/" ];
utilities = {
qol.enable = true;
remote.enable = true;
2024-03-14 20:51:37 +01:00
tailscale.enable = true;
};
2024-03-12 00:02:59 +01:00
};
2023-02-14 22:16:43 +01:00
programs = {
dconf.enable = true;
bash = {
interactiveShellInit = let
cut = "${pkgs.coreutils}/bin/cut";
echo = "${pkgs.coreutils}/bin/echo";
2024-02-08 16:35:00 +01:00
fzf = "${pkgs.fzf}/bin/fzf";
git = "${pkgs.git}/bin/git";
head = "${pkgs.coreutils}/bin/head";
2024-02-08 16:35:00 +01:00
sort = "${pkgs.coreutils}/bin/sort";
task = "${pkgs.taskwarrior}/bin/task";
tmux = "${pkgs.tmux}/bin/tmux";
in ''
git() {
2024-02-08 16:35:00 +01:00
if [[ "$1" == "commit" ]] && [ -f "$(${git} rev-parse --show-toplevel)/.precommit" ]; then
$(${git} rev-parse --show-toplevel)/.precommit
fi
2024-02-08 16:35:00 +01:00
${git} "$@"
}
listen() {
${pkgs.yt-dlp}/bin/yt-dlp \
--force-ipv4 \
--concurrent-fragments 4 \
--paths "/tmp" \
--output "%(album)s/%(playlist_index)s-%(title)s.%(ext)s" \
--restrict-filenames \
--embed-metadata \
--embed-thumbnail \
--yes-playlist \
--extract-audio \
--audio-format mp3 \
"$1"
}
play() {
if [[ "$1" == "" ]]; then
2024-01-18 12:34:45 +01:00
target="."
else
target="$1"
fi
${pkgs.mpv}/bin/mpv --video=no --display-tags-clr "$target"
}
${lib.concatStringsSep "\n" (map (category: ''
${category}() {
if [[ $1 == "add" ]]; then
shift
2024-02-08 16:35:00 +01:00
${task} add project:${category} $@
else
2024-02-08 16:35:00 +01:00
${task} project:${category} $@
fi
}
2024-02-01 14:19:05 +01:00
'') [ "learn" "uni" "life" ])}
where() {
_get_pane() {
for pid in $(${pkgs.lsof}/bin/lsof -Fp "$1"); do
pid=''${pid#p}
pts="/dev/$(${pkgs.procps}/bin/ps -o tty= -p $pid)"
2024-02-08 16:35:00 +01:00
for pane in $(${tmux} list-panes -a -F "#{pane_tty}~#{session_name}~#{pane_id}"); do
if [[ "$(${cut} -d "~" -f 1 <<< $pane)" == "$pts" ]]; then
${echo} $pane
fi
done
done
}
2024-02-08 16:35:00 +01:00
panes=$(_get_pane "$1" | ${sort} -u)
if [ -n "$panes" ]; then
for pane in $panes; do
${echo} "The file is open in: $(${cut} -d "~" -f 1 --complement <<< "$pane" | ${pkgs.gnused}/bin/sed -e "s/~/ => /")."
done
else
${echo} "No process could be found. Delete the swap file." >&2
fi
}
2024-02-08 16:35:00 +01:00
spy() {
current_session="$(${tmux} list-clients -t "$TMUX_PANE" -F "#S" | ${head} -n 1)"
if [ -n "$1" ]; then
query="-1 -q $1"
else
query=""
fi
session="$(${tmux} list-clients -F "#S" | sort -u | sed -e "/$current_session/d" | ${fzf} -0 $query --prompt "current> " || ${tmux} list-sessions -F "#S" | sort -u | sed -e "/$current_session/d" | ${fzf} -0 $query --prompt "old> ")" && \
TMUX="" ${tmux} attach-session -r -t "$session"
2024-02-08 16:35:00 +01:00
}
,() {
if [ -x "./.run" ]
then
./run $@
fi
if basedir="$(git rev-parse --show-toplevel 2>/dev/null)" && [ -x "$basedir/.run" ]
then
"$basedir/.run" $@
fi
}
2024-01-04 12:53:08 +01:00
complete -F _command doas
'';
shellAliases = {
base = ''cd "$(tmux list-panes -F "#{pane_start_path}" | head -n 1)"'';
calculator = "(cd && R --save --quiet)";
chvt = "${config.lwad.definitions.sudoas.command} ${pkgs.kbd}/bin/chvt";
connected = ''
ssh scc230@shinobu 'users="" && for tmux_client in $(tmux list-clients | cut -d ":" -f 1 | cut -d "/" --complement -f 1,2); do if [ -n "$users" ]; then users+="@"; fi && users+="$(tailscale whois --json "$(last | rg "still logged in" | rg "$tmux_client" | tr -s " " | cut -d " " -f 3)" | jq -r ".UserProfile.DisplayName")"; done && echo "$users"' | tr "@" "\n" | sort -u
'';
drivediff = ''
rsync -nilrc --delete /mnt/external/Documents/ /home/${config.lwad.definitions.username}/Documents/ | sed -e "/.undo/d" -e "/.git/d"'';
here = "pwd >/tmp/herethere";
open = "xdg-open";
otp = ''
${pkgs.cloak}/bin/cloak view lancs | ${pkgs.coreutils}/bin/tr -d "\n" | ${pkgs.xclip}/bin/xclip -i -selection clipboard'';
2024-02-08 16:35:00 +01:00
pk = "tmux kill-session -t PROJECTS";
psql = "psql -d scc230 -U scc230 -p 5432 -h shinobu";
2024-02-26 20:02:43 +01:00
repo = ''
directory="$((cd /home/${config.lwad.definitions.username} && ${pkgs.fd}/bin/fd -H "^\.git$" Documents -x dirname {}) | sort -h | ${pkgs.fzf}/bin/fzf)" && (pushd "/home/${config.lwad.definitions.username}/$directory" >/dev/null; bash -i; popd >/dev/null)'';
serverfs = ''
base=$(git rev-parse --show-toplevel 2>/dev/null) && sshfs -o uid=$(id -u),gid=$(id -g) scc230@shinobu:/home/scc230/per-user/luke/server "$base/server"'';
there = ''cd "$(head -n 1 /tmp/herethere)"'';
wget = ''wget --hsts-file="$XDG_DATA_HOME/wget-hsts"'';
xclip = "xclip -selection clipboard";
};
2023-02-14 22:16:43 +01:00
};
};
services.pipewire = {
audio.enable = true;
enable = true;
pulse.enable = true;
socketActivation = true;
2023-05-25 15:23:31 +02:00
};
users.users.${config.lwad.definitions.username}.extraGroups = [ "video" ];
2023-02-14 22:16:43 +01:00
}