From 264dff65659e1df8974b77914561209ea7599c1c Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Wed, 14 Feb 2024 21:49:54 +0100 Subject: [PATCH] Move home manager program configs to separate modules --- home-manager/home.nix | 538 +----------------------------- home-manager/modules/btop.nix | 11 + home-manager/modules/dmenu.nix | 12 + home-manager/modules/gpg.nix | 15 + home-manager/modules/mangohud.nix | 42 +++ home-manager/modules/mpv.nix | 18 + home-manager/modules/nnn.nix | 12 + home-manager/modules/nvim.nix | 213 ++++++++++++ home-manager/modules/restic.nix | 89 +++++ home-manager/modules/shell.nix | 73 ++++ home-manager/modules/tmux.nix | 68 ++++ 11 files changed, 565 insertions(+), 526 deletions(-) create mode 100644 home-manager/modules/btop.nix create mode 100644 home-manager/modules/dmenu.nix create mode 100644 home-manager/modules/gpg.nix create mode 100644 home-manager/modules/mangohud.nix create mode 100644 home-manager/modules/mpv.nix create mode 100644 home-manager/modules/nnn.nix create mode 100644 home-manager/modules/nvim.nix create mode 100644 home-manager/modules/restic.nix create mode 100644 home-manager/modules/shell.nix create mode 100644 home-manager/modules/tmux.nix diff --git a/home-manager/home.nix b/home-manager/home.nix index c3a5a5c..c2dd3b1 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, inputs, ... }: +{ pkgs, ... }: { # Basic user info @@ -11,7 +11,16 @@ # Imports imports = [ - inputs.nixvim.homeManagerModules.nixvim + ./modules/gpg.nix + ./modules/btop.nix + ./modules/mpv.nix + ./modules/tmux.nix + ./modules/nnn.nix + ./modules/dmenu.nix + ./modules/mangohud.nix + ./modules/shell.nix + ./modules/nvim.nix + ./modules/restic.nix ]; @@ -36,19 +45,12 @@ krita # best drawing program tutanota-desktop # fjdlkfjldjflkd delfin # jellyfin client - nurl # nix tool + nurl # nix git config tool ripgrep # Neovim telescope dependency lazygit # Amazing git tui lm_sensors # Sensor monitoring tool (nerdfonts.override { fonts = [ "CascadiaCode" ]; }) # Best font - # My custom dmenu build - (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 @@ -83,520 +85,4 @@ # 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 ]; - }; - - programs.tmux = { - enable = true; - disableConfirmationPrompt = true; - escapeTime = 0; - keyMode = "vi"; - mouse = true; - plugins = with pkgs; [ - tmuxPlugins.sensible - tmuxPlugins.yank - { - plugin = tmuxPlugins.catppuccin; - extraConfig = '' - set -g @catppuccin_flavour 'frappe' - set -g @catppuccin_window_right_separator "█ " - set -g @catppuccin_window_number_position "right" - set -g @catppuccin_window_middle_separator " | " - - set -g @catppuccin_window_default_fill "none" - - set -g @catppuccin_window_current_fill "all" - - set -g @catppuccin_status_modules_right "application session date_time" - set -g @catppuccin_status_left_separator "█" - set -g @catppuccin_status_right_separator "█" - ''; - } - ]; - prefix = "C-Space"; - terminal = "alacritty"; - extraConfig = '' - # Fix colors - set-option -sa terminal-overrides ",alacritty:Tc" - - # start window and panes indexing at 1 - set -g base-index 1 - set -g pane-base-index 1 - set-window-option -g pane-base-index 1 - set-option -g renumber-windows on - - # Faster statusbar updates - set-option -g status-interval 1 - - # Easier movement - bind -n M-K previous-window - bind -n M-J next-window - - # Better split bindings - bind "'" split-window -v -c "#{pane_current_path}" - bind '\' split-window -h -c "#{pane_current_path}" - - # Vim keybindings for pane movement - setw -g mode-keys vi - bind-key h select-pane -L - bind-key j select-pane -D - bind-key k select-pane -U - bind-key l select-pane -R - - # Status bar border - setw -g pane-border-status top - setw -g pane-border-format '─' - - # Bar to top - set-option -g status-position top - ''; - }; - - # 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 nsxiv ]; - 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 = "a"; - toggleQuickMenu = ""; - navFile = { "1" = ""; "2" = ""; "3" = ""; "4" = ""; }; - }; - }; - - 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 = { - "pf" = "find_files"; - "" = "git_files"; - "vh" = "help_tags"; - "ps" = "grep_string"; - }; - }; - - lsp = { - enable = true; - servers = { - lua-ls.enable = true; - nil_ls.enable = true; - marksman.enable = true; - }; - keymaps = { - diagnostic = { - "vd" = "open_float"; - "[d" = "goto_next"; - "]d" = "goto_prev"; - }; - lspBuf = { - K = "hover"; - gd = "definition"; - gD = "declaration"; - gi = "implementation"; - "lca" = "code_action"; - "lrn" = "rename"; - "" = "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 = { - "" = "cmp.mapping.confirm({ select = false })"; - "" = { - action = '' - function(fallback) - if cmp.visible then - cmp.select_next_item() - else - fallback() - end - end - ''; - modes = [ "i" "s" ]; - }; - "" = { - 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" ]; - }; - }; } diff --git a/home-manager/modules/btop.nix b/home-manager/modules/btop.nix new file mode 100644 index 0000000..1c6b25e --- /dev/null +++ b/home-manager/modules/btop.nix @@ -0,0 +1,11 @@ +{ inputs, ... }: +{ + # Btop settings + programs.btop = { + enable = true; + settings = { + color_theme = "catppuccin_frappe"; + vim_keys = true; + }; + }; +} diff --git a/home-manager/modules/dmenu.nix b/home-manager/modules/dmenu.nix new file mode 100644 index 0000000..27d1754 --- /dev/null +++ b/home-manager/modules/dmenu.nix @@ -0,0 +1,12 @@ +{ inputs, pkgs, ... }: +{ + home.packages = with pkgs; [ + # My custom dmenu build + (dmenu.overrideAttrs (oldAttrs: rec { + src = builtins.fetchGit { + url = "https://code.cronyakatsuki.xyz/crony/dmenu"; + rev = "10dcddf14b38cfd965ab27f084139513baed70bf"; + }; + })) + ]; +} diff --git a/home-manager/modules/gpg.nix b/home-manager/modules/gpg.nix new file mode 100644 index 0000000..5c519a1 --- /dev/null +++ b/home-manager/modules/gpg.nix @@ -0,0 +1,15 @@ +{ inputs, config, ...}: + +{ + # gpg settings + programs.gpg = { + enable = true; + homedir = "${config.xdg.dataHome}/gnupg"; + }; + + # Make it use kde for flkdsjlkfdlsjflkdsjflsdjklfjdsklf + services.gpg-agent = { + enable = true; + pinentryFlavor = "qt"; + }; +} diff --git a/home-manager/modules/mangohud.nix b/home-manager/modules/mangohud.nix new file mode 100644 index 0000000..5560d36 --- /dev/null +++ b/home-manager/modules/mangohud.nix @@ -0,0 +1,42 @@ +{ inputs, ... }: +{ + # 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"; + }; + }; +} diff --git a/home-manager/modules/mpv.nix b/home-manager/modules/mpv.nix new file mode 100644 index 0000000..68518fd --- /dev/null +++ b/home-manager/modules/mpv.nix @@ -0,0 +1,18 @@ +{ inputs, pkgs, ... }: +{ + # 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 ]; + }; +} diff --git a/home-manager/modules/nnn.nix b/home-manager/modules/nnn.nix new file mode 100644 index 0000000..3d84580 --- /dev/null +++ b/home-manager/modules/nnn.nix @@ -0,0 +1,12 @@ +{ inputs, pkgs, ... }: +{ + # 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 nsxiv ]; + 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"; + }; +} diff --git a/home-manager/modules/nvim.nix b/home-manager/modules/nvim.nix new file mode 100644 index 0000000..ecf483a --- /dev/null +++ b/home-manager/modules/nvim.nix @@ -0,0 +1,213 @@ +{ inputs, pkgs, ... }: +{ + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ]; + + # 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 = "a"; + toggleQuickMenu = ""; + navFile = { "1" = ""; "2" = ""; "3" = ""; "4" = ""; }; + }; + }; + + 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 = { + "pf" = "find_files"; + "" = "git_files"; + "vh" = "help_tags"; + "ps" = "grep_string"; + }; + }; + + lsp = { + enable = true; + servers = { + lua-ls.enable = true; + nil_ls.enable = true; + marksman.enable = true; + }; + keymaps = { + diagnostic = { + "vd" = "open_float"; + "[d" = "goto_next"; + "]d" = "goto_prev"; + }; + lspBuf = { + K = "hover"; + gd = "definition"; + gD = "declaration"; + gi = "implementation"; + "lca" = "code_action"; + "lrn" = "rename"; + "" = "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 = { + "" = "cmp.mapping.confirm({ select = false })"; + "" = { + action = '' + function(fallback) + if cmp.visible then + cmp.select_next_item() + else + fallback() + end + end + ''; + modes = [ "i" "s" ]; + }; + "" = { + 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 + ]; + }; +} diff --git a/home-manager/modules/restic.nix b/home-manager/modules/restic.nix new file mode 100644 index 0000000..e7b71ca --- /dev/null +++ b/home-manager/modules/restic.nix @@ -0,0 +1,89 @@ +{ inputs, pkgs, ... }: +{ + ##-- 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" ]; + }; + }; +} diff --git a/home-manager/modules/shell.nix b/home-manager/modules/shell.nix new file mode 100644 index 0000000..fd9fed3 --- /dev/null +++ b/home-manager/modules/shell.nix @@ -0,0 +1,73 @@ +{ inputs, config, ... }: +{ + # 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; + }; +} diff --git a/home-manager/modules/tmux.nix b/home-manager/modules/tmux.nix new file mode 100644 index 0000000..e2f3bef --- /dev/null +++ b/home-manager/modules/tmux.nix @@ -0,0 +1,68 @@ +{ inputs, pkgs, ... }: +{ + programs.tmux = { + enable = true; + disableConfirmationPrompt = true; + escapeTime = 0; + keyMode = "vi"; + mouse = true; + plugins = with pkgs; [ + tmuxPlugins.sensible + tmuxPlugins.yank + { + plugin = tmuxPlugins.catppuccin; + extraConfig = '' + set -g @catppuccin_flavour 'frappe' + set -g @catppuccin_window_right_separator "█ " + set -g @catppuccin_window_number_position "right" + set -g @catppuccin_window_middle_separator " | " + + set -g @catppuccin_window_default_fill "none" + + set -g @catppuccin_window_current_fill "all" + + set -g @catppuccin_status_modules_right "application session date_time" + set -g @catppuccin_status_left_separator "█" + set -g @catppuccin_status_right_separator "█" + ''; + } + ]; + prefix = "C-Space"; + terminal = "alacritty"; + extraConfig = '' + # Fix colors + set-option -sa terminal-overrides ",alacritty:Tc" + + # start window and panes indexing at 1 + set -g base-index 1 + set -g pane-base-index 1 + set-window-option -g pane-base-index 1 + set-option -g renumber-windows on + + # Faster statusbar updates + set-option -g status-interval 1 + + # Easier movement + bind -n M-K previous-window + bind -n M-J next-window + + # Better split bindings + bind "'" split-window -v -c "#{pane_current_path}" + bind '\' split-window -h -c "#{pane_current_path}" + + # Vim keybindings for pane movement + setw -g mode-keys vi + bind-key h select-pane -L + bind-key j select-pane -D + bind-key k select-pane -U + bind-key l select-pane -R + + # Status bar border + setw -g pane-border-status top + setw -g pane-border-format '─' + + # Bar to top + set-option -g status-position top + ''; + }; +}