From 4d9906b59c3b970687c349ae84f93e83986da98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 3 Feb 2026 22:28:01 +0100 Subject: [PATCH] admin tools --- flake.nix | 2 + modules/tool.nix | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 modules/tool.nix diff --git a/flake.nix b/flake.nix index db60dd8..2b6ecc1 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,8 @@ git = modules/git.nix; udiskie = modules/udiskie.nix; niri = modules/niri; + + tools = modules/tool.nix; }; overlays.default = final: prev: { diff --git a/modules/tool.nix b/modules/tool.nix new file mode 100644 index 0000000..26ec88d --- /dev/null +++ b/modules/tool.nix @@ -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"; + } + ); +}