nix/home-manager/common/software/cli/bash.nix

212 lines
6.5 KiB
Nix
Raw Normal View History

2024-03-19 01:39:24 +01:00
{ ... }: {
2023-07-01 12:12:43 +02:00
# Configure BASH exports
2023-07-07 00:36:51 +02:00
# https://nix-community.github.io/home-manager/options.html
# https://github.com/justjanne/powerline-go
2023-08-16 03:53:33 +02:00
# https://nix-community.github.io/home-manager/options.html#opt-programs.powerline-go.enable
programs.powerline-go = {
2024-01-19 05:02:09 +01:00
enable = false;
2023-08-16 03:53:33 +02:00
# https://github.com/justjanne/powerline-go#customization
settings = {
2023-08-21 13:51:58 +02:00
hostname-only-if-ssh = true;
cwd-max-depth = 2;
2024-01-04 14:22:55 +01:00
condensed = false;
2024-01-05 08:57:48 +01:00
theme = "default";
2023-12-13 14:37:54 +01:00
# valid choices: default, low-contrast, gruvbox, solarized-dark16, solarized-light16
2024-01-04 11:41:36 +01:00
# theme = "gruvbox";
2023-08-16 03:53:33 +02:00
};
2023-08-16 13:07:56 +02:00
modules = [
"venv"
"user"
2023-08-21 13:51:58 +02:00
"host"
2023-08-16 13:07:56 +02:00
"ssh"
"cwd"
"nix-shell"
"perms"
"git"
"docker"
"exit"
2023-08-21 12:33:50 +02:00
"root"
2023-08-16 13:07:56 +02:00
];
2023-08-16 03:53:33 +02:00
};
2023-07-10 12:50:38 +02:00
2024-02-15 13:57:52 +01:00
programs.bash = {
2024-02-15 13:57:22 +01:00
enable = true;
enableCompletion = true;
initExtra = ''
GPG_TTY=$(tty)
2024-03-25 04:00:22 +01:00
EDITOR=vim
2024-02-15 13:57:22 +01:00
ssh-add > /dev/null &> /dev/null
2024-04-08 15:10:15 +02:00
[[ -z "$TMUX" && "$DISABLE_TMUX" = "true" ]] && { tmux attach || exec tmux new-session && exit;}
2024-02-15 13:57:22 +01:00
'';
sessionVariables = {
# Set the GTK Theme
# GTK_THEME = "Gruvbox-Dark-BL";
XDG_DATA_HOME = "$HOME/.local/share";
# Disable askpass for cli auth:
# SSH_ASKPASS = "";
};
bashrcExtra = ''
2024-02-15 14:00:13 +01:00
restart-docker() {
2024-03-30 15:53:56 +01:00
pushd /Storage/Data/docker compose/sysctl.io
2024-02-15 13:57:22 +01:00
docker stop $1
docker rm $1
2024-03-28 06:04:39 +01:00
git pull
2024-03-30 15:53:56 +01:00
docker compose up -d $1
2024-02-15 13:57:22 +01:00
popd
}
# 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
}
2023-09-30 07:03:08 +02:00
2024-02-15 13:57:22 +01:00
# NixOS Related
nix-clean-all() {
2024-02-19 03:07:31 +01:00
echo "Optimizing the nix store..."
sudo nix-store --optimize
echo "nix-store: Collecting Garbage..."
sudo nix-store --gc
echo "Collecting garbage..."
2024-02-15 13:57:22 +01:00
sudo nix-collect-garbage -d
}
'';
shellAliases = {
prime-select = "nvidia-offload";
screenshot = ''grim -g "$(slurp)" | wl-copy -t image/png'';
2023-07-12 05:54:40 +02:00
2024-02-15 13:57:22 +01:00
# Don't use X to open emacs
emacs = "emacs -nw";
2023-08-25 14:27:31 +02:00
2024-02-15 13:57:22 +01:00
# docker
d = "docker";
2024-03-30 15:53:56 +01:00
dc = "docker compose";
2024-02-15 13:57:22 +01:00
de = "docker exec -it";
dl = "docker logs -f ";
dps = ''docker ps --format "table [{{.ID}}] {{.Names}}\t{{.Status}}\t{{.State}}\t{{.Label \"type\"}}"'';
2023-07-01 13:14:29 +02:00
2024-02-15 13:57:22 +01:00
# bash / system
ls = "exa --icons -F --group-directories-first --git";
cp = "rsync -avr";
ll = "exa -lah --icons -F --group-directories-first --git";
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";
2023-07-01 13:14:29 +02:00
2024-02-15 13:57:22 +01:00
# time / date
tdate = "date +%Y.%m.%d..%H.%M";
ttime = "date +%H.%M";
ddate = "date +%Y.%m.%d";
dday = "date +%A";
2023-07-01 13:42:01 +02:00
2024-02-15 13:57:22 +01:00
# nixos-rebuild
nr = "sudo nixos-rebuild";
nrs = "sudo nixos-rebuild --upgrade switch";
nrt = "sudo nixos-rebuild test";
nrb = "sudo nixos-rebuild build";
2023-08-23 08:09:52 +02:00
2024-02-15 13:57:22 +01:00
# 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";
2023-07-01 12:12:43 +02:00
};
};
2024-02-19 03:07:31 +01:00
}