2021-04-06 21:07:36 +00:00
|
|
|
{ config, 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-06-09 18:36:52 +00:00
|
|
|
system-rev = toString config.system.nixos.revision;
|
|
|
|
|
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
|
|
|
|
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
|
2021-04-05 23:08:19 +00:00
|
|
|
nix-index
|
2021-05-26 17:03:14 +00:00
|
|
|
nix-top
|
2020-09-18 13:54:09 +00:00
|
|
|
|
2021-03-22 19:09:30 +00:00
|
|
|
(writeShellScriptBin "dirt" "while sleep 1; do grep '^Dirty:' /proc/meminfo ; done")
|
|
|
|
|
2020-10-26 15:47:45 +00:00
|
|
|
(writeShellScriptBin "nix-roots" "nix-store --gc --print-roots | grep -v ^/proc/")
|
2020-09-18 13:54:09 +00:00
|
|
|
|
2021-05-03 05:48:22 +00:00
|
|
|
(writeShellScriptBin "ns" ''
|
2021-06-09 18:36:52 +00:00
|
|
|
exec nix shell "nixpkgs/${system-rev}#$@"
|
2021-05-03 05:48:22 +00:00
|
|
|
'')
|
|
|
|
|
2021-04-30 02:21:47 +00:00
|
|
|
(writeShellScriptBin "pip_install" ''
|
2021-06-09 18:36:52 +00:00
|
|
|
exec nix shell 'nixpkgs/${system-rev}#python3.pkgs.pip' --command pip install --user -UI pip setuptools
|
2021-04-30 02:21:47 +00:00
|
|
|
'')
|
|
|
|
|
2021-06-04 03:47:35 +00:00
|
|
|
(writeShellScriptBin "nixos-check-reboot" ''
|
|
|
|
set -e
|
|
|
|
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
|
|
|
built="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
2021-06-04 03:59:17 +00:00
|
|
|
if [ "$booted" = "$built" ]
|
|
|
|
then
|
|
|
|
echo OK
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo REBOOT NEEDED
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-04 03:47:35 +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
|
|
|
|
2020-10-26 15:47:45 +00:00
|
|
|
(writeShellScriptBin "channel" ''
|
2020-10-27 05:01:11 +00:00
|
|
|
echo
|
2021-04-06 21:07:36 +00:00
|
|
|
echo "NixOS ${config.system.nixos.release} (${config.system.defaultChannel})"
|
2020-10-27 05:01:11 +00:00
|
|
|
echo
|
2021-06-09 18:36:52 +00:00
|
|
|
echo "${system-rev} current local"
|
2021-04-06 21:07:36 +00:00
|
|
|
echo "$(curl --silent -L ${config.system.defaultChannel}/git-revision) latest available"
|
2020-10-27 05:01:11 +00:00
|
|
|
echo
|
2020-10-01 15:40:28 +00:00
|
|
|
'')
|
2021-06-09 18:46:13 +00:00
|
|
|
|
2021-06-28 17:20:20 +00:00
|
|
|
];
|
2020-09-18 13:54:09 +00:00
|
|
|
|
2021-04-30 02:21:47 +00:00
|
|
|
environment.etc."pip.conf".text = ''
|
|
|
|
[install]
|
|
|
|
no-warn-script-location = false
|
|
|
|
'';
|
|
|
|
|
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
|
2021-04-29 21:45:05 +00:00
|
|
|
alias tmp='cd "$(TMPDIR=$XDG_RUNTIME_DIR mktemp -d)"'
|
2020-12-22 22:10:04 +00:00
|
|
|
alias catc='${pkgs.vimpager-latest}/bin/vimpager --force-passthrough'
|
2021-04-09 02:44:57 +00:00
|
|
|
alias nix-env="echo nix-env is disabled #"
|
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
|
|
|
'';
|
2021-06-04 14:45:50 +00:00
|
|
|
|
|
|
|
programs.neovim = {
|
|
|
|
enable = true;
|
|
|
|
viAlias = true;
|
|
|
|
vimAlias = true;
|
|
|
|
configure = {
|
|
|
|
packages.sconfig.start = [ pkgs.vimPlugins.vim-nix ];
|
|
|
|
customRC = ''
|
|
|
|
set nowrap scrolloff=9
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-09-18 13:54:09 +00:00
|
|
|
}
|