nixconf/modules/home/core/default.nix

346 lines
9.6 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
inherit (lib) types;
cfg = config.mtxyz;
in
{
options.mtxyz = {
private = lib.mkOption {
type = types.bool;
default = false;
};
minimal = lib.mkOption {
type = types.bool;
default = false;
};
graphical= lib.mkOption {
type = types.bool;
default = true;
};
};
config = {
home.packages = with pkgs; ([
delta unzip tree pwgen nvd nixpkgs-fmt home-manager
kitty.terminfo nix-output-monitor mosh universal-ctags
] ++ (lib.optionals cfg.graphical [
xclip wl-clipboard neovide vlc helvum
freetube slack armcord logseq zoom-us fractal
]) ++ (lib.optionals (cfg.graphical && !cfg.minimal) [
ungoogled-chromium reaper cardinal plex-media-player puredata kate
minetest prismlauncher mangohud qflipper bottles dosbox blender
]) ++ (lib.optionals cfg.private [
hledger hledger-ui diceware libsecret
]) ++ (lib.optionals (cfg.private && cfg.graphical) [
thunderbird
]));
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.firefox = {
enable = cfg.graphical;
nativeMessagingHosts = with pkgs; lib.optionals cfg.private [
browserpass
];
policies = {
BlockAboutConfig = true;
};
profiles.default = {
extensions = (with pkgs.nur.repos.rycee.firefox-addons; [
browserpass adnauseam pay-by-privacy libredirect unpaywall
]);
settings = {
"browser.fixup.domainsuffixwhitelist.lan" = true;
};
search = {
force = true;
default = "DuckDuckGo Start";
engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{ name = "type"; value = "packages"; }
{ name = "channel"; value = "unstable"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "''${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
"Nix Options" = {
urls = [{
template = "https://search.nixos.org/options";
params = [
{ name = "channel"; value = "unstable"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "''${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@no" ];
};
"NixOS Wiki" = {
urls = [{
template = "https://nixos.wiki/index.php";
params = [
{ name = "search"; value = "{searchTerms}"; }
];
}];
iconUpdateURL = "https://nixos.wiki/favicon.png";
updateInterval = 24 * 60 * 60 * 1000; # every day
definedAliases = [ "@nw" ];
};
"DuckDuckGo Start" = {
urls = [{
template = "https://duckduckgo.com/";
params = [
{ name = "start"; value = "1"; }
{ name = "q"; value = "{searchTerms}"; }
];
}];
iconUpdateURL = "https://duckduckgo.com/favicon.png";
definedAliases = [ "@ddg" ];
};
"GitHub" = {
urls = [{
template = "https://github.com/search";
params = [
{ name = "ref"; value = "opensearch"; }
{ name = "q"; value = "{searchTerms}"; }
];
}];
iconUpdateURL = "https://github.com/favicon.ico";
definedAliases = [ "@gh" ];
};
"Bing".metaData.hidden = true;
"Google".metaData.hidden = true;
"DuckDuckGo".metaData.hidden = true;
"Amazon.com".metaData.hidden = true;
"eBay".metaData.hidden = true;
};
};
};
};
programs.wezterm = {
enable = cfg.graphical;
extraConfig = (builtins.readFile ./wezterm.lua);
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.zoxide = {
enable = true;
enableFishIntegration = true;
options = [ "--cmd cd" ];
};
programs.fish = {
enable = true;
functions = {
fish_prompt = (builtins.readFile ./fish_prompt.fish);
fish_greeting = "";
last_cmd = "echo $history[1]";
fish_command_not_found = ''
set -l last_argv $argv
echo \"$argv[1]\" Command Not Found
'';
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 # 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.gpg.enable = true;
services.gpg-agent = {
enable = true;
defaultCacheTtl = 1800;
pinentryFlavor = if cfg.graphical then "gnome3" else "tty";
};
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 = true;
home.stateVersion = "22.11";
};
}