nixos-config/modules/cli.nix

108 lines
2.8 KiB
Nix
Raw Normal View History

2020-12-29 04:05:45 +00:00
{ pkgs, lib, ... }:
2020-11-12 20:16:44 +00:00
let
powerlineOpts = [
"-mode=flat"
"-colorize-hostname"
"-cwd-mode=dironly"
"-modules=user,host,cwd,nix-shell,git,jobs"
"-git-assume-unchanged-size 0"
];
2021-04-02 22:28:44 +00:00
rebuild-scripts = (map
(x: (pkgs.writeShellScriptBin "sc-${builtins.head x}" "nixos-rebuild ${lib.concatStringsSep " " (builtins.tail x)}"))
[
[ "switch" "switch" ]
[ "build" "build" ]
[ "boot" "boot" ]
[ "switch-upgrade" "switch" "--recreate-lock-file" "--refresh" ]
[ "build-upgrade" "build" "--recreate-lock-file" "--refresh" ]
[ "boot-upgrade" "boot" "--recreate-lock-file" "--refresh" ]
]
);
2020-11-12 20:16:44 +00:00
in
2020-09-18 13:54:09 +00:00
{
2020-09-24 05:45:48 +00:00
environment.systemPackages = with pkgs; [
pwgen
pv
tree
psmisc
ncdu
git
file
sqlite
usbutils
entr
ffmpeg
gcc
python3
openssl
wget
lm_sensors
htop
2020-10-24 01:50:14 +00:00
jq
2020-09-24 05:45:48 +00:00
zip
unzip
dnsutils
2021-03-22 19:24:07 +00:00
whois
2020-09-24 05:45:48 +00:00
tcpdump
rsync
2020-09-24 05:48:44 +00:00
nixpkgs-fmt
2020-09-18 13:54:09 +00:00
(writeShellScriptBin "dirt" "while sleep 1; do grep '^Dirty:' /proc/meminfo ; done")
(writeShellScriptBin "nix-roots" "nix-store --gc --print-roots | grep -v ^/proc/")
2020-09-18 13:54:09 +00:00
2020-09-24 05:45:48 +00:00
(vim_configurable.customize {
name = "vim";
vimrcConfig.customRC = ''
syntax enable
filetype plugin indent on
set nowrap ruler scrolloff=9 backspace=start,indent
'';
})
2020-09-18 13:54:09 +00:00
2020-09-24 05:45:48 +00:00
(writeScriptBin "zfsram" ''
#!${pkgs.python3}/bin/python
for ln in open('/proc/spl/kstat/zfs/arcstats').readlines():
if ln.startswith('size '):
print(str(int(ln.split(' ')[-1])/(1024*1024*1024))[:5],'GB')
'')
2020-10-01 15:40:28 +00:00
(writeShellScriptBin "channel" ''
2021-04-02 21:48:50 +00:00
branch="$(jq -r .nodes.nixpkgs.original.ref </etc/nixos/flake.lock)"
2020-10-27 05:01:11 +00:00
echo
2021-04-02 21:48:50 +00:00
echo "$branch"
2020-10-27 05:01:11 +00:00
echo
2021-04-02 21:48:50 +00:00
echo "$(jq -r .nodes.nixpkgs.locked.rev </etc/nixos/flake.lock) current local"
echo "$(git ls-remote https://github.com/NixOS/nixpkgs.git "$branch" | cut -f1) latest available"
2020-10-27 05:01:11 +00:00
echo
2020-10-01 15:40:28 +00:00
'')
2021-04-02 22:28:44 +00:00
] ++ rebuild-scripts;
2020-09-18 13:54:09 +00:00
2020-11-11 18:06:55 +00:00
environment.variables.EDITOR = "vim";
2020-09-25 23:30:24 +00:00
environment.variables.PLGO_HOSTNAMEFG = "0";
environment.variables.PLGO_HOSTNAMEBG = "114";
2020-12-20 05:51:18 +00:00
programs.tmux = {
enable = true;
terminal = "screen-256color";
};
2020-09-24 05:45:48 +00:00
programs.bash.interactiveShellInit = ''
stty -ixon
alias p=python3
2020-10-23 02:26:37 +00:00
alias tmp='cd $(mktemp -d)'
2020-11-09 22:10:48 +00:00
alias buildsys='nix build -f "<nixpkgs/nixos>" --no-link system'
2020-12-09 20:37:13 +00:00
alias sha256sum-base32='nix hash-file --type sha256 --base32'
2020-12-18 17:58:11 +00:00
alias pip_install='nix run nixpkgs.python3.pkgs.pip -c pip install --user -UI pip setuptools'
2020-12-22 22:10:04 +00:00
alias catc='${pkgs.vimpager-latest}/bin/vimpager --force-passthrough'
2020-09-18 13:54:09 +00:00
2020-09-24 05:45:48 +00:00
function _update_ps1() {
2020-11-12 20:16:44 +00:00
PS1="\n$(${pkgs.powerline-go}/bin/powerline-go ${lib.concatStringsSep " " powerlineOpts})$ "
2020-09-24 05:45:48 +00:00
}
2021-04-01 23:11:02 +00:00
[ "$TERM" = "linux" ] || PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
2020-09-24 05:45:48 +00:00
'';
2020-09-18 13:54:09 +00:00
}