mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-10 01:42:55 +00:00
clean up and improve docs
This commit is contained in:
parent
ef2ee7b871
commit
3d6f57c324
@ -10,6 +10,7 @@
|
|||||||
pkgs.vimPlugins.which-key-nvim # Keybind helper
|
pkgs.vimPlugins.which-key-nvim # Keybind helper
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Initialize some plugins
|
||||||
setup.Comment = { };
|
setup.Comment = { };
|
||||||
setup.colorizer = { };
|
setup.colorizer = { };
|
||||||
setup.glow = { };
|
setup.glow = { };
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ pkgs, dsl, ... }: {
|
{ pkgs, dsl, ... }: {
|
||||||
|
|
||||||
|
# Telescope is a fuzzy finder that can work with different sub-plugins
|
||||||
|
|
||||||
plugins = [
|
plugins = [
|
||||||
pkgs.vimPlugins.telescope-nvim
|
pkgs.vimPlugins.telescope-nvim
|
||||||
pkgs.vimPlugins.project-nvim
|
pkgs.vimPlugins.project-nvim
|
||||||
|
@ -12,6 +12,8 @@ vim.api.nvim_create_autocmd("TermOpen", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- These are all the different types of terminals we can trigger
|
||||||
|
|
||||||
local terminal = require("toggleterm.terminal").Terminal
|
local terminal = require("toggleterm.terminal").Terminal
|
||||||
|
|
||||||
local basicterminal = terminal:new()
|
local basicterminal = terminal:new()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ pkgs, dsl, ... }: {
|
{ pkgs, dsl, ... }: {
|
||||||
|
|
||||||
|
# Toggleterm provides a floating terminal inside the editor for quick access
|
||||||
|
|
||||||
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
|
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
|
||||||
|
|
||||||
use.toggleterm.setup = dsl.callWith {
|
use.toggleterm.setup = dsl.callWith {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ pkgs, dsl, ... }: {
|
{ pkgs, dsl, ... }: {
|
||||||
|
|
||||||
|
# This plugin creates a side drawer for navigating the current project
|
||||||
|
|
||||||
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
|
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
|
||||||
|
|
||||||
# Disable netrw eagerly
|
# Disable netrw eagerly
|
||||||
@ -10,16 +12,16 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
setup.nvim-tree = {
|
setup.nvim-tree = {
|
||||||
disable_netrw = true;
|
disable_netrw = true; # Disable the built-in file manager
|
||||||
hijack_netrw = true;
|
hijack_netrw = true; # Works as the file manager
|
||||||
sync_root_with_cwd = true;
|
sync_root_with_cwd = true; # Change project whenever currend dir changes
|
||||||
respect_buf_cwd = true;
|
respect_buf_cwd = true; # Change to exact location of focused buffer
|
||||||
update_focused_file = {
|
update_focused_file = { # Change project based on the focused buffer
|
||||||
enable = true;
|
enable = true;
|
||||||
update_root = true;
|
update_root = true;
|
||||||
ignore_list = { };
|
ignore_list = { };
|
||||||
};
|
};
|
||||||
diagnostics = {
|
diagnostics = { # Enable LSP and linter integration
|
||||||
enable = true;
|
enable = true;
|
||||||
icons = {
|
icons = {
|
||||||
hint = "";
|
hint = "";
|
||||||
@ -28,7 +30,7 @@
|
|||||||
error = "";
|
error = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
renderer = {
|
renderer = { # Show files with changes vs. current commit
|
||||||
icons = {
|
icons = {
|
||||||
glyphs = {
|
glyphs = {
|
||||||
git = {
|
git = {
|
||||||
@ -43,6 +45,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
# Set keybinds and initialize program
|
||||||
on_attach = dsl.rawLua ''
|
on_attach = dsl.rawLua ''
|
||||||
function (bufnr)
|
function (bufnr)
|
||||||
local api = require('nvim-tree.api')
|
local api = require('nvim-tree.api')
|
||||||
@ -58,7 +61,7 @@
|
|||||||
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
|
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
view = {
|
view = { # Set look and feel
|
||||||
width = 30;
|
width = 30;
|
||||||
hide_root_folder = false;
|
hide_root_folder = false;
|
||||||
side = "left";
|
side = "left";
|
||||||
@ -67,6 +70,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Toggle the sidebar
|
||||||
lua = ''
|
lua = ''
|
||||||
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
|
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
|
||||||
'';
|
'';
|
||||||
|
@ -18,11 +18,16 @@ in {
|
|||||||
|
|
||||||
home.packages = [ neovim ];
|
home.packages = [ neovim ];
|
||||||
|
|
||||||
|
# Use Neovim as the editor for git commit messages
|
||||||
programs.git.extraConfig.core.editor = "nvim";
|
programs.git.extraConfig.core.editor = "nvim";
|
||||||
|
|
||||||
|
# Set Neovim as the default app for text editing and manual pages
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
EDITOR = "nvim";
|
EDITOR = "nvim";
|
||||||
MANPAGER = "nvim +Man!";
|
MANPAGER = "nvim +Man!";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Create quick aliases for launching Neovim
|
||||||
programs.fish = {
|
programs.fish = {
|
||||||
shellAliases = { vim = "nvim"; };
|
shellAliases = { vim = "nvim"; };
|
||||||
shellAbbrs = {
|
shellAbbrs = {
|
||||||
@ -31,12 +36,20 @@ in {
|
|||||||
vll = "nvim -c 'Telescope oldfiles'";
|
vll = "nvim -c 'Telescope oldfiles'";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Set Neovim as the kitty terminal "scrollback" (vi mode) option.
|
||||||
|
# Requires removing some of the ANSI escape codes that are sent to the
|
||||||
|
# scrollback using sed and baleia, as well as removing several
|
||||||
|
# unnecessary features.
|
||||||
programs.kitty.settings.scrollback_pager = ''
|
programs.kitty.settings.scrollback_pager = ''
|
||||||
$SHELL -c 'sed -r "s/[[:cntrl:]]\]133;[AC]..//g" | ${neovim}/bin/nvim -c "setlocal nonumber norelativenumber nolist laststatus=0" -c "lua baleia = require(\"baleia\").setup({}); baleia.once(0)" -c "map <silent> q :qa!<CR>" -c "autocmd VimEnter * normal G"' '';
|
$SHELL -c 'sed -r "s/[[:cntrl:]]\]133;[AC]..//g" | ${neovim}/bin/nvim -c "setlocal nonumber norelativenumber nolist laststatus=0" -c "lua baleia = require(\"baleia\").setup({}); baleia.once(0)" -c "map <silent> q :qa!<CR>" -c "autocmd VimEnter * normal G"' '';
|
||||||
|
|
||||||
|
# Create a desktop option for launching Neovim from a file manager
|
||||||
|
# (Requires launching the terminal and then executing Neovim)
|
||||||
xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux {
|
xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux {
|
||||||
name = "Neovim wrapper";
|
name = "Neovim wrapper";
|
||||||
exec = "kitty nvim %F";
|
exec = "kitty nvim %F";
|
||||||
|
mimeType = [ "text/plain" "text/markdown" ];
|
||||||
};
|
};
|
||||||
xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux {
|
xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux {
|
||||||
"text/plain" = [ "nvim.desktop" ];
|
"text/plain" = [ "nvim.desktop" ];
|
||||||
@ -45,9 +58,6 @@ in {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# # Used for icons in Vim
|
|
||||||
# fonts.fonts = with pkgs; [ nerdfonts ];
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ config, pkgs, lib, ... }: {
|
{ config, pkgs, lib, ... }: {
|
||||||
|
|
||||||
|
# Allows me to make sure I can work on my dotfiles locally
|
||||||
|
|
||||||
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
|
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
|
||||||
|
|
||||||
config = lib.mkIf config.dotfiles.enable {
|
config = lib.mkIf config.dotfiles.enable {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{ config, ... }: {
|
{ config, ... }: {
|
||||||
|
|
||||||
|
# This is just a placeholder as I expect to interact with my notes in a
|
||||||
|
# certain location
|
||||||
|
|
||||||
home-manager.users.${config.user} = {
|
home-manager.users.${config.user} = {
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ config, pkgs, lib, ... }: {
|
{ config, pkgs, lib, ... }: {
|
||||||
|
|
||||||
|
# Convenience utilities from charm.sh
|
||||||
|
|
||||||
options.charm.enable = lib.mkEnableOption "Charm utilities.";
|
options.charm.enable = lib.mkEnableOption "Charm utilities.";
|
||||||
|
|
||||||
config.home-manager.users.${config.user} = lib.mkIf config.charm.enable {
|
config.home-manager.users.${config.user} = lib.mkIf config.charm.enable {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{ config, ... }: {
|
{ config, ... }: {
|
||||||
|
|
||||||
|
# Enables quickly entering Nix shells when changing directories
|
||||||
home-manager.users.${config.user}.programs.direnv = {
|
home-manager.users.${config.user}.programs.direnv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
nix-direnv.enable = true;
|
nix-direnv.enable = true;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{ config, ... }: {
|
{ config, ... }: {
|
||||||
|
|
||||||
|
# FZF is a fuzzy-finder for the terminal
|
||||||
|
|
||||||
home-manager.users.${config.user} = {
|
home-manager.users.${config.user} = {
|
||||||
|
|
||||||
programs.fzf.enable = true;
|
programs.fzf.enable = true;
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
home.packages = with pkgs; [ calibre ];
|
home.packages = with pkgs; [ calibre ];
|
||||||
# home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; };
|
# home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Forces Calibre to use dark mode
|
||||||
environment.sessionVariables = { CALIBRE_USE_DARK_PALETTE = "1"; };
|
environment.sessionVariables = { CALIBRE_USE_DARK_PALETTE = "1"; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
home-manager.users.${config.user} = {
|
home-manager.users.${config.user} = {
|
||||||
|
|
||||||
|
# Quick button for launching nautilus
|
||||||
xsession.windowManager.i3.config.keybindings = {
|
xsession.windowManager.i3.config.keybindings = {
|
||||||
"${
|
"${
|
||||||
config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier
|
config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier
|
||||||
}+n" = "exec --no-startup-id ${pkgs.gnome.nautilus}/bin/nautilus";
|
}+n" = "exec --no-startup-id ${pkgs.gnome.nautilus}/bin/nautilus";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Generates a QR code and previews it with sushi
|
||||||
programs.fish.functions = {
|
programs.fish.functions = {
|
||||||
qr = {
|
qr = {
|
||||||
body =
|
body =
|
||||||
@ -31,7 +33,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Set default for opening directories
|
# Set Nautilus as default for opening directories
|
||||||
xdg.mimeApps = {
|
xdg.mimeApps = {
|
||||||
associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ];
|
associations.added."inode/directory" = [ "org.gnome.Nautilus.desktop" ];
|
||||||
# associations.removed = {
|
# associations.removed = {
|
||||||
|
47
modules/nixos/system/auto-upgrade.nix
Normal file
47
modules/nixos/system/auto-upgrade.nix
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{ config, pkgs, lib, ... }: {
|
||||||
|
|
||||||
|
# This setting only applies to NixOS, different on Darwin
|
||||||
|
nix.gc.dates = "03:03"; # Run every morning (but before upgrade)
|
||||||
|
|
||||||
|
# Update the system daily by pointing it at the flake repository
|
||||||
|
system.autoUpgrade = {
|
||||||
|
enable = config.server; # Only auto upgrade servers
|
||||||
|
dates = "03:33";
|
||||||
|
flake = "git+${config.dotfilesRepo}";
|
||||||
|
randomizedDelaySec = "25min";
|
||||||
|
operation = "switch";
|
||||||
|
allowReboot = true;
|
||||||
|
rebootWindow = {
|
||||||
|
lower = "00:01";
|
||||||
|
upper = "06:00";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Create an email notification service for failed jobs
|
||||||
|
systemd.services."notify-email@" =
|
||||||
|
let address = "system@${config.mail.server}";
|
||||||
|
in {
|
||||||
|
enable = config.mail.enable;
|
||||||
|
environment.SERVICE_ID = "%i";
|
||||||
|
script = ''
|
||||||
|
TEMPFILE=$(mktemp)
|
||||||
|
echo "From: ${address}" > $TEMPFILE
|
||||||
|
echo "To: ${address}" >> $TEMPFILE
|
||||||
|
echo "Subject: Failure in $SERVICE_ID" >> $TEMPFILE
|
||||||
|
echo -e "\nGot an error with $SERVICE_ID\n\n" >> $TEMPFILE
|
||||||
|
set +e
|
||||||
|
systemctl status $SERVICE_ID >> $TEMPFILE
|
||||||
|
set -e
|
||||||
|
${pkgs.msmtp}/bin/msmtp \
|
||||||
|
--file=${config.homePath}/.config/msmtp/config \
|
||||||
|
--account=system \
|
||||||
|
${address} < $TEMPFILE
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Send an email whenever auto upgrade fails
|
||||||
|
systemd.services.nixos-upgrade.onFailure =
|
||||||
|
lib.mkIf config.systemd.services."notify-email@".enable
|
||||||
|
[ "notify-email@%i.service" ];
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{ config, pkgs, lib, ... }: {
|
{ config, pkgs, lib, ... }: {
|
||||||
|
|
||||||
imports = [ ./doas.nix ./journald.nix ./user.nix ./timezone.nix ];
|
imports =
|
||||||
|
[ ./auto-upgrade.nix ./doas.nix ./journald.nix ./user.nix ./timezone.nix ];
|
||||||
|
|
||||||
config = lib.mkIf pkgs.stdenv.isLinux {
|
config = lib.mkIf pkgs.stdenv.isLinux {
|
||||||
|
|
||||||
@ -8,54 +9,6 @@
|
|||||||
system.stateVersion =
|
system.stateVersion =
|
||||||
config.home-manager.users.${config.user}.home.stateVersion;
|
config.home-manager.users.${config.user}.home.stateVersion;
|
||||||
|
|
||||||
# This setting only applies to NixOS, different on Darwin
|
|
||||||
nix.gc.dates = "weekly";
|
|
||||||
|
|
||||||
systemd.timers.nix-gc.timerConfig = { WakeSystem = true; };
|
|
||||||
systemd.services.nix-gc.postStop =
|
|
||||||
lib.mkIf (!config.server) "systemctl suspend";
|
|
||||||
|
|
||||||
# Update the system daily
|
|
||||||
system.autoUpgrade = {
|
|
||||||
enable = config.server; # Only auto upgrade servers
|
|
||||||
dates = "03:33";
|
|
||||||
flake = "git+${config.dotfilesRepo}";
|
|
||||||
randomizedDelaySec = "45min";
|
|
||||||
operation = "switch";
|
|
||||||
allowReboot = config.server; # Reboot servers
|
|
||||||
rebootWindow = {
|
|
||||||
lower = "00:01";
|
|
||||||
upper = "06:00";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Create an email notification service for failed jobs
|
|
||||||
systemd.services."notify-email@" =
|
|
||||||
let address = "system@${config.mail.server}";
|
|
||||||
in {
|
|
||||||
enable = config.mail.enable;
|
|
||||||
environment.SERVICE_ID = "%i";
|
|
||||||
script = ''
|
|
||||||
TEMPFILE=$(mktemp)
|
|
||||||
echo "From: ${address}" > $TEMPFILE
|
|
||||||
echo "To: ${address}" >> $TEMPFILE
|
|
||||||
echo "Subject: Failure in $SERVICE_ID" >> $TEMPFILE
|
|
||||||
echo -e "\nGot an error with $SERVICE_ID\n\n" >> $TEMPFILE
|
|
||||||
set +e
|
|
||||||
systemctl status $SERVICE_ID >> $TEMPFILE
|
|
||||||
set -e
|
|
||||||
${pkgs.msmtp}/bin/msmtp \
|
|
||||||
--file=${config.homePath}/.config/msmtp/config \
|
|
||||||
--account=system \
|
|
||||||
${address} < $TEMPFILE
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Send an email whenever auto upgrade fails
|
|
||||||
systemd.services.nixos-upgrade.onFailure =
|
|
||||||
lib.mkIf config.systemd.services."notify-email@".enable
|
|
||||||
[ "notify-email@%i.service" ];
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
doas = {
|
doas = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# No password required
|
# No password required for trusted users
|
||||||
wheelNeedsPassword = false;
|
wheelNeedsPassword = false;
|
||||||
|
|
||||||
# Pass environment variables from user to root
|
# Pass environment variables from user to root
|
||||||
# Also requires removing password here
|
# Also requires specifying that we are removing password here
|
||||||
extraRules = [{
|
extraRules = [{
|
||||||
groups = [ "wheel" ];
|
groups = [ "wheel" ];
|
||||||
noPass = true;
|
noPass = true;
|
||||||
@ -26,6 +26,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Alias sudo to doas for convenience
|
||||||
home-manager.users.${config.user}.programs.fish.shellAliases = {
|
home-manager.users.${config.user}.programs.fish.shellAliases = {
|
||||||
sudo = "doas";
|
sudo = "doas";
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ ... }: {
|
{ ... }: {
|
||||||
|
|
||||||
# How long to keep journalctl entries
|
# How long to keep journalctl entries
|
||||||
|
# This helps to make sure log disk usage doesn't grow too unwieldy
|
||||||
services.journald.extraConfig = ''
|
services.journald.extraConfig = ''
|
||||||
SystemMaxUse=100M
|
SystemMaxUse=100M
|
||||||
MaxFileSec=1month
|
MaxFileSec=1month
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ config, pkgs, lib, ... }: {
|
{ config, lib, ... }: {
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (pkgs.stdenv.isLinux) {
|
config = {
|
||||||
|
|
||||||
# Allows us to declaritively set password
|
# Allows us to declaritively set password
|
||||||
users.mutableUsers = false;
|
users.mutableUsers = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user