{ config, pkgs, ... }: { # Configure BASH exports # https://nix-community.github.io/home-manager/options.html # https://github.com/justjanne/powerline-go # https://nix-community.github.io/home-manager/options.html#opt-programs.powerline-go.enable programs.powerline-go = { enable = true; # https://github.com/justjanne/powerline-go#customization settings = { hostname-only-if-ssh = true; cwd-max-depth = 1; condensed = true; # valid choices: default, low-contrast, gruvbox, solarized-dark16, solarized-light16 theme = "gruvbox"; }; modules = [ "venv" "user" "host" "ssh" "cwd" "nix-shell" "perms" "git" "docker" "exit" "root" ]; }; programs = { bash = { enable = true; enableCompletion = true; initExtra = '' GPG_TTY=$(tty) ssh-add ''; sessionVariables = { # Set the GTK Theme # GTK_THEME = "Gruvbox-Dark-BL"; XDG_DATA_HOME = "$HOME/.local/share"; # Disable askpass for cli auth: # SSH_ASKPASS = ""; }; bashrcExtra = '' restart-docker() { docker stop $1 docker rm $1 docker-compose up -d $1 } # Build ISOs/SD Card Images nixos-build-all-images-verbose() { echo "Building Linode image..." nixos-build-linode-img-verbose echo "Building Raspberry Pi image..." nixos-build-pi-img-verbose echo "Building ISO Console image..." nixos-build-console-verbose echo "Building ISO Desktop image..." nixos-build-desktop-verbose ls -lah ~/ | grep nixos } nixos-build-all-images() { echo "Building Linode image..." nixos-build-linode-img echo "Building Raspberry Pi image..." nixos-build-pi-img echo "Building ISO Console image..." nixos-build-console echo "Building ISO Desktop image..." nixos-build-desktop ls -lah ~/ | grep nixos } nixos-build-pi-img-verbose() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-rpi4-img --show-trace --verbose cp result/sd-image/nixos-sd-image* ~/. rm -f result popd } nixos-build-linode-img-verbose() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-linode-img --show-trace --verbose cp result/nixos.img.gz ~/nixos-linode-`ddate`-`git rev-parse HEAD | cut -b 1-7`.img.gz rm -f result popd } nixos-build-console-verbose() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-iso-console --show-trace --verbose cp result/iso/nixos.iso ~/nixos-console-`ddate`-`git rev-parse HEAD | cut -b 1-7`.iso rm -f result popd } nixos-build-desktop-verbose() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-iso-desktop --show-trace --verbose cp result/iso/nixos.iso ~/nixos-desktop-`ddate`-`git rev-parse HEAD | cut -b 1-7`.iso rm -f result popd } nixos-build-pi-img() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-rpi4-img cp result/sd-image/nixos-sd-image* ~/. rm -f result popd } nixos-build-linode-img() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-linode-img cp result/nixos.img.gz ~/nixos-linode-`ddate`-`git rev-parse HEAD | cut -b 1-7`.img.gz rm -f result popd } nixos-build-console() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-iso-console cp result/iso/nixos.iso ~/nixos-console-`ddate`-`git rev-parse HEAD | cut -b 1-7`.iso rm -f result popd } nixos-build-desktop() { pushd /etc/nixos/git git pull nix build .#imageConfigurations.nixos-iso-desktop cp result/iso/nixos.iso ~/nixos-desktop-`ddate`-`git rev-parse HEAD | cut -b 1-7`.iso rm -f result popd } # NixOS Related nix-clean-all() { sudo nix-env -u --always sudo nix-collect-garbage -d } # Update SOPS Secrets install-secrets() { pushd /etc/nixos/git nix develop -c update-repo popd } update-repo() { for i in $(ls secrets); do echo "Updateing secrets/$i" sops updatekeys secrets/$i -y done } ''; shellAliases = { # nVidia prime selector alias: prime-select = "nvidia-offload"; # Don't use X to open emacs emacs = "emacs -nw"; # docker d = "docker"; dc = "docker-compose"; de = "docker exec -it"; dl = "docker logs -f "; dps = ''docker ps --format "table [{{.ID}}] {{.Names}}\t{{.Status}}\t{{.State}}\t{{.Label \"type\"}}"''; # bash / system ls = "exa"; cp = "rsync -avr"; ll = "exa -lah"; rm = "rm -i"; df = "duf"; cat = "bat"; # git g = "git"; ga = "git add -A"; gb = "git branch"; gc = "git commit"; gca = "git commit -a"; gco = "git checkout"; gd = "git diff"; gp = "git pull --prune"; gpu = "git push origin HEAD"; gs = "git status -sb"; # time / date tdate = "date +%Y.%m.%d..%H.%M"; ttime = "date +%H.%M"; ddate = "date +%Y.%m.%d"; dday = "date +%A"; # nixos-rebuild ns = "nix shell"; nr = "sudo nixos-rebuild"; nrs = "sudo nixos-rebuild --upgrade switch"; nrt = "sudo nixos-rebuild test"; nrb = "sudo nixos-rebuild build"; # Rebuild everything rebuild-home = "git -C /etc/nixos/git pull && home-manager switch -b backup --flake /etc/nixos/git"; rebuild-host = "git -C /etc/nixos/git pull && sudo nixos-rebuild switch --flake /etc/nixos/git"; rebuild-all = "rebuild-host && rebuild-home"; rebuild-host-remote = "git -C /etc/nixos/git pull && sudo nixos-rebuild switch --flake /etc/nixos/git -j0"; rebuild-home-remote = "git -C /etc/nixos/git pull && home-manager switch -b backup --flake /etc/nixos/git --max-jobs 0"; rebuild-all-remote = "rebuild-host-remote && rebuild-home-remote"; }; }; }; }