From d9153ca794282407d5a13ee33a00a8920cf743d8 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 20 Aug 2024 22:43:31 -0500 Subject: [PATCH] Cleanup aliases Make Xonsh aliases nicer Organize the ones in my config Enhance the cleanup alias to include home-manager generations Create aliases as Python raw strings --- home/modules/baseline/xonsh.nix | 21 +++++++++++++-------- home/modules/baseline/xonsh_footer.xsh | 6 ++++++ home/modules/xonsh.nix | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/home/modules/baseline/xonsh.nix b/home/modules/baseline/xonsh.nix index ce2dd95..c3517d4 100644 --- a/home/modules/baseline/xonsh.nix +++ b/home/modules/baseline/xonsh.nix @@ -32,24 +32,29 @@ }; aliases = { + # Python related ones ac = "vox activate"; - - cleanup = "sudo nix-collect-garbage --delete-older-than 30d && nix store optimise"; d = "vox deactivate"; - dirflake = "nix flake new -t github:nix-community/nix-direnv"; - gh-personal = "$GH_CONFIG_DIR=\"${config.home.homeDirectory}/.config/gh/personal\" gh"; + + # Nix related ones gl-nging = "sudo nixos-container run gitlab -- systemctl restart nginx"; - ls = "ls --color"; - ll = "ls -l --color"; - molcol = "molecule -c ../../tests/molecule.yml"; nixup = "nix flake lock --update-input"; nixtest = "nixpkgs-review rev HEAD"; - pa = "cd ~/src/packaging"; + nixdu = "sudo nix-store --gc --print-roots | egrep -v r\"^(/nix/var|/run/\\w+-system|\\{memory|/proc)\""; + + # General + gh-personal = "$GH_CONFIG_DIR=\"${config.home.homeDirectory}/.config/gh/personal\" gh"; + ls = "ls --color"; + ll = "ls -l --color"; tf = "terraform"; + + # Tailscale related ones tsup = "sudo tailscale up"; tspub = "sudo tailscale up --exit-node=linode"; tshome = "sudo tailscale up --exit-node=2maccabees"; tsclear = "sudo tailscale up --exit-node=''"; + + # Vagrant related vdown = "vagrant destroy"; vhalt = "vagrant halt"; vos = "vagrant up --provision --provider openstack"; diff --git a/home/modules/baseline/xonsh_footer.xsh b/home/modules/baseline/xonsh_footer.xsh index 4871a8b..4d435df 100644 --- a/home/modules/baseline/xonsh_footer.xsh +++ b/home/modules/baseline/xonsh_footer.xsh @@ -110,6 +110,12 @@ def _bake(args): copier copy @(str(templates / args[0])) . aliases['bake'] = _bake +def _cleanup(args): + sudo nix profile wipe-history --profile ~/.local/state/nix/profiles/home-manager --older-than '30d' + sudo nix-collect-garbage --delete-older-than 30d + sudo nix store optimise +aliases['cleanup'] = _cleanup + ### # # Other random nice-to-have things diff --git a/home/modules/xonsh.nix b/home/modules/xonsh.nix index 08f57ab..95bd862 100644 --- a/home/modules/xonsh.nix +++ b/home/modules/xonsh.nix @@ -59,7 +59,7 @@ in with lib; { config = let shortAliases = concatStringsSep "\n" ( - mapAttrsToList (k: v: "aliases['${k}']='${v}'") cfg.aliases + mapAttrsToList (k: v: "aliases['${k}']=r'${v}'") cfg.aliases ); listToPythonList = let