{ config, lib, namespace, ... }: let cfg = config.${namespace}.shell-aliases; net = lib.${namespace}.network; in { options.${namespace}.shell-aliases = { enable = lib.mkEnableOption "Common shell aliases"; buildHost = lib.mkOption { type = lib.types.str; default = "admin@${net.hosts.nas.lan}"; description = "Build host for nixos-rebuild commands"; }; flakeInputs = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; description = "List of flake inputs to update"; }; extraAliases = lib.mkOption { type = lib.types.attrsOf lib.types.str; default = { }; description = "Additional host-specific aliases"; }; }; config = lib.mkIf cfg.enable { programs.zsh.shellAliases = { # Common file operations ll = "ls -alh"; ducks = "du -cksh * | sort -hr | head -n 15"; # NixOS rebuild commands update-boot = "sudo nixos-rebuild boot --max-jobs 10" + lib.optionalString (cfg.buildHost != "") " --build-host ${cfg.buildHost}"; update-switch = "sudo nixos-rebuild switch --max-jobs 10" + lib.optionalString (cfg.buildHost != "") " --build-host ${cfg.buildHost}"; # Flake update command update-flake = lib.mkIf ( cfg.flakeInputs != [ ] ) "nix flake update ${lib.concatStringsSep " " cfg.flakeInputs} --flake /etc/nixos"; # NAS management update-nas = "nixos-rebuild switch --use-remote-sudo --target-host admin@${net.hosts.nas.lan} --build-host admin@${net.hosts.nas.lan} --flake ~/nix-config#jallen-nas"; nas-ssh = "kitten ssh admin@${net.hosts.nas.lan}"; } // cfg.extraAliases; }; }