admin tools

This commit is contained in:
2026-02-03 22:28:01 +01:00
parent a059882831
commit 4d9906b59c
2 changed files with 100 additions and 0 deletions

98
modules/tool.nix Normal file
View File

@@ -0,0 +1,98 @@
{ pkgs, lib, ... }:
let
isDarwin = lib.strings.hasSuffix "darwin" pkgs.system;
in
{
environment.systemPackages = [
pkgs.htop
pkgs.btop
pkgs.iftop
pkgs.lsof
pkgs.wget
pkgs.curl
pkgs.zip
pkgs.unzip
pkgs.unrar
pkgs.p7zip
pkgs.fd
pkgs.ripgrep
pkgs.bat
pkgs.findutils
pkgs.coreutils
pkgs.tree
pkgs.rlwrap
pkgs.file
pkgs.progress
pkgs.gdu
pkgs.rmlint
pkgs.jq
pkgs.yq
pkgs.bc
pkgs.vimv
pkgs.pciutils # for lspci
]
++ lib.optionals (!isDarwin) [
pkgs.usbutils # for lsusb
pkgs.lshw
pkgs.iotop
pkgs.psmisc # killall, pstree
];
environment.shellAliases =
let
take = pkgs.writers.writeDash "take" ''
mkdir "$1" && cd "$1"
'';
cdt = pkgs.writers.writeDash "cdt" ''
cd $(mktemp -p "$XDG_RUNTIME_DIR" -d "cdt-XXXXXX")
pwd
'';
wcd = pkgs.writers.writeDash "wcd" ''
cd "$(readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname)/.."
'';
where = pkgs.writers.writeDash "where" ''
readlink "$(${pkgs.which}/bin/which --skip-alias "$1")" | xargs dirname
'';
in
{
nixi = "nix repl nixpkgs";
take = "source ${take}";
wcd = "source ${wcd}";
where = "source ${where}";
# temporary files and directories
cdt = "source ${cdt}";
vit = "$EDITOR $(mktemp)";
# file safety
mv = "${pkgs.coreutils}/bin/mv --interactive";
rm = "${pkgs.coreutils}/bin/rm --interactive --verbose";
cp = "${pkgs.coreutils}/bin/cp --interactive";
# colours
cat = "${pkgs.bat}/bin/bat --theme=ansi --style=plain";
l = "${pkgs.coreutils}/bin/ls --color=auto --time-style=long-iso --almost-all";
ls = "${pkgs.coreutils}/bin/ls --color=auto --time-style=long-iso";
ll = "${pkgs.coreutils}/bin/ls --color=auto --time-style=long-iso -l";
la = "${pkgs.coreutils}/bin/ls --color=auto --time-style=long-iso --almost-all -l";
}
// (
if isDarwin then
{ }
else
{
"ß" = "${pkgs.util-linux}/bin/setsid";
ip = "${pkgs.iproute2}/bin/ip -c";
# systemd
s = "${pkgs.systemd}/bin/systemctl";
us = "${pkgs.systemd}/bin/systemctl --user";
j = "${pkgs.systemd}/bin/journalctl";
uj = "${pkgs.systemd}/bin/journalctl --user";
}
);
}