nixconf/modules/home/core/default.nix

342 lines
8.4 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
inherit (lib) types;
cfg = config.mtxyz.platform;
in
{
options.mtxyz.platform = {
private = lib.mkOption {
type = types.bool;
default = false;
};
minimal = lib.mkOption {
type = types.bool;
default = false;
};
portable = lib.mkOption {
type = types.bool;
default = false;
};
};
imports = [
./neovim.nix
];
config = {
home.packages = with pkgs; [
delta unzip tree pwgen nvd nixpkgs-fmt home-manager git-crypt
kitty.terminfo nix-output-monitor mosh universal-ctags
] ++ (lib.optionals cfg.private [
hledger hledger-ui diceware libsecret
]);
accounts = lib.mkIf cfg.private {
email.accounts.mtxyz = rec {
address = "me@mtxyz.me";
userName = address;
passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup login ${address}";
realName = "mtxyz";
primary = true;
aliases = [
"me@mtxyz.me"
"billy@mtxyz.me"
"billie@mtxyz.me"
"bailey@mtxyz.me"
"contact@wasv.me"
];
imap = {
host = "imap.migadu.com";
port = 993;
tls.enable = true;
};
smtp = {
host = "smtp.migadu.com";
port = 465;
tls.enable = true;
};
folders = {
inbox = "INBOX";
trash = "Archives";
};
};
calendar.accounts.home = {
name = "Home";
primary = true;
remote = rec {
type = "caldav";
userName = "me@mtxyz.me";
passwordCommand = ["${pkgs.libsecret}/bin/secret-tool" "lookup" "login" userName];
url = "https://cdav.migadu.com/calendars/${userName}/home/";
};
};
};
manual.html.enable = true;
home.keyboard.layout = "us";
home.keyboard.options = [ "caps:super" ];
programs.tmux = {
enable = true;
mouse = true;
aggressiveResize = true;
clock24 = true;
newSession = true;
extraConfig = ''
bind - split-window -h -c "#{pane_current_path}"
bind | split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
set -sg escape-time 0
'';
};
programs.btop = {
enable = true;
settings = {
color_theme = "TTY";
theme_background = false;
};
};
programs.password-store.enable = lib.mkDefault cfg.private;
programs.password-store.package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]);
services.syncthing.enable = lib.mkDefault cfg.private;
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.zoxide = {
enable = true;
enableFishIntegration = true;
options = [ "--cmd cd" ];
};
programs.fish = {
enable = true;
functions = {
fish_greeting = "echo ~~ Hi ~$USER! Welcome to $hostname. ~~";
__fish_command_not_found_handler = {
body = "__fish_default_command_not_found_handler $argv[1]";
onEvent = "fish_command_not_found";
};
last_cmd = "echo $history[1]";
update-sys = ''
argparse -i 'f/flake=' -- $argv
set -f mode switch
if set -q argv[1]
set -f mode $argv[1]
end
set -f flake nixconf
if set -q _flag_f
set -f flake $_flag_f
end
sudo echo -n; or exit 1 # Make sure sudo has already prompted for password.
sudo nixos-rebuild $mode --log-format internal-json -v --flake $flake &| nom --json
'';
};
interactiveShellInit = ''
abbr --position anywhere -a !! -f last_cmd
'';
};
programs.starship = {
enable = true;
settings = {
scan_timeout = 10;
command_timeout = 250;
format = lib.concatStrings [
"$status"
"$cmd_duration"
" $fill "
"$time"
"$line_break"
"$username"
"$hostname"
"$sudo"
"$directory"
"$git_branch"
"$git_state"
"$git_status"
"$package"
"$shlvl"
"$nix_shell"
"$direnv"
"$line_break"
"$character"
];
character = {
error_symbol = "[>](bold green)";
};
directory = {
truncate_to_repo = false;
};
status = {
pipestatus = true;
disabled = false;
};
time = {
disabled = false;
time_format = "%F %T %z";
};
sudo = {
disabled = false;
};
fill = {
symbol = "";
style = "blue";
};
hostname = {
ssh_only = false;
detect_env_vars = ["!TMUX" "SSH_CONNECTION"];
disabled = false;
};
git_branch = {
ignore_branches = ["master" "main"];
truncation_length = 10;
only_attached = false;
};
git_status = {
ahead = " $count";
diverged = " $ahead_count $behind_count";
behind = " $count";
};
};
};
# Launch fish for user shell from bash
programs.bash = {
enable = true;
initExtra = ''
if [[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]; then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec fish ''$LOGIN_OPTION
fi
'';
};
programs.lsd = {
enable = true;
enableAliases = true;
settings = {
size = "short";
indicators = true;
ignore-globs = [
".git"
".hg"
];
blocks = [
"permission"
"user"
"group"
"size"
"date"
"name"
"git"
];
};
};
programs.gpg.enable = true;
services.gpg-agent = {
enable = true;
defaultCacheTtl = 1800;
pinentryPackage = lib.mkDefault pkgs.pinentry;
};
programs.bat.enable = true;
programs.lazygit.enable = true;
programs.git = {
enable = true;
userName = "Bailey Stevens";
userEmail = "me@mtxyz.me";
package = pkgs.gitFull;
aliases = {
lazy = "!lazygit";
graph = "log --graph --oneline";
};
extraConfig = {
pull.rebase = true;
rebase.autostash = true;
init.defaultBranch = "main";
push.autoSetupRemote = true;
sendemail.confirm = "always";
sendemail.identity = "mtxyz";
credential.helper = "libsecret";
};
ignores = [
"*~"
"*.swp"
".cache/"
".venv/"
"compile_commands.json"
".#*"
"tags"
".vscode/"
".gradle"
".idea"
".direnv"
".envrc"
];
delta.enable = true;
delta.options.line-numbers = true;
};
programs.ssh = {
enable = true;
controlMaster = "auto";
controlPersist = "5m";
matchBlocks = {
"jellydonut sol pegasi gallifrey" = {
forwardAgent = true;
hostname = "%h.gg.lan";
};
"freedom shell" = {
user = "wasv";
forwardAgent = true;
hostname = "%h.csh.rit.edu";
};
};
};
programs.fzf.enable = true;
programs.zellij = {
enable = true;
settings = {
pane_frames = false;
default_mode = "locked";
default_layout = "compact";
};
};
programs.home-manager.enable = lib.mkDefault cfg.private;
home.stateVersion = "22.11";
};
}