depot/ops/nixos/lib/home-manager/common.nix

177 lines
4.9 KiB
Nix
Raw Normal View History

{ config, configName, depot, lib, pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux;
2023-01-15 16:10:12 +00:00
kitty-terminfo = pkgs.mkDerivation {
pname = "kitty-terminfo";
inherit (pkgs.kitty) version src;
dontBuild = true;
installPhase = ''
runHook preInstall
install -d $out/share/terminfo
export TERMINFO=$out/share/terminfo
tic terminfo/kitty.terminfo
runHook postInstall
'';
};
in
2020-10-25 11:36:16 +00:00
{
2021-03-28 23:08:02 +00:00
imports = [ ./ntfy.nix ];
programs.ntfy = {
enable = true;
package = if isDarwin then pkgs.ntfy.overrideAttrs (oldAttrs: {
postPatch = ''
substituteInPlace setup.py \
--replace '"darwin"' '"darwin-disabled"'
'';
}) else pkgs.ntfy;
2021-03-28 23:08:02 +00:00
settings = {
backends = [ "pushover" ];
pushover = {
user_key = depot.ops.secrets.pushover.userKey;
api_token = depot.ops.secrets.pushover.tokens.depot;
};
};
};
2020-10-25 11:36:16 +00:00
home.username = "lukegb";
home.homeDirectory = if isDarwin then "/Users/lukegb" else "/home/lukegb";
2020-10-25 11:36:16 +00:00
home.file = {
".hgrc".source = ./hgrc;
2023-01-15 16:10:12 +00:00
} // (lib.optionalAttrs isDarwin {
".terminfo".source = "${depot.nix.pkgs.terminfos}/share/terminfo";
2023-01-15 16:10:12 +00:00
});
home.sessionVariables = {
EDITOR = "vim";
VISUAL = "vim";
};
2020-10-25 11:36:16 +00:00
2020-11-09 00:21:32 +00:00
programs.ssh = {
enable = true;
forwardAgent = true;
matchBlocks = let
allEventBlocks = (lib.concatStringsSep " " (builtins.map (n: "172.${toString n}.*.*") (lib.range 16 31)));
2021-11-25 17:14:03 +00:00
blast-tmpl = ip: {
user = "root";
port = 888;
hostname = ip;
extraOptions.setEnv = "TERM=xterm-256color";
};
2023-05-07 13:39:32 +00:00
blast-jump-tmpl = ip: via: (blast-tmpl ip) // {
proxyJump = via;
};
2020-11-09 00:21:32 +00:00
in ({
2021-11-25 17:14:03 +00:00
sar1 = {
2022-07-15 07:59:43 +00:00
hostname = "172.16.0.1";
2021-11-25 17:14:03 +00:00
extraOptions.setEnv = "TERM=xterm-256color";
2020-11-09 00:21:32 +00:00
};
2021-10-19 06:53:59 +00:00
su-cinema-ernie = {
user = "lukegb";
hostname = "su-cinema-ernie.su.ic.ac.uk";
port = 8080;
};
su-cinema-ernie-root = {
user = "root";
hostname = "su-cinema-ernie.su.ic.ac.uk";
port = 8080;
};
2021-11-25 17:14:03 +00:00
2022-12-14 05:35:38 +00:00
blast-worker1 = blast-tmpl "10.200.109.10";
2023-05-07 13:39:32 +00:00
blast-worker1-jump = blast-jump-tmpl "10.200.109.10" "blast-csgo1-jump";
2022-12-14 05:35:38 +00:00
blast-worker2 = blast-tmpl "10.200.109.11";
2023-05-07 13:39:32 +00:00
blast-worker2-jump = blast-jump-tmpl "10.200.109.11" "blast-csgo2-jump";
2022-12-14 05:35:38 +00:00
blast-csgo1 = blast-tmpl "10.200.109.12";
2023-05-07 13:39:32 +00:00
blast-csgo1-jump = blast-jump-tmpl "10.222.0.2" "bvm-netbox";
2022-12-14 05:35:38 +00:00
blast-csgo2 = blast-tmpl "10.200.109.13";
2023-05-07 13:39:32 +00:00
blast-csgo2-jump = blast-jump-tmpl "10.222.0.3" "bvm-netbox";
2022-05-17 00:41:48 +00:00
whitby = {
hostname = "whitby.tvl.fyi";
};
2022-09-04 20:10:20 +00:00
github = {
user = "git";
hostname = "github.com";
identityFile = "~/.ssh/keys/github";
};
2020-11-09 00:21:32 +00:00
} // (builtins.listToAttrs [
2022-07-15 07:59:43 +00:00
{
name = allEventBlocks;
value = {
extraOptions.setEnv = "TERM=xterm-256color";
};
}
2020-11-09 00:21:32 +00:00
]));
};
2020-10-25 11:36:16 +00:00
programs.bash = {
enable = true;
enableVteIntegration = !isDarwin;
2020-10-25 11:36:16 +00:00
initExtra = ''
function join_by { local IFS="$1"; shift; echo "$*"; }
if [[ -z "$LAUNCH_SHLVL" ]]; then
export LAUNCH_SHLVL="$SHLVL"
fi
export LAUNCH_DEPTH="$(expr $SHLVL - $LAUNCH_SHLVL)"
export LAUNCH_DEPTH_STR=""
if [[ "$LAUNCH_DEPTH" > 0 ]]; then
if [[ "$PATH" == /nix/store/* ]]; then
declare -a RECENT_PKGS
while read -rd: pathseg; do
if [[ "$pathseg" != /nix/store/* ]]; then
break
fi
RECENT_PKGS+=("$(echo "$pathseg" | sed -E -e 's,^/nix/store/[a-z0-9]+-,,' -e 's,/.*$,,' -e 's,-[0-9.]+$,,')")
done <<< $PATH
RECENT_PKG="$(join_by ":" "''${RECENT_PKGS[@]}")"
if [[ "''${#RECENT_PKG}" > 32 ]]; then
RECENT_PKGS="''${RECENT_PKGS[0]}"
fi
if [[ ! -z "$RECENT_PKG" ]]; then
LAUNCH_DEPTH_STR="[$RECENT_PKG] "
fi
fi
if [[ -z "$LAUNCH_DEPTH_STR" ]]; then
LAUNCH_DEPTH_STR="[$LAUNCH_DEPTH] "
fi
fi
export PS1="\n\[\033[1;32m\]$LAUNCH_DEPTH_STR[\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$ \[\033[0m\]"
'';
};
programs.vim.enable = true;
programs.vim.packageConfigurable = pkgs.vim_configurable.override {
guiSupport = false;
};
2020-10-25 11:36:16 +00:00
home.packages = (with pkgs; ([
2020-10-25 11:36:16 +00:00
ripgrep
whois
dnsutils
] ++ lib.optionals (configName != null) [
2021-03-20 12:11:45 +00:00
# This only applies to "external" users of this config.
(writeShellScriptBin "home-manager" ''
#!/bin/sh
exec "${home-manager}/bin/home-manager" -f "${config.home.homeDirectory}/depot/home-manager-ext.nix" -A "${configName}" "$@"
'')
2023-01-15 16:10:12 +00:00
tmux rsync libarchive tcpdump restic
depot.nix.pkgs.terminfos
2021-03-20 12:11:45 +00:00
iftop htop jq
2021-04-10 22:17:28 +00:00
depot.nix.pkgs.mercurial
2021-02-14 21:40:41 +00:00
] ++ lib.optionals isLinux [
iotop
]));
2020-10-25 11:36:16 +00:00
2022-11-02 00:49:53 +00:00
# No manuals.
manual.manpages.enable = false;
manual.json.enable = false;
manual.html.enable = false;
2020-10-25 11:36:16 +00:00
home.stateVersion = "20.09";
}