nixos/hosts/default/home.nix

557 lines
15 KiB
Nix

{ config, pkgs, inputs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "crony";
home.homeDirectory = "/home/crony";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.11"; # Please read the comment before changing.
imports =
[
inputs.nixvim.homeManagerModules.nixvim
];
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
pkgs.librewolf
pkgs.thunderbird
pkgs.qutebrowser
pkgs.discord
pkgs.neofetch
pkgs.keepassxc
pkgs.buku
pkgs.bukubrow
pkgs.tmux
pkgs.rclone
pkgs.age
pkgs.alacritty
pkgs.nitch
pkgs.ripgrep
pkgs.libarchive
pkgs.nsxiv
pkgs.imagemagick
pkgs.ffmpeg
pkgs.glow
pkgs.piper
pkgs.krita
pkgs.tutanota-desktop
pkgs.delfin
pkgs.nurl
(pkgs.nerdfonts.override { fonts = [ "CascadiaCode" ]; })
# My custom dmenu build
(pkgs.dmenu.overrideAttrs (oldAttrs: rec {
src = builtins.fetchGit {
url = "https://code.cronyakatsuki.xyz/crony/dmenu";
rev = "10dcddf14b38cfd965ab27f084139513baed70bf";
};
}))
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy. ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. If you don't want to manage your shell through Home
# Manager then you have to manually source 'hm-session-vars.sh' located at
# either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/crony/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
EDITOR = "nvim";
BROWSER = "qutebrowser";
TERMINAL = "alacritty";
};
# Fix environmental variables not loaded in plasma x11
xsession.enable = true;
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
# gpg settings
programs.gpg = {
enable = true;
homedir = "${config.xdg.dataHome}/gnupg";
};
# Make it use kde for flkdsjlkfdlsjflkdsjflsdjklfjdsklf
services.gpg-agent = {
enable = true;
pinentryFlavor = "qt";
};
# Btop settings
programs.btop = {
enable = true;
settings = {
color_theme = "catppuccin_frappe";
vim_keys = true;
};
};
# Mpv settings
programs.mpv = {
enable = true;
config = {
ytdl-format="bestvideo[height<=?1080][fps<=?60][vcodec!=?vp9]+bestaudio/best";
ytdl-raw-options="extractor-args=youtube:player-client=android";
fs=true;
force-window="immediate";
screenshot-template="%F - [%P]v%#01n";
sub-file-paths="Subs;subs";
sub-auto="all";
slang="english,eng,en";
};
scripts = with pkgs.mpvScripts; [ mpris sponsorblock uosc thumbfast quality-menu ];
};
# NNN Settings
programs.nnn = {
enable = true;
package = pkgs.nnn.override ({ withNerdIcons = true; });
bookmarks = { d = "~/Documents"; D = "~/Downloads"; p = "~/Pictures"; v = "~/Videos";};
extraPackages = with pkgs; [ pmount ffmpegthumbnailer mediainfo ueberzugpp poppler_utils gnome-epub-thumbnailer ];
plugins.mappings = { u = "nmount"; c = "chksum"; r = "gitroot"; v = "imgview"; m = "mtpmount"; d = "xdgdefault"; x = "togglex"; p = "preview-tui"; };
plugins.src = (pkgs.fetchFromGitHub { owner = "jarun"; repo = "nnn"; rev = "v4.9"; sha256 = "sha256-g19uI36HyzTF2YUQKFP4DE2ZBsArGryVHhX79Y0XzhU=";}) + "/plugins";
};
# Mangohud settings
programs.mangohud = {
enable = true;
settings = {
# GPU SETTINGS
gpu_stats = true;
gpu_temp = true;
gpu_core_clock = true;
gpu_power = true;
gpu_text = "GPU";
gpu_load_change = true;
gpu_load_color = "39F900,FDFD09,B22222";
# CPU SETTINGS
cpu_stats = true;
cpu_temp = true;
cpu_text = "CPU";
cpu_mhz = true;
cpu_load_change = true;
cpu_load_value = "60,90";
cpu_load_color = "39F900,FDFD09,B22222";
# Vram/Ram/Swap
vram = true;
ram = true;
swap = true;
# Fps settings
fps = true;
fps_sampling_period = "1000";
fps_color_change = true;
fps_value = "30,60";
fps_color = "B22222,FDFD09,39F900";
frametime = true;
# Misc
gpu_name = true;
vulkan_driver = true;
show_fps_limit = true;
resolution = true;
round_corners = "5";
};
};
# But we all know I love zsh
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
history.path = "${config.xdg.dataHome}/zsh/history";
dotDir = ".config/zsh";
envExtra = ''
# NNN settings
export NNN_FIFO="/tmp/nnn.fifo"
export NNN_SSHFS="sshfs -o follow_symlinks"
export NNN_TERMINAL="alacritty --class preview,preview"
# Catppuccin colors nnn
BLK="03" CHR="03" DIR="04" EXE="02" REG="07" HARDLINK="05" SYMLINK="05" MISSING="08" ORPHAN="01" FIFO="06" SOCK="03" UNKNOWN="01"
export NNN_COLORS="#04020301;4231"
export NNN_FCOLORS="$BLK$CHR$DIR$EXE$REG$HARDLINK$SYMLINK$MISSING$ORPHAN$FIFO$SOCK$UNKNOWN"
'';
initExtra = ''
# VI Mode escape timeout fix
export KEYTIMEOUT=1
# Substring search settings
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold"
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=black,bold'
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
'';
initExtraFirst = ''
nitch
'';
zplug = {
enable = true;
plugins = [
{ name = "zap-zsh/supercharge"; }
{ name = "zap-zsh/completions"; }
{ name = "zap-zsh/vim"; }
{ name = "chivalryq/git-alias"; }
{ name = "zdharma-continuum/fast-syntax-highlighting"; }
{ name = "MichaelAquilina/zsh-you-should-use"; }
{ name = "zsh-users/zsh-history-substring-search"; }
];
};
};
# Eza settings
programs.eza = {
enable = true;
enableAliases = true;
git = true;
icons = true;
};
# Zoxide settings
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
# Starhip settings
programs.starship = {
enable = true;
enableZshIntegration = true;
};
# Fzf settings
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
# Nixvim
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
options = {
hlsearch = false;
incsearch = true;
number = true;
relativenumber = true;
tabstop = 4;
softtabstop = 4;
shiftwidth = 4;
expandtab = true;
smartindent = true;
mouse = "";
breakindent = true;
undofile = true;
swapfile = true;
ignorecase = true;
smartcase = true;
signcolumn = "yes";
completeopt = "menuone,noselect";
updatetime = 50;
timeoutlen = 300;
colorcolumn = "80";
showmode = false;
laststatus = 3;
splitbelow = true;
splitright = true;
};
globals = {
mapleader = " ";
maplocalleader = ";";
};
extraConfigLuaPost = ''
vim.notify = require("mini.notify").make_notify()
'';
plugins = {
harpoon = {
enable = true;
keymaps = {
addFile = "<leader>a";
toggleQuickMenu = "<C-e>";
navFile = { "1" = "<C-j>"; "2" = "<C-k>"; "3" = "<C-l>"; "4" = "<C-;>"; };
};
};
oil = {
enable = true;
defaultFileExplorer = true;
extraOptions = { show_hidden = true; };
};
treesitter.enable = true;
gitsigns = {
enable = true;
signs = {
add.text = "";
change.text = "";
changedelete.text = "";
delete.text = "";
topdelete.text = "";
untracked.text = "";
};
onAttach.function = ''
function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end
-- stylua: ignore start
map("n", "]g", gs.next_hunk, "Next git hunk")
map("n", "[g", gs.prev_hunk, "Previous git hunk")
end
'';
};
mini = {
enable = true;
modules = {
statusline = {
set_vim_settings = false;
};
comment = {};
notify = {};
};
};
telescope = {
enable = true;
extensions = {
fzf-native = {
enable = true;
fuzzy = true;
overrideGenericSorter = true;
overrideFileSorter = true;
caseMode = "smart_case";
};
ui-select.enable = true;
};
keymaps = {
"<leader>pf" = "find_files";
"<C-p>" = "git_files";
"<leader>vh" = "help_tags";
"<leader>ps" = "grep_string";
};
};
lsp = {
enable = true;
servers = {
lua-ls.enable = true;
nil_ls.enable = true;
};
keymaps = {
diagnostic = {
"<leader>vd" = "open_float";
"[d" = "goto_next";
"]d" = "goto_prev";
};
lspBuf = {
K = "hover";
gd = "definition";
gD = "declaration";
gi = "implementation";
"<leader>lca" = "code_action";
"<leader>lrn" = "rename";
"<C-h>" = "signature_help";
};
};
preConfig = ''
local function sign_define(args)
vim.fn.sign_define(args.name, {
texthl = args.name,
text = args.text,
numhl = "",
})
end
sign_define({ name = "DiagnosticSignError", text = "E" })
sign_define({ name = "DiagnosticSignWarn", text = "W" })
sign_define({ name = "DiagnosticSignHint", text = "H" })
sign_define({ name = "DiagnosticSignInfo", text = "I" })
'';
};
nvim-cmp = {
enable = true;
autoEnableSources = true;
sources = [
{name = "nvim_lsp";}
{name = "path";}
{name = "snippy";}
];
snippet.expand = "snippy";
mapping = {
"<C-l>" = "cmp.mapping.confirm({ select = false })";
"<C-j>" = {
action = ''
function(fallback)
if cmp.visible then
cmp.select_next_item()
else
fallback()
end
end
'';
modes = [ "i" "s" ];
};
"<C-k>" = {
action = ''
function(fallback)
if cmp.visible then
cmp.select_prev_item()
else
fallback()
end
end
'';
modes = [ "i" "s" ];
};
};
};
};
colorschemes.catppuccin = {
enable = true;
flavour = "frappe";
styles = {
functions = [ "bold" ];
keywords = [ "bold" ];
};
};
extraPlugins = with pkgs.vimPlugins; [
vim-snippets
];
};
##-- Restic Timers And Services --##
# Restic backup
systemd.user.services = {
restic_backup = {
Unit.Description = "Restic backup service";
Service = {
Type = "oneshot";
ExecStart = toString (
pkgs.writeShellScript "restic-backup" ''
. /etc/restic/local
restic backup --files-from /home/crony/.config/restic/list --verbose && restic forget --keep-last 10 --keep-daily 7 --keep-weekly 5 --keep-monthly 12
. /etc/restic/online
restic backup --files-from /home/crony/.config/restic/list --verbose && restic forget --keep-last 10 --keep-daily 7 --keep-weekly 5 --keep-monthly 12
''
);
};
Install.WantedBy = [ "default.target" ];
};
};
systemd.user.timers = {
restic_backup = {
Unit.Description = "Restic backup timer";
Timer = {
OnBootSec = "5m";
OnUnitActiveSec = "6h";
};
Install.WantedBy = [ "timers.target" ];
};
};
# Restic check
systemd.user.services = {
restic_check = {
Unit.Description = "Restic check service";
Service = {
Type = "oneshot";
ExecStart = toString (
pkgs.writeShellScript "restic-check" ''
. /etc/restic/local
restic check --read-data-subset=10%
. /etc/restic/online
restic check --read-data-subset=10%
''
);
};
Install.WantedBy = [ "default.target" ];
};
};
systemd.user.timers = {
restic_check = {
Unit.Description = "Restic check timer";
Timer = {
OnCalendar="Thu *-*-* 18:00:00";
};
Install.WantedBy = [ "timers.target" ];
};
};
# Restic prune
systemd.user.services = {
restic_prune = {
Unit.Description = "Restic prune service";
Service = {
Type = "oneshot";
ExecStart = toString (
pkgs.writeShellScript "restic-prune" ''
. /etc/restic/local
restic prune
. /etc/restic/online
restic prune
''
);
};
Install.WantedBy = [ "default.target" ];
};
};
systemd.user.timers = {
restic_prune = {
Unit.Description = "Restic prune timer";
Timer = {
OnCalendar="Fri *-*-* 18:00:00";
};
Install.WantedBy = [ "timers.target" ];
};
};
}