refactor: move modules to their own dir
This commit is contained in:
parent
dda72854df
commit
addf563bfc
26 changed files with 86 additions and 60 deletions
221
modules/hm/default.nix
Normal file
221
modules/hm/default.nix
Normal file
|
@ -0,0 +1,221 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
osConfig ? null,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jhome;
|
||||
devcfg = cfg.dev;
|
||||
# Query the osConfig for a setting. Return the default value if missing or in standalone mode
|
||||
fromOs =
|
||||
path: default: if osConfig == null then default else lib.attrsets.attrByPath path default osConfig;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./gui
|
||||
./users.nix
|
||||
];
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (cfg.enable && cfg.styling.enable) {
|
||||
stylix = {
|
||||
enable = true;
|
||||
targets.nixvim.enable = false; # I prefer doing it myself
|
||||
};
|
||||
})
|
||||
(lib.mkIf cfg.enable {
|
||||
# Add gopass if pass is enabled
|
||||
home.packages = lib.optional config.programs.password-store.enable pkgs.gopass;
|
||||
|
||||
nix.settings.use-xdg-base-directories = fromOs [
|
||||
"nix"
|
||||
"settings"
|
||||
"use-xdg-base-directories"
|
||||
] true;
|
||||
programs = {
|
||||
# Better cat (bat)
|
||||
bat = {
|
||||
enable = true;
|
||||
config = {
|
||||
# Disable headers and numbers
|
||||
style = "plain";
|
||||
theme = lib.mkForce "gruvbox-dark";
|
||||
};
|
||||
};
|
||||
# Direnv
|
||||
direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
};
|
||||
# ls replacement
|
||||
eza = {
|
||||
enable = true;
|
||||
git = true;
|
||||
icons = "auto";
|
||||
};
|
||||
# GnuPG
|
||||
gpg = {
|
||||
enable = true;
|
||||
homedir = "${config.xdg.dataHome}/gnupg";
|
||||
};
|
||||
# Mail client
|
||||
himalaya.enable = lib.mkDefault true;
|
||||
# Password manager
|
||||
password-store = {
|
||||
enable = lib.mkDefault true;
|
||||
package = pkgs.pass-nodmenu;
|
||||
settings.PASSWORD_STORE_DIR = "${config.xdg.dataHome}/pass";
|
||||
};
|
||||
# SSH
|
||||
ssh.enable = true;
|
||||
# cd replacement
|
||||
zoxide.enable = true;
|
||||
# Shell
|
||||
zsh = {
|
||||
enable = true;
|
||||
autosuggestion.enable = true;
|
||||
enableCompletion = true;
|
||||
autocd = true;
|
||||
dotDir = ".config/zsh";
|
||||
history.path = "${config.xdg.dataHome}/zsh/zsh_history";
|
||||
syntaxHighlighting.enable = true;
|
||||
};
|
||||
};
|
||||
services = {
|
||||
# GPG Agent
|
||||
gpg-agent = {
|
||||
enable = true;
|
||||
maxCacheTtl = 86400;
|
||||
pinentryPackage = if config.jhome.gui.enable then pkgs.pinentry-qt else pkgs.pinentry-curses;
|
||||
extraConfig = "allow-preset-passphrase";
|
||||
};
|
||||
# Spotifyd
|
||||
spotifyd = {
|
||||
inherit (config.jhome.gui) enable;
|
||||
settings.global = {
|
||||
device_name = config.jhome.hostName;
|
||||
device_type = "computer";
|
||||
backend = "pulseaudio";
|
||||
zeroconf_port = 2020;
|
||||
};
|
||||
};
|
||||
};
|
||||
home = {
|
||||
stateVersion = "22.11";
|
||||
# Extra packages
|
||||
# Extra variables
|
||||
sessionVariables = {
|
||||
CARGO_HOME = "${config.xdg.dataHome}/cargo";
|
||||
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
|
||||
GOPATH = "${config.xdg.dataHome}/go";
|
||||
};
|
||||
shellAliases = {
|
||||
# Verbose Commands
|
||||
cp = "cp --verbose";
|
||||
ln = "ln --verbose";
|
||||
mv = "mv --verbose";
|
||||
mkdir = "mkdir --verbose";
|
||||
rename = "rename --verbose";
|
||||
rm = "rm --verbose";
|
||||
# Add Color
|
||||
grep = "grep --color=auto";
|
||||
ip = "ip --color=auto";
|
||||
# Use exa/eza
|
||||
tree = "eza --tree";
|
||||
};
|
||||
};
|
||||
# XDG directories
|
||||
xdg = {
|
||||
enable = true;
|
||||
userDirs = {
|
||||
enable = true;
|
||||
createDirectories = true;
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.enable && devcfg.enable) {
|
||||
home = {
|
||||
sessionVariables.MANPAGER = lib.optionalString devcfg.neovimAsManPager "nvim -c 'Man!' -o -";
|
||||
packages = devcfg.extraPackages;
|
||||
};
|
||||
# Github CLI
|
||||
programs = {
|
||||
gh.enable = true;
|
||||
gh-dash.enable = true;
|
||||
# Git
|
||||
git = {
|
||||
enable = true;
|
||||
difftastic = {
|
||||
enable = true;
|
||||
background = "dark";
|
||||
};
|
||||
lfs.enable = true;
|
||||
extraConfig = {
|
||||
# Add diff to the commit message editor
|
||||
commit.verbose = true;
|
||||
# Improve submodule diff
|
||||
diff.submodule = "log";
|
||||
# Set the default branch name for new branches
|
||||
init.defaultBranch = "main";
|
||||
# Better conflicts (also shows parent commit state)
|
||||
merge.conflictStyle = "zdiff3";
|
||||
# Do not create merge commits when pulling (rebase but abort on conflict)
|
||||
pull.ff = "only";
|
||||
# Use `--set-upstream` if the remote does not have the branch
|
||||
push.autoSetupRemote = true;
|
||||
rebase = {
|
||||
# If there are uncommitted changes, stash them before rebasing
|
||||
autoStash = true;
|
||||
# If there are fixup! commits, squash them while rebasing
|
||||
autoSquash = true;
|
||||
};
|
||||
# Enable ReReRe (Reuse Recovered Resolution) auto resolve previously resolved conflicts
|
||||
rerere.enabled = true;
|
||||
# Improve submodule status
|
||||
status.submoduleSummary = true;
|
||||
};
|
||||
};
|
||||
lazygit.enable = true;
|
||||
# Jujutsu (alternative DVCS (git-compatible))
|
||||
jujutsu = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.jujutsu;
|
||||
settings = {
|
||||
ui.pager = "bat";
|
||||
# mimic git commit --verbose by adding a diff
|
||||
templates.draft_commit_description = ''
|
||||
concat(
|
||||
description,
|
||||
surround(
|
||||
"\nJJ: This commit contains the following changes:\n", "",
|
||||
indent("JJ: ", diff.stat(72)),
|
||||
),
|
||||
surround(
|
||||
"\nJJ: Diff:\n", "",
|
||||
indent("JJ: ", diff.git()),
|
||||
),
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.enable && devcfg.enable && devcfg.rust.enable) {
|
||||
home.packages = [ pkgs.rustup ] ++ devcfg.rust.extraPackages;
|
||||
# Background code checker (for Rust)
|
||||
programs.bacon = {
|
||||
enable = true;
|
||||
settings = {
|
||||
export = {
|
||||
enabled = true;
|
||||
path = ".bacon-locations";
|
||||
line_format = "{kind} {path}:{line}:{column} {message}";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
198
modules/hm/gui/default.nix
Normal file
198
modules/hm/gui/default.nix
Normal file
|
@ -0,0 +1,198 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
osConfig ? null,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (config) jhome;
|
||||
flatpakEnabled = if osConfig != null then osConfig.services.flatpak.enable else false;
|
||||
osSway = osConfig == null && !osConfig.programs.sway.enable;
|
||||
swayPkg = if osSway then pkgs.sway else null;
|
||||
cfg = jhome.gui;
|
||||
cursor = {
|
||||
package = pkgs.nordzy-cursor-theme;
|
||||
name = "Nordzy-cursors";
|
||||
};
|
||||
iconTheme = {
|
||||
name = "Papirus-Dark";
|
||||
package = pkgs.papirus-icon-theme;
|
||||
};
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (jhome.enable && cfg.enable) {
|
||||
home.packages =
|
||||
(with pkgs; [
|
||||
webcord
|
||||
ferdium
|
||||
xournalpp
|
||||
signal-desktop
|
||||
pcmanfm
|
||||
wl-clipboard
|
||||
# Extra fonts
|
||||
noto-fonts-cjk-sans # Chinese, Japanese and Korean characters
|
||||
noto-fonts-cjk-serif # Chinese, Japanese and Korean characters
|
||||
(nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
|
||||
])
|
||||
++ lib.optional flatpakEnabled pkgs.flatpak;
|
||||
fonts.fontconfig = {
|
||||
enable = true;
|
||||
defaultFonts = lib.mkIf config.jhome.styling.enable {
|
||||
emoji = [ "Noto Color Emoji" ];
|
||||
monospace = [
|
||||
"JetBrains Mono"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
serif = [
|
||||
"Noto Serif"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
sansSerif = [
|
||||
"Noto Sans"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
};
|
||||
};
|
||||
# Browser
|
||||
programs = {
|
||||
firefox.enable = true;
|
||||
# Dynamic Menu
|
||||
fuzzel = {
|
||||
enable = true;
|
||||
settings.main = lib.mkIf config.jhome.styling.enable {
|
||||
icon-theme = "Papirus-Dark";
|
||||
inherit (cfg) terminal;
|
||||
layer = "overlay";
|
||||
};
|
||||
};
|
||||
# Video player
|
||||
mpv = {
|
||||
enable = true;
|
||||
scripts = builtins.attrValues { inherit (pkgs.mpvScripts) uosc thumbfast; };
|
||||
};
|
||||
# Text editor
|
||||
nixvim.clipboard.providers.wl-copy.enable = lib.mkDefault true;
|
||||
# Status bar
|
||||
waybar = {
|
||||
enable = true;
|
||||
systemd.enable = true;
|
||||
settings = lib.mkIf config.jhome.styling.enable (
|
||||
import ./waybar-settings.nix { inherit config lib; }
|
||||
);
|
||||
style =
|
||||
lib.optionalString config.jhome.styling.enable # css
|
||||
''
|
||||
.modules-left #workspaces button {
|
||||
border-bottom: 3px solid @base01;
|
||||
}
|
||||
.modules-left #workspaces button.persistent {
|
||||
border-bottom: 3px solid transparent;
|
||||
}
|
||||
'';
|
||||
};
|
||||
# Terminal
|
||||
wezterm = {
|
||||
enable = cfg.terminal == "wezterm";
|
||||
extraConfig =
|
||||
lib.optionalString config.jhome.styling.enable # lua
|
||||
''
|
||||
local wezterm = require("wezterm")
|
||||
|
||||
local config = wezterm.config_builder()
|
||||
|
||||
config.front_end = "WebGpu"
|
||||
config.hide_tab_bar_if_only_one_tab = true
|
||||
config.window_padding = { left = 1, right = 1, top = 1, bottom = 1 }
|
||||
|
||||
return config
|
||||
'';
|
||||
};
|
||||
alacritty = {
|
||||
enable = cfg.terminal == "alacritty";
|
||||
settings = {
|
||||
# hide mouse when typing, this ensures I don't have to move the mouse when it hides text
|
||||
mouse.hide_when_typing = true;
|
||||
# Start zellij when it is enabled
|
||||
terminal.shell = lib.mkIf (config.jhome.dev.enable && config.programs.zellij.enable) {
|
||||
program = "${lib.getExe config.programs.zellij.package}";
|
||||
};
|
||||
};
|
||||
};
|
||||
zellij.enable = cfg.terminal == "alacritty"; # alacritty has no terminal multiplexer built-in
|
||||
# PDF reader
|
||||
zathura.enable = true;
|
||||
# Auto start sway
|
||||
zsh.loginExtra =
|
||||
lib.optionalString cfg.sway.autostart # sh
|
||||
''
|
||||
# Start Sway on login to TTY 1
|
||||
if [ "$TTY" = /dev/tty1 ]; then
|
||||
exec sway
|
||||
fi
|
||||
'';
|
||||
};
|
||||
services = {
|
||||
# Volume/Backlight control and notifications
|
||||
avizo = {
|
||||
enable = true;
|
||||
settings.default = {
|
||||
time = 0.8;
|
||||
border-width = 0;
|
||||
height = 176;
|
||||
y-offset = 0.1;
|
||||
block-spacing = 1;
|
||||
};
|
||||
};
|
||||
# Sound tuning
|
||||
easyeffects.enable = true;
|
||||
# Auto configure displays
|
||||
kanshi.enable = lib.mkDefault true;
|
||||
# Notifications
|
||||
mako = {
|
||||
enable = true;
|
||||
layer = "overlay";
|
||||
borderRadius = 8;
|
||||
defaultTimeout = 15000;
|
||||
};
|
||||
};
|
||||
|
||||
# Window Manager
|
||||
wayland.windowManager.sway = {
|
||||
inherit (cfg.sway) enable;
|
||||
package = swayPkg; # no sway package if it comes from the OS
|
||||
config = import ./sway-config.nix { inherit config pkgs; };
|
||||
systemd = {
|
||||
enable = true;
|
||||
xdgAutostart = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Set cursor style
|
||||
stylix = lib.mkIf config.jhome.styling.enable { inherit cursor; };
|
||||
home.pointerCursor = lib.mkIf config.jhome.styling.enable (
|
||||
lib.mkDefault {
|
||||
gtk.enable = true;
|
||||
inherit (cursor) name package;
|
||||
}
|
||||
);
|
||||
# Set Gtk theme
|
||||
gtk = lib.mkIf config.jhome.styling.enable {
|
||||
enable = true;
|
||||
inherit iconTheme;
|
||||
gtk3.extraConfig.gtk-application-prefer-dark-theme = 1;
|
||||
gtk4.extraConfig.gtk-application-prefer-dark-theme = 1;
|
||||
};
|
||||
# Set Qt theme
|
||||
qt = lib.mkIf config.jhome.styling.enable {
|
||||
enable = true;
|
||||
platformTheme.name = "gtk";
|
||||
};
|
||||
|
||||
xdg.systemDirs.data = [
|
||||
"/usr/share"
|
||||
"/var/lib/flatpak/exports/share"
|
||||
"${config.xdg.dataHome}/flatpak/exports/share"
|
||||
];
|
||||
};
|
||||
}
|
118
modules/hm/gui/keybindings.nix
Normal file
118
modules/hm/gui/keybindings.nix
Normal file
|
@ -0,0 +1,118 @@
|
|||
{ pkgs, config }:
|
||||
let
|
||||
cfg = config.jhome.gui.sway;
|
||||
passmenu = "${pkgs.jpassmenu}/bin/jpassmenu";
|
||||
selectAudio = "${pkgs.audiomenu}/bin/audiomenu";
|
||||
swayconf = config.wayland.windowManager.sway.config;
|
||||
mod = swayconf.modifier;
|
||||
workspaces = map toString [
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
];
|
||||
dirs =
|
||||
map
|
||||
(dir: {
|
||||
key = swayconf.${dir};
|
||||
arrow = dir;
|
||||
direction = dir;
|
||||
})
|
||||
[
|
||||
"up"
|
||||
"down"
|
||||
"left"
|
||||
"right"
|
||||
];
|
||||
joinKeys = builtins.concatStringsSep "+";
|
||||
# Generate a keybind from a modifier prefix and a key
|
||||
keycombo = prefix: key: joinKeys (prefix ++ [ key ]);
|
||||
modKeybind = keycombo [ mod ];
|
||||
modCtrlKeybind = keycombo [
|
||||
mod
|
||||
"Ctrl"
|
||||
];
|
||||
modShiftKeybind = keycombo [
|
||||
mod
|
||||
"Shift"
|
||||
];
|
||||
modCtrlShiftKeybind = keycombo [
|
||||
mod
|
||||
"Ctrl"
|
||||
"Shift"
|
||||
];
|
||||
dir2resize.up = "resize grow height";
|
||||
dir2resize.down = "resize shrink height";
|
||||
dir2resize.right = "resize grow width";
|
||||
dir2resize.left = "resize shrink width";
|
||||
# Bind a key combo to an action
|
||||
genKeybind = prefix: action: key: { "${prefix key}" = "${action key}"; };
|
||||
genKey =
|
||||
prefix: action: genKeybind ({ key, ... }: prefix key) ({ direction, ... }: action direction);
|
||||
genArrow =
|
||||
prefix: action: genKeybind ({ arrow, ... }: prefix arrow) ({ direction, ... }: action direction);
|
||||
genArrowAndKey =
|
||||
prefix: action: key:
|
||||
(genKey prefix action key) // (genArrow prefix action key);
|
||||
# Move window
|
||||
moveWindowKeybinds = map (genArrowAndKey modShiftKeybind (dir: "move ${dir}")) dirs;
|
||||
# Focus window
|
||||
focusWindowKeybinds = map (genArrowAndKey modKeybind (dir: "focus ${dir}")) dirs;
|
||||
# Resize window
|
||||
resizeWindowKeybinds = map (genArrowAndKey modCtrlKeybind (dir: dir2resize.${dir})) dirs;
|
||||
# Move container to workspace
|
||||
moveWorkspaceKeybindings = map (genKeybind modShiftKeybind (
|
||||
number: "move container to workspace number ${number}"
|
||||
)) workspaces;
|
||||
# Focus workspace
|
||||
focusWorkspaceKeybindings = map (genKeybind modKeybind (
|
||||
number: "workspace number ${number}"
|
||||
)) workspaces;
|
||||
# Move container to Workspace and focus on it
|
||||
moveFocusWorkspaceKeybindings = map (genKeybind modCtrlShiftKeybind (
|
||||
number: "move container to workspace number ${number}; workspace number ${number}"
|
||||
)) workspaces;
|
||||
in
|
||||
builtins.foldl' (l: r: l // r)
|
||||
{
|
||||
"${mod}+Return" = "exec ${swayconf.terminal}";
|
||||
"${mod}+D" = "exec ${swayconf.menu}";
|
||||
"${mod}+P" = "exec ${passmenu}";
|
||||
"${mod}+Shift+P" = "exec ${passmenu} --type";
|
||||
"${mod}+F2" = "exec qutebrowser";
|
||||
"${mod}+Shift+Q" = "kill";
|
||||
"${mod}+F" = "fullscreen toggle";
|
||||
# Media Controls
|
||||
"${mod}+F10" = "exec ${selectAudio} select-sink";
|
||||
"${mod}+Shift+F10" = "exec ${selectAudio} select-source";
|
||||
"XF86AudioRaiseVolume" = "exec ${pkgs.avizo}/bin/volumectl up";
|
||||
"XF86AudioLowerVolume" = "exec ${pkgs.avizo}/bin/volumectl down";
|
||||
"XF86AudioMute" = "exec ${pkgs.avizo}/bin/volumectl toggle-mute";
|
||||
"XF86ScreenSaver" = "exec swaylock --image ${cfg.background}";
|
||||
"XF86MonBrightnessUp" = "exec ${pkgs.avizo}/bin/lightctl up";
|
||||
"XF86MonBrightnessDown" = "exec ${pkgs.avizo}/bin/lightctl down";
|
||||
# Floating
|
||||
"${mod}+Space" = "floating toggle";
|
||||
"${mod}+Shift+Space" = "focus mode_toggle";
|
||||
# Scratchpad
|
||||
"${mod}+Minus" = "scratchpad show";
|
||||
"${mod}+Shift+Minus" = "move scratchpad";
|
||||
# Layout
|
||||
"${mod}+e" = "layout toggle split";
|
||||
# Session control
|
||||
"${mod}+r" = "reload";
|
||||
"${mod}+Shift+m" = "exit";
|
||||
}
|
||||
(
|
||||
focusWindowKeybinds
|
||||
++ moveWindowKeybinds
|
||||
++ resizeWindowKeybinds
|
||||
++ focusWorkspaceKeybindings
|
||||
++ moveWorkspaceKeybindings
|
||||
++ moveFocusWorkspaceKeybindings
|
||||
)
|
101
modules/hm/gui/sway-config.nix
Normal file
101
modules/hm/gui/sway-config.nix
Normal file
|
@ -0,0 +1,101 @@
|
|||
{ config, pkgs }:
|
||||
let
|
||||
cfg = config.jhome.gui.sway;
|
||||
modifier = "Mod4";
|
||||
inherit (config.jhome.gui) terminal;
|
||||
termCmd =
|
||||
if terminal == "wezterm" then
|
||||
"wezterm start"
|
||||
else if terminal == "alacritty" then
|
||||
"alacritty -e"
|
||||
else
|
||||
builtins.abort "no command configured for ${terminal}";
|
||||
menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'";
|
||||
# currently, there is some friction between sway and gtk:
|
||||
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
|
||||
# the suggested way to set gtk settings is with gsettings
|
||||
# for gsettings to work, we need to tell it where the schemas are
|
||||
# using the XDG_DATA_DIR environment variable
|
||||
# run at the end of sway config
|
||||
configure-gtk =
|
||||
let
|
||||
schema = pkgs.gsettings-desktop-schemas;
|
||||
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
|
||||
in
|
||||
pkgs.writers.writeDashBin "configure-gtk" ''
|
||||
export XDG_DATA_DIRS="${datadir}:$XDG_DATA_DIRS"
|
||||
|
||||
gnome_schema=org.gnome.desktop.interface
|
||||
config="${config.xdg.configHome}/gtk-3.0/settings.ini"
|
||||
if [ ! -f "$config" ]; then exit 1; fi
|
||||
# Read settings from gtk3
|
||||
gtk_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
|
||||
icon_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-icon-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
|
||||
cursor_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-cursor-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
|
||||
font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')"
|
||||
${pkgs.glib}/bin/gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
|
||||
${pkgs.glib}/bin/gsettings set "$gnome_schema" icon-theme "$icon_theme"
|
||||
${pkgs.glib}/bin/gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
|
||||
${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name"
|
||||
${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark
|
||||
'';
|
||||
cmdOnce = command: { inherit command; };
|
||||
cmdAlways = command: {
|
||||
inherit command;
|
||||
always = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit modifier terminal menu;
|
||||
keybindings = import ./keybindings.nix { inherit config pkgs; };
|
||||
# Appearance
|
||||
bars = [ ]; # Waybar is started as a systemd service
|
||||
gaps = {
|
||||
smartGaps = true;
|
||||
smartBorders = "on";
|
||||
inner = 4;
|
||||
};
|
||||
output."*".bg = "${cfg.background} fill";
|
||||
# Window Appearance
|
||||
window = {
|
||||
border = 2;
|
||||
titlebar = false;
|
||||
# Make certain windows floating
|
||||
commands = [
|
||||
{
|
||||
command = "floating enable";
|
||||
criteria.title = "zoom";
|
||||
}
|
||||
{
|
||||
command = "floating enable";
|
||||
criteria.class = "floating";
|
||||
}
|
||||
{
|
||||
command = "floating enable";
|
||||
criteria.app_id = "floating";
|
||||
}
|
||||
];
|
||||
};
|
||||
# Startup scripts
|
||||
startup =
|
||||
[
|
||||
(cmdAlways "${configure-gtk}/bin/configure-gtk")
|
||||
]
|
||||
++ (builtins.map cmdAlways cfg.exec.always)
|
||||
++ (builtins.map cmdOnce cfg.exec.once);
|
||||
# Keyboard configuration
|
||||
input."type:keyboard" = {
|
||||
repeat_delay = "300";
|
||||
repeat_rate = "50";
|
||||
xkb_options = "caps:swapescape,compose:ralt";
|
||||
xkb_numlock = "enabled";
|
||||
};
|
||||
# Touchpad
|
||||
input."type:touchpad" = {
|
||||
click_method = "clickfinger";
|
||||
natural_scroll = "enabled";
|
||||
scroll_method = "two_finger";
|
||||
tap = "enabled";
|
||||
tap_button_map = "lrm";
|
||||
};
|
||||
}
|
127
modules/hm/gui/waybar-settings.nix
Normal file
127
modules/hm/gui/waybar-settings.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{ config, lib }:
|
||||
let
|
||||
cfg = config.jhome.gui;
|
||||
in
|
||||
{
|
||||
mainBar = {
|
||||
layer = "top";
|
||||
position = "top";
|
||||
margin = "2 2 2 2";
|
||||
# Choose the order of the modules
|
||||
modules-left = [ "sway/workspaces" ];
|
||||
modules-center = [ "clock" ];
|
||||
modules-right =
|
||||
[
|
||||
"pulseaudio"
|
||||
"backlight"
|
||||
"battery"
|
||||
"sway/language"
|
||||
"memory"
|
||||
]
|
||||
++ lib.optional (cfg.tempInfo != null) "temperature"
|
||||
++ [ "tray" ];
|
||||
"sway/workspaces" = {
|
||||
disable-scroll = true;
|
||||
persistent-workspaces = {
|
||||
"1" = [ ];
|
||||
"2" = [ ];
|
||||
"3" = [ ];
|
||||
"4" = [ ];
|
||||
"5" = [ ];
|
||||
"6" = [ ];
|
||||
"7" = [ ];
|
||||
"8" = [ ];
|
||||
"9" = [ ];
|
||||
};
|
||||
};
|
||||
"sway/language" = {
|
||||
format = "{} ";
|
||||
min-length = 5;
|
||||
tooltip = false;
|
||||
};
|
||||
memory = {
|
||||
format = "{used:0.1f}/{total:0.1f}GiB ";
|
||||
interval = 3;
|
||||
};
|
||||
clock = {
|
||||
timezone = "Europe/Berlin";
|
||||
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
|
||||
format = "{:%a, %d %b, %H:%M}";
|
||||
};
|
||||
pulseaudio = {
|
||||
reverse-scrolling = 1;
|
||||
format = "{volume}% {icon} {format_source}";
|
||||
format-bluetooth = "{volume}% {icon} {format_source}";
|
||||
format-bluetooth-muted = "{volume}% {icon} {format_source}";
|
||||
format-muted = "{volume}% {format_source}";
|
||||
format-source = "{volume}% ";
|
||||
format-source-muted = "{volume}% ";
|
||||
format-icons = {
|
||||
headphone = "";
|
||||
hands-free = "";
|
||||
headset = "";
|
||||
phone = "";
|
||||
portable = "";
|
||||
car = "";
|
||||
default = [
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
};
|
||||
on-click = "pavucontrol";
|
||||
min-length = 13;
|
||||
};
|
||||
temperature = lib.optionalAttrs (cfg.tempInfo != null) {
|
||||
inherit (cfg.tempInfo) hwmon-path;
|
||||
critical-threshold = 80;
|
||||
format = "{temperatureC}°C {icon}";
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
tooltip = false;
|
||||
};
|
||||
backlight = {
|
||||
device = "intel_backlight";
|
||||
format = "{percent}% {icon}";
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
min-length = 7;
|
||||
};
|
||||
battery = {
|
||||
states.warning = 30;
|
||||
states.critical = 15;
|
||||
format = "{capacity}% {icon}";
|
||||
format-charging = "{capacity}% ";
|
||||
format-plugged = "{capacity}% ";
|
||||
format-alt = "{time} {icon}";
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
};
|
||||
tray = {
|
||||
icon-size = 16;
|
||||
spacing = 0;
|
||||
};
|
||||
};
|
||||
}
|
249
modules/hm/options.nix
Normal file
249
modules/hm/options.nix
Normal file
|
@ -0,0 +1,249 @@
|
|||
{ lib, pkgs, ... }@attrs:
|
||||
let
|
||||
osConfig = attrs.osConfig or null;
|
||||
inherit (lib) types;
|
||||
fromOs =
|
||||
let
|
||||
get =
|
||||
path: set:
|
||||
if path == [ ] then set else get (builtins.tail path) (builtins.getAttr (builtins.head path) set);
|
||||
in
|
||||
path: default: if osConfig == null then default else get path osConfig;
|
||||
fromConfig = path: default: fromOs ([ "jconfig" ] ++ path) default;
|
||||
|
||||
mkExtraPackagesOption =
|
||||
name: defaultPkgsPath:
|
||||
let
|
||||
text = lib.strings.concatMapStringsSep " " (
|
||||
pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath)
|
||||
) defaultPkgsPath;
|
||||
defaultText = lib.literalExpression "[ ${text} ]";
|
||||
default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath;
|
||||
in
|
||||
lib.mkOption {
|
||||
description = "Extra ${name} Packages.";
|
||||
type = types.listOf types.package;
|
||||
inherit default defaultText;
|
||||
example = [ ];
|
||||
};
|
||||
|
||||
identity.options = {
|
||||
email = lib.mkOption {
|
||||
description = "Primary email address";
|
||||
type = types.str;
|
||||
example = "email@example.org";
|
||||
};
|
||||
name = lib.mkOption {
|
||||
description = "The default name you use.";
|
||||
type = types.str;
|
||||
example = "John Doe";
|
||||
};
|
||||
signingKey = lib.mkOption {
|
||||
description = "The signing key programs should use (i.e. git).";
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "F016B9E770737A0B";
|
||||
};
|
||||
encryptionKey = lib.mkOption {
|
||||
description = "The encryption key programs should use (i.e. pass).";
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "F016B9E770737A0B";
|
||||
};
|
||||
};
|
||||
|
||||
user.options = {
|
||||
enable = lib.mkEnableOption "Jalil's default user configuration";
|
||||
gpg = lib.mkOption {
|
||||
description = "GnuPG Configuration.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.unlockKeys = lib.mkOption {
|
||||
description = "Keygrips of keys to unlock through `pam-gnupg` when logging in.";
|
||||
default = [ ];
|
||||
example = [ "6F4ABB77A88E922406BCE6627AFEEE2363914B76" ];
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
defaultIdentity = lib.mkOption {
|
||||
description = "The default identity to use in things like git.";
|
||||
type = types.submodule identity;
|
||||
};
|
||||
};
|
||||
|
||||
tempInfo.options.hwmon-path = lib.mkOption {
|
||||
description = "Path to the hardware sensor whose temperature to monitor.";
|
||||
type = types.str;
|
||||
example = "/sys/class/hwmon/hwmon2/temp1_input";
|
||||
};
|
||||
|
||||
sway.options = {
|
||||
enable = lib.mkEnableOption "sway" // {
|
||||
default = fromConfig [
|
||||
"gui"
|
||||
"sway"
|
||||
] true;
|
||||
};
|
||||
background = lib.mkOption {
|
||||
description = "The wallpaper to use.";
|
||||
type = types.path;
|
||||
default =
|
||||
fromConfig
|
||||
[
|
||||
"styling"
|
||||
"wallpaper"
|
||||
]
|
||||
(
|
||||
builtins.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
|
||||
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
|
||||
}
|
||||
);
|
||||
};
|
||||
autostart = lib.mkOption {
|
||||
description = ''
|
||||
Autostart Sway when logging in to /dev/tty1.
|
||||
|
||||
This will make it so `exec sway` is run when logging in to TTY1, if
|
||||
you want a non-graphical session (ie. your GPU drivers are broken)
|
||||
you can switch TTYs when logging in by using CTRL+ALT+F2 (for TTY2,
|
||||
F3 for TTY3, etc).
|
||||
'';
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
exec = lib.mkOption {
|
||||
description = "Run commands when starting sway.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options = {
|
||||
once = lib.mkOption {
|
||||
description = "Programs to start only once (`exec`).";
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [ "signal-desktop --start-in-tray" ];
|
||||
};
|
||||
always = lib.mkOption {
|
||||
description = "Programs to start whenever the config is sourced (`exec_always`).";
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [ "signal-desktop --start-in-tray" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gui.options = {
|
||||
enable = lib.mkEnableOption "GUI applications" // {
|
||||
default = fromConfig [
|
||||
"gui"
|
||||
"enable"
|
||||
] false;
|
||||
};
|
||||
tempInfo = lib.mkOption {
|
||||
description = "Temperature info to display in the statusbar.";
|
||||
default = null;
|
||||
type = types.nullOr (types.submodule tempInfo);
|
||||
};
|
||||
sway = lib.mkOption {
|
||||
description = "Sway window manager configuration.";
|
||||
default = { };
|
||||
type = types.submodule sway;
|
||||
};
|
||||
terminal = lib.mkOption {
|
||||
description = "The terminal emulator to use.";
|
||||
default = "alacritty";
|
||||
example = "wezterm";
|
||||
type = types.enum [
|
||||
"wezterm"
|
||||
"alacritty"
|
||||
];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.jhome = lib.mkOption {
|
||||
description = "Jalil's default home-manager configuration.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "jalil's home defaults";
|
||||
hostName = lib.mkOption {
|
||||
description = "The hostname of this system.";
|
||||
type = types.str;
|
||||
default = fromOs [
|
||||
"networking"
|
||||
"hostName"
|
||||
] "nixos";
|
||||
example = "my pc";
|
||||
};
|
||||
dev = lib.mkOption {
|
||||
description = "Setup development environment for programming languages.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "development settings" // {
|
||||
default = fromConfig [
|
||||
"dev"
|
||||
"enable"
|
||||
] false;
|
||||
};
|
||||
neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
|
||||
extraPackages = mkExtraPackagesOption "dev" [
|
||||
# FIXME: readd on new lix version with fix [ "devenv" ] # a devshell alternative
|
||||
[ "jq" ] # json parser
|
||||
[ "just" ] # just a command runner
|
||||
[ "typos" ] # low false positive rate typo checker
|
||||
[ "gcc" ] # GNU Compiler Collection
|
||||
[ "git-absorb" ] # fixup! but automatic
|
||||
[ "gitoxide" ] # git but RiiR
|
||||
[ "man-pages" ] # gimme the man pages
|
||||
[ "man-pages-posix" ] # I said gimme the man pages!!!
|
||||
];
|
||||
rust = lib.mkOption {
|
||||
description = "Jalil's default rust configuration.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.enable = lib.mkEnableOption "rust development settings";
|
||||
options.extraPackages = mkExtraPackagesOption "Rust" [
|
||||
[ "cargo-insta" ] # snapshot testing
|
||||
[ "cargo-nextest" ] # better testing harness
|
||||
[ "cargo-udeps" ] # check for unused dependencies (requires nightly)
|
||||
[ "cargo-watch" ] # watch for file changes and run commands
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
user = lib.mkOption {
|
||||
description = "User settings.";
|
||||
default = null;
|
||||
type = types.nullOr (types.submodule user);
|
||||
};
|
||||
gui = lib.mkOption {
|
||||
description = "Jalil's default GUI configuration.";
|
||||
default = { };
|
||||
type = types.submodule gui;
|
||||
};
|
||||
styling = lib.mkOption {
|
||||
description = "My custom styling (uses stylix)";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "styling" // {
|
||||
default = fromConfig [
|
||||
"styling"
|
||||
"enable"
|
||||
] true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
41
modules/hm/users.nix
Normal file
41
modules/hm/users.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (config) jhome;
|
||||
inherit (cfg.defaultIdentity) signingKey;
|
||||
|
||||
cfg = jhome.user;
|
||||
hasConfig = jhome.enable && cfg != null;
|
||||
hasKey = signingKey != null;
|
||||
gpgHome = config.programs.gpg.homedir;
|
||||
unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
|
||||
in
|
||||
{
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf hasConfig {
|
||||
programs.git = {
|
||||
userName = cfg.defaultIdentity.name;
|
||||
userEmail = cfg.defaultIdentity.email;
|
||||
signing = lib.mkIf hasKey {
|
||||
signByDefault = true;
|
||||
key = signingKey;
|
||||
};
|
||||
};
|
||||
programs.jujutsu.settings = {
|
||||
user = lib.mkIf (cfg.defaultIdentity != null) { inherit (cfg.defaultIdentity) name email; };
|
||||
signing = lib.mkIf hasKey {
|
||||
sign-all = true;
|
||||
backend = "gpg";
|
||||
key = signingKey;
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf unlockKey {
|
||||
xdg.configFile.pam-gnupg.text =
|
||||
''
|
||||
${gpgHome}
|
||||
|
||||
''
|
||||
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
|
||||
})
|
||||
];
|
||||
}
|
127
modules/nixos/default.nix
Normal file
127
modules/nixos/default.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jconfig;
|
||||
keysFromGithub = lib.attrsets.mapAttrs' (username: sha256: {
|
||||
name = "pubkeys/${username}";
|
||||
value = {
|
||||
mode = "0755";
|
||||
source = builtins.fetchurl {
|
||||
inherit sha256;
|
||||
url = "https://github.com/${username}.keys";
|
||||
};
|
||||
};
|
||||
}) cfg.importSSHKeysFromGithub;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./gui
|
||||
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; }
|
||||
];
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
boot.plymouth = {
|
||||
inherit (cfg.styling) enable;
|
||||
};
|
||||
|
||||
# Enable unlocking the gpg-agent at boot (configured through home.nix)
|
||||
security.pam.services.login.gnupg.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
# CLI tools
|
||||
pkgs.fd
|
||||
pkgs.ripgrep
|
||||
pkgs.du-dust
|
||||
pkgs.curl
|
||||
pkgs.zip
|
||||
pkgs.unzip
|
||||
];
|
||||
|
||||
# Enable dev documentation
|
||||
documentation.dev = {
|
||||
inherit (cfg.dev) enable;
|
||||
};
|
||||
programs = {
|
||||
# Shell prompt
|
||||
starship = {
|
||||
enable = true;
|
||||
settings = lib.mkMerge [
|
||||
{
|
||||
format = "$time$all";
|
||||
add_newline = false;
|
||||
cmd_duration.min_time = 500;
|
||||
cmd_duration.show_milliseconds = true;
|
||||
time.disabled = false;
|
||||
status = {
|
||||
format = "[$signal_name$common_meaning$maybe_int](red)";
|
||||
symbol = "[✗](bold red)";
|
||||
disabled = false;
|
||||
};
|
||||
sudo.disabled = false;
|
||||
}
|
||||
# Add nerdfont symbols
|
||||
(lib.mkIf cfg.styling.enable (import ./starship-nerdfont-symbols.nix))
|
||||
# Remove the `in`s and `on`s from the prompt
|
||||
(lib.mkIf cfg.styling.enable (import ./starship-shorter-text.nix))
|
||||
];
|
||||
};
|
||||
# Default shell
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
environment.etc = keysFromGithub;
|
||||
services = {
|
||||
# Enable printer autodiscovery if printing is enabled
|
||||
avahi = {
|
||||
inherit (config.services.printing) enable;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") (
|
||||
builtins.attrNames keysFromGithub
|
||||
);
|
||||
};
|
||||
users.defaultUserShell = pkgs.zsh;
|
||||
# Open ports for spotifyd
|
||||
networking.firewall = {
|
||||
allowedUDPPorts = [ 5353 ];
|
||||
allowedTCPPorts = [ 2020 ];
|
||||
};
|
||||
# Nix Settings
|
||||
nix = {
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 30d";
|
||||
# run between 0 and 45min after boot if run was missed
|
||||
randomizedDelaySec = "45min";
|
||||
};
|
||||
settings = {
|
||||
use-xdg-base-directories = true;
|
||||
auto-optimise-store = true;
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
# dev configuration
|
||||
(lib.mkIf cfg.dev.enable {
|
||||
users.extraUsers = lib.mkIf cfg.dev.jupyter.enable { jupyter.group = "jupyter"; };
|
||||
services.jupyter = {
|
||||
inherit (cfg.dev.jupyter) enable;
|
||||
group = "jupyter";
|
||||
user = "jupyter";
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
118
modules/nixos/gui/default.nix
Normal file
118
modules/nixos/gui/default.nix
Normal file
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jconfig.gui;
|
||||
enable = config.jconfig.enable && cfg.enable;
|
||||
linuxOlderThan6_3 = lib.versionOlder config.boot.kernelPackages.kernel.version "6.3";
|
||||
in
|
||||
{
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf enable {
|
||||
environment.systemPackages = [
|
||||
pkgs.adwaita-icon-theme
|
||||
pkgs.adwaita-qt
|
||||
pkgs.nordzy-cursor-theme
|
||||
pkgs.pinentry-qt
|
||||
] ++ lib.optional cfg.ydotool.enable pkgs.ydotool;
|
||||
systemd = {
|
||||
user.services.ydotool = lib.mkIf cfg.ydotool.enable {
|
||||
enable = cfg.ydotool.autoStart;
|
||||
wantedBy = [ "default.target" ];
|
||||
description = "Generic command-line automation tool";
|
||||
documentation = [
|
||||
"man:ydotool(1)"
|
||||
"man:ydotoold(8)"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
ExecStart = "${pkgs.ydotool}/bin/ydotoold";
|
||||
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
|
||||
KillMode = "process";
|
||||
TimeoutSec = 180;
|
||||
};
|
||||
};
|
||||
# Fix xdg-portals issue issue: https://github.com/NixOS/nixpkgs/issues/189851
|
||||
user.extraConfig = ''
|
||||
DefaultEnvironment="PATH=/run/wrappers/bin:/etc/profiles/per-user/%u/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
|
||||
'';
|
||||
};
|
||||
|
||||
fonts.fontDir.enable = true;
|
||||
programs = {
|
||||
dconf.enable = true;
|
||||
sway = {
|
||||
enable = cfg.sway;
|
||||
# No extra packages (by default it adds foot, dmenu, and other stuff)
|
||||
extraPackages = [ ];
|
||||
wrapperFeatures = {
|
||||
base = true;
|
||||
gtk = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
security = {
|
||||
polkit.enable = true;
|
||||
rtkit.enable = true; # Recommended for pipewire
|
||||
};
|
||||
services = {
|
||||
flatpak.enable = true;
|
||||
# Audio
|
||||
pipewire = {
|
||||
enable = true;
|
||||
alsa = {
|
||||
enable = true;
|
||||
support32Bit = true;
|
||||
};
|
||||
pulse.enable = true;
|
||||
wireplumber.enable = true;
|
||||
};
|
||||
# Dbus
|
||||
dbus.enable = true;
|
||||
# Virtual Filesystem (for PCManFM)
|
||||
gvfs.enable = true;
|
||||
};
|
||||
xdg.portal = {
|
||||
# XDG portals
|
||||
enable = true;
|
||||
wlr.enable = true;
|
||||
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
|
||||
config.preferred = {
|
||||
# Default to the gtk portal
|
||||
default = "gtk";
|
||||
# Use wlr for screenshots and screen recording
|
||||
"org.freedesktop.impl.portal.Screenshot" = "wlr";
|
||||
};
|
||||
# Consider using darkman like upstream
|
||||
};
|
||||
hardware = {
|
||||
graphics.enable = true;
|
||||
uinput.enable = true;
|
||||
steam-hardware.enable = cfg.steamHardwareSupport;
|
||||
};
|
||||
})
|
||||
(lib.mkIf (enable && linuxOlderThan6_3 && cfg."8bitdoFix") {
|
||||
# Udev rules to start or stop systemd service when controller is connected or disconnected
|
||||
services.udev.extraRules = # udev
|
||||
''
|
||||
# May vary depending on your controller model, find product id using 'lsusb'
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3106", ATTR{manufacturer}=="8BitDo", RUN+="${pkgs.systemd}/bin/systemctl start 8bitdo-ultimate-xinput@2dc8:3106"
|
||||
# This device (2dc8:3016) is "connected" when the above device disconnects
|
||||
SUBSYSTEM=="usb", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3016", ATTR{manufacturer}=="8BitDo", RUN+="${pkgs.systemd}/bin/systemctl stop 8bitdo-ultimate-xinput@2dc8:3106"
|
||||
'';
|
||||
|
||||
# Systemd service which starts xboxdrv in xbox360 mode
|
||||
systemd.services."8bitdo-ultimate-xinput@" = {
|
||||
unitConfig.Description = "8BitDo Ultimate Controller XInput mode xboxdrv daemon";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.xboxdrv}/bin/xboxdrv --mimic-xpad --silent --type xbox360 --device-by-id %I --force-feedback";
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
106
modules/nixos/options.nix
Normal file
106
modules/nixos/options.nix
Normal file
|
@ -0,0 +1,106 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
# Like mkEnableOption but defaults to true
|
||||
mkDisableOption =
|
||||
option:
|
||||
(lib.mkEnableOption option)
|
||||
// {
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
mkImageOption =
|
||||
{
|
||||
description,
|
||||
url,
|
||||
sha256 ? "",
|
||||
}:
|
||||
lib.mkOption {
|
||||
inherit description;
|
||||
type = types.path;
|
||||
default = builtins.fetchurl { inherit url sha256; };
|
||||
defaultText = lib.literalMD "";
|
||||
};
|
||||
|
||||
gui.options = {
|
||||
enable = lib.mkEnableOption "jalil's default gui configuration.";
|
||||
# Fix for using Xinput mode on 8bitdo Ultimate C controller
|
||||
# Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev
|
||||
# Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4
|
||||
"8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers";
|
||||
steamHardwareSupport = mkDisableOption "steam hardware support";
|
||||
ydotool = lib.mkOption {
|
||||
description = "Jalil's default ydotool configuration.";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.enable = mkDisableOption "ydotool";
|
||||
options.autoStart = mkDisableOption "autostarting ydotool at login";
|
||||
};
|
||||
};
|
||||
sway = mkDisableOption "sway";
|
||||
};
|
||||
|
||||
styling.options = {
|
||||
enable = mkDisableOption "jalil's default styling (disables stylix)";
|
||||
wallpaper = mkImageOption {
|
||||
description = "The wallpaper to use.";
|
||||
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
|
||||
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
|
||||
};
|
||||
bootLogo = mkImageOption {
|
||||
description = "The logo used by plymouth at boot.";
|
||||
# http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png
|
||||
url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png";
|
||||
sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8=";
|
||||
};
|
||||
};
|
||||
|
||||
config.options = {
|
||||
enable = lib.mkEnableOption "jalil's default configuration.";
|
||||
dev = lib.mkOption {
|
||||
description = "Options for setting up a dev environment";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
options.enable = lib.mkEnableOption "dev configuration";
|
||||
options.jupyter.enable = lib.mkEnableOption "jupyter configuration";
|
||||
};
|
||||
};
|
||||
gui = lib.mkOption {
|
||||
description = "Jalil's default configuration for a NixOS gui.";
|
||||
default = { };
|
||||
type = types.submodule gui;
|
||||
};
|
||||
styling = lib.mkOption {
|
||||
description = "Jalil's styling options";
|
||||
default = { };
|
||||
type = types.submodule styling;
|
||||
};
|
||||
importSSHKeysFromGithub = lib.mkOption {
|
||||
description = ''
|
||||
Import public ssh keys from a github username.
|
||||
|
||||
This will fetch the keys from https://github.com/$${username}.keys.
|
||||
|
||||
The format is `"$${github-username}" = $${sha256-hash}`. The example
|
||||
will try to fetch the keys from <https://github.com/jalil-salame.keys>.
|
||||
|
||||
**Warning**: this will interfere with services like gitea that override
|
||||
the default ssh behaviour. In that case you want to use
|
||||
`users.users.<name>.openssh.authorizedKeys.keyFiles` on the users you
|
||||
want to allow ssh logins.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
"jalil-salame" = "sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||
};
|
||||
type = types.attrsOf types.str;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.jconfig = lib.mkOption {
|
||||
description = "Jalil's default NixOS configuration.";
|
||||
default = { };
|
||||
type = types.submodule config;
|
||||
};
|
||||
}
|
89
modules/nixos/starship-nerdfont-symbols.nix
Normal file
89
modules/nixos/starship-nerdfont-symbols.nix
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
aws.symbol = " ";
|
||||
buf.symbol = " ";
|
||||
c.symbol = " ";
|
||||
conda.symbol = " ";
|
||||
crystal.symbol = " ";
|
||||
dart.symbol = " ";
|
||||
directory.read_only = " ";
|
||||
docker_context.symbol = " ";
|
||||
elixir.symbol = " ";
|
||||
elm.symbol = " ";
|
||||
fennel.symbol = " ";
|
||||
fossil_branch.symbol = " ";
|
||||
git_branch.symbol = " ";
|
||||
git_commit.tag_symbol = " ";
|
||||
golang.symbol = " ";
|
||||
gradle.symbol = " ";
|
||||
guix_shell.symbol = " ";
|
||||
haskell.symbol = " ";
|
||||
haxe.symbol = " ";
|
||||
hg_branch.symbol = " ";
|
||||
hostname.ssh_symbol = " ";
|
||||
java.symbol = " ";
|
||||
julia.symbol = " ";
|
||||
kotlin.symbol = " ";
|
||||
lua.symbol = " ";
|
||||
memory_usage.symbol = " ";
|
||||
meson.symbol = " ";
|
||||
nim.symbol = " ";
|
||||
nix_shell.symbol = " ";
|
||||
nodejs.symbol = " ";
|
||||
ocaml.symbol = " ";
|
||||
package.symbol = " ";
|
||||
perl.symbol = " ";
|
||||
php.symbol = " ";
|
||||
pijul_channel.symbol = " ";
|
||||
python.symbol = " ";
|
||||
rlang.symbol = " ";
|
||||
ruby.symbol = " ";
|
||||
rust.symbol = " ";
|
||||
scala.symbol = " ";
|
||||
swift.symbol = " ";
|
||||
zig.symbol = " ";
|
||||
os.symbols = {
|
||||
Alpaquita = " ";
|
||||
Alpine = " ";
|
||||
AlmaLinux = " ";
|
||||
Amazon = " ";
|
||||
Android = " ";
|
||||
Arch = " ";
|
||||
Artix = " ";
|
||||
CentOS = " ";
|
||||
Debian = " ";
|
||||
DragonFly = " ";
|
||||
Emscripten = " ";
|
||||
EndeavourOS = " ";
|
||||
Fedora = " ";
|
||||
FreeBSD = " ";
|
||||
Garuda = " ";
|
||||
Gentoo = " ";
|
||||
HardenedBSD = " ";
|
||||
Illumos = " ";
|
||||
Kali = " ";
|
||||
Linux = " ";
|
||||
Mabox = " ";
|
||||
Macos = " ";
|
||||
Manjaro = " ";
|
||||
Mariner = " ";
|
||||
MidnightBSD = " ";
|
||||
Mint = " ";
|
||||
NetBSD = " ";
|
||||
NixOS = " ";
|
||||
OpenBSD = " ";
|
||||
openSUSE = " ";
|
||||
OracleLinux = " ";
|
||||
Pop = " ";
|
||||
Raspbian = " ";
|
||||
Redhat = " ";
|
||||
RedHatEnterprise = " ";
|
||||
RockyLinux = " ";
|
||||
Redox = " ";
|
||||
Solus = " ";
|
||||
SUSE = " ";
|
||||
Ubuntu = " ";
|
||||
Unknown = " ";
|
||||
Void = " ";
|
||||
Windows = " ";
|
||||
};
|
||||
}
|
66
modules/nixos/starship-shorter-text.nix
Normal file
66
modules/nixos/starship-shorter-text.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
aws.format = "[$symbol($profile)(\\($region\\))(\\[$duration\\])]($style) ";
|
||||
bun.format = "[$symbol($version)]($style) ";
|
||||
c.format = "[$symbol($version(-$name))]($style) ";
|
||||
cmake.format = "[$symbol($version)]($style) ";
|
||||
cmd_duration.format = "[⏱ $duration]($style) ";
|
||||
cobol.format = "[$symbol($version)]($style) ";
|
||||
conda.format = "[$symbol$environment]($style) ";
|
||||
crystal.format = "[$symbol($version)]($style) ";
|
||||
daml.format = "[$symbol($version)]($style) ";
|
||||
dart.format = "[$symbol($version)]($style) ";
|
||||
deno.format = "[$symbol($version)]($style) ";
|
||||
docker_context.format = "[$symbol$context]($style) ";
|
||||
dotnet.format = "[$symbol($version)(🎯 $tfm)]($style) ";
|
||||
elixir.format = "[$symbol($version \\(OTP $otp_version\\))]($style) ";
|
||||
elm.format = "[$symbol($version)]($style) ";
|
||||
erlang.format = "[$symbol($version)]($style) ";
|
||||
fennel.format = "[$symbol($version)]($style) ";
|
||||
fossil_branch.format = "[$symbol$branch]($style) ";
|
||||
gcloud.format = "[$symbol$account(@$domain)(\\($region\\))]($style) ";
|
||||
git_branch.format = "[$symbol$branch]($style) ";
|
||||
git_status.format = "[$all_status$ahead_behind]($style) ";
|
||||
golang.format = "[$symbol($version)]($style) ";
|
||||
gradle.format = "[$symbol($version)]($style) ";
|
||||
guix_shell.format = "[$symbol]($style) ";
|
||||
haskell.format = "[$symbol($version)]($style) ";
|
||||
haxe.format = "[$symbol($version)]($style) ";
|
||||
helm.format = "[$symbol($version)]($style) ";
|
||||
hg_branch.format = "[$symbol$branch]($style) ";
|
||||
java.format = "[$symbol($version)]($style) ";
|
||||
julia.format = "[$symbol($version)]($style) ";
|
||||
kotlin.format = "[$symbol($version)]($style) ";
|
||||
kubernetes.format = "[$symbol$context( \\($namespace\\))]($style) ";
|
||||
lua.format = "[$symbol($version)]($style) ";
|
||||
memory_usage.format = "$symbol[$ram( | $swap)]($style) ";
|
||||
meson.format = "[$symbol$project]($style) ";
|
||||
nim.format = "[$symbol($version)]($style) ";
|
||||
nix_shell.format = "[$symbol$state( \\($name\\))]($style) ";
|
||||
nodejs.format = "[$symbol($version)]($style) ";
|
||||
ocaml.format = "[$symbol($version)(\\($switch_indicator$switch_name\\))]($style) ";
|
||||
opa.format = "[$symbol($version)]($style) ";
|
||||
openstack.format = "[$symbol$cloud(\\($project\\))]($style) ";
|
||||
os.format = "[$symbol]($style) ";
|
||||
package.format = "[$symbol$version]($style) ";
|
||||
perl.format = "[$symbol($version)]($style) ";
|
||||
php.format = "[$symbol($version)]($style) ";
|
||||
pijul_channel.format = "[$symbol$channel]($style) ";
|
||||
pulumi.format = "[$symbol$stack]($style) ";
|
||||
purescript.format = "[$symbol($version)]($style) ";
|
||||
python.format = "[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style) ";
|
||||
raku.format = "[$symbol($version-$vm_version)]($style) ";
|
||||
red.format = "[$symbol($version)]($style) ";
|
||||
ruby.format = "[$symbol($version)]($style) ";
|
||||
rust.format = "[$symbol($version)]($style) ";
|
||||
scala.format = "[$symbol($version)]($style) ";
|
||||
spack.format = "[$symbol$environment]($style) ";
|
||||
sudo.format = "[as $symbol]($style) ";
|
||||
swift.format = "[$symbol($version)]($style) ";
|
||||
terraform.format = "[$symbol$workspace]($style) ";
|
||||
time.format = "[$time]($style) ";
|
||||
username.format = "[$user]($style) ";
|
||||
vagrant.format = "[$symbol($version)]($style) ";
|
||||
vlang.format = "[$symbol($version)]($style) ";
|
||||
zig.format = "[$symbol($version)]($style) ";
|
||||
solidity.format = "[$symbol($version)]($style) ";
|
||||
}
|
36
modules/nixos/stylix-config.nix
Normal file
36
modules/nixos/stylix-config.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, pkgs }:
|
||||
let
|
||||
cfg = config.jconfig.styling;
|
||||
in
|
||||
{
|
||||
inherit (cfg) enable;
|
||||
image = cfg.wallpaper;
|
||||
base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
|
||||
polarity = "dark";
|
||||
fonts = {
|
||||
monospace = {
|
||||
name = "JetBrains Mono";
|
||||
package = pkgs.jetbrains-mono;
|
||||
};
|
||||
sansSerif = {
|
||||
name = "Noto Sans";
|
||||
package = pkgs.noto-fonts;
|
||||
};
|
||||
serif = {
|
||||
name = "Noto Serif";
|
||||
package = pkgs.noto-fonts;
|
||||
};
|
||||
emoji = {
|
||||
package = pkgs.noto-fonts-emoji;
|
||||
name = "Noto Color Emoji";
|
||||
};
|
||||
sizes.popups = 12;
|
||||
};
|
||||
targets = {
|
||||
plymouth = {
|
||||
logoAnimated = false;
|
||||
logo = cfg.bootLogo;
|
||||
};
|
||||
nixvim.enable = false;
|
||||
};
|
||||
}
|
122
modules/nixvim/augroups.nix
Normal file
122
modules/nixvim/augroups.nix
Normal file
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
config,
|
||||
helpers,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
cfg = config.jhome.nvim;
|
||||
dev = cfg.dev.enable;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
autoGroups = {
|
||||
"highlightOnYank" = { };
|
||||
"lspConfig" = { };
|
||||
"restoreCursorPosition" = { };
|
||||
"terminalConfig" = { };
|
||||
};
|
||||
autoCmd =
|
||||
[
|
||||
{
|
||||
group = "terminalConfig";
|
||||
event = "TermOpen";
|
||||
pattern = "*";
|
||||
callback =
|
||||
# lua
|
||||
mkRaw ''
|
||||
function(args)
|
||||
vim.wo.number = false
|
||||
vim.wo.relativenumber = false
|
||||
end
|
||||
'';
|
||||
}
|
||||
{
|
||||
group = "highlightOnYank";
|
||||
event = "TextYankPost";
|
||||
pattern = "*";
|
||||
callback =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function()
|
||||
vim.highlight.on_yank {
|
||||
higroup = (
|
||||
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
|
||||
),
|
||||
timeout = 200,
|
||||
}
|
||||
end
|
||||
'';
|
||||
}
|
||||
{
|
||||
group = "restoreCursorPosition";
|
||||
event = "BufReadPost";
|
||||
pattern = "*";
|
||||
callback =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function()
|
||||
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
|
||||
vim.cmd [[execute "normal! g'\""]]
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
]
|
||||
++ lib.optional dev {
|
||||
group = "lspConfig";
|
||||
event = "LspAttach";
|
||||
pattern = "*";
|
||||
callback =
|
||||
let
|
||||
opts = "noremap = true, buffer = bufnr";
|
||||
in
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function(opts)
|
||||
local bufnr = opts.buf
|
||||
local client = vim.lsp.get_client_by_id(opts.data.client_id)
|
||||
local capabilities = client.server_capabilities
|
||||
-- Set Omnifunc if supported
|
||||
if capabilities.completionProvider then
|
||||
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
end
|
||||
-- Enable inlay hints if supported
|
||||
if capabilities.inlayHintProvider then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
|
||||
vim.keymap.set('n', '<space>ht', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
|
||||
end,
|
||||
{ desc = '[H]ints [T]oggle', ${opts} }
|
||||
)
|
||||
-- Enable hover if supported
|
||||
if capabilities.hoverProvider then
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
|
||||
end
|
||||
-- Enable rename if supported
|
||||
if capabilities.renameProvider then
|
||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
|
||||
end
|
||||
-- Enable code actions if supported
|
||||
if capabilities.codeActionProvider then
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
|
||||
end
|
||||
-- Enable formatting if supported
|
||||
if capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
|
||||
end
|
||||
-- Other keybinds
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
|
||||
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
17
modules/nixvim/default.nix
Normal file
17
modules/nixvim/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.jhome.nvim;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config.programs.nixvim = lib.mkMerge [
|
||||
(import ./standalone.nix)
|
||||
(lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
nixpkgs.useGlobalPackages = true;
|
||||
defaultEditor = lib.mkDefault true;
|
||||
jhome.nvim = cfg;
|
||||
})
|
||||
];
|
||||
}
|
187
modules/nixvim/dev-plugins.nix
Normal file
187
modules/nixvim/dev-plugins.nix
Normal file
|
@ -0,0 +1,187 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) enableExceptInTests;
|
||||
cfg = config.jhome.nvim;
|
||||
enabledLSPs = [
|
||||
"basedpyright"
|
||||
"bashls"
|
||||
"clangd"
|
||||
# "html" # Not writing html
|
||||
"jsonls"
|
||||
"marksman"
|
||||
"ruff"
|
||||
"taplo"
|
||||
# "texlab" # Not using it
|
||||
"typos_lsp"
|
||||
# "typst_lsp" # Not using it
|
||||
"zls"
|
||||
];
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.dev.enable (
|
||||
lib.mkMerge [
|
||||
# Enable LSPs
|
||||
{
|
||||
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
|
||||
enable = true;
|
||||
});
|
||||
}
|
||||
# Remove bundled LSPs
|
||||
(lib.mkIf (!cfg.dev.bundleLSPs) {
|
||||
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
|
||||
package = null;
|
||||
});
|
||||
})
|
||||
# Configure LSPs
|
||||
{
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
# Pyright needs to have the project root set?
|
||||
basedpyright.rootDir = # lua
|
||||
''
|
||||
function()
|
||||
return vim.fs.root(0, {'flake.nix', '.git', '.jj', 'pyproject.toml', 'setup.py'})
|
||||
end
|
||||
'';
|
||||
bashls.package = lib.mkDefault pkgs.bash-language-server;
|
||||
# Adds ~2 GiB, install in a devShell instead
|
||||
clangd.package = lib.mkDefault null;
|
||||
# zls & other zig tools are big, install in a devShell instead
|
||||
zls.package = lib.mkDefault null;
|
||||
};
|
||||
};
|
||||
lspkind = {
|
||||
enable = true;
|
||||
mode = "symbol";
|
||||
extraOptions.maxwidth = 50;
|
||||
};
|
||||
lsp-lines.enable = true;
|
||||
};
|
||||
}
|
||||
# Configure Treesitter
|
||||
{
|
||||
plugins.treesitter = {
|
||||
enable = true;
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
incremental_election.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
# Do not bundle treesitter grammars
|
||||
(lib.mkIf (!cfg.dev.bundleGrammars) { plugins.treesitter.grammarPackages = [ ]; })
|
||||
# Remove tools for building gramars when bundling them
|
||||
(lib.mkIf cfg.dev.bundleGrammars {
|
||||
plugins.treesitter = {
|
||||
gccPackage = null;
|
||||
nodejsPackage = null;
|
||||
treesitterPackage = null;
|
||||
};
|
||||
})
|
||||
# Configure Formatters
|
||||
{
|
||||
extraPackages = [
|
||||
pkgs.luajitPackages.jsregexp
|
||||
pkgs.shfmt
|
||||
pkgs.stylua
|
||||
pkgs.taplo
|
||||
pkgs.yamlfmt
|
||||
];
|
||||
plugins.conform-nvim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
formatters.nixfmt.command = "${lib.getExe pkgs.nixfmt-rfc-style}";
|
||||
formatters_by_ft = {
|
||||
"_" = [ "trim_whitespace" ];
|
||||
c = [ "clang_format" ];
|
||||
cpp = [ "clang_format" ];
|
||||
lua = [ "stylua" ];
|
||||
nix = [ "nixfmt" ];
|
||||
rust = [ "rustfmt" ];
|
||||
sh = [ "shfmt" ];
|
||||
toml = [ "taplo" ];
|
||||
yaml = [ "yamlfmt" ];
|
||||
zig = [ "zigfmt" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
# Configure Linters
|
||||
{
|
||||
extraPackages = [
|
||||
pkgs.dash
|
||||
pkgs.statix
|
||||
];
|
||||
plugins.lint = {
|
||||
enable = true;
|
||||
lintersByFt = {
|
||||
# latex = [ "chktex" ]; # Not in use
|
||||
nix = [ "statix" ];
|
||||
sh = [ "dash" ];
|
||||
zsh = [ "zsh" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
# Jupyter notebooks
|
||||
{
|
||||
extraPackages = [ (pkgs.python3.withPackages (p: [ p.jupytext ])) ];
|
||||
plugins = {
|
||||
image.enable = enableExceptInTests;
|
||||
jupytext = {
|
||||
enable = true;
|
||||
settings.custom_language_formatting.python = {
|
||||
extension = "md";
|
||||
style = "markdown";
|
||||
force_ft = "markdown";
|
||||
};
|
||||
};
|
||||
molten = {
|
||||
enable = true;
|
||||
settings = {
|
||||
image_provider = "image.nvim";
|
||||
virt_text_output = true;
|
||||
molten_auto_open_output = false;
|
||||
molten_virt_lines_off_by_1 = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
# Rust plugins
|
||||
{
|
||||
plugins = {
|
||||
bacon = {
|
||||
enable = true;
|
||||
settings.quickfix.enabled = true;
|
||||
};
|
||||
rustaceanvim = {
|
||||
enable = true;
|
||||
# Install through rustup
|
||||
rustAnalyzerPackage = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
# Other plugins
|
||||
{
|
||||
plugins = {
|
||||
colorizer = {
|
||||
enable = true;
|
||||
settings.user_default_options = {
|
||||
names = false; # disable named colors (i.e. red)
|
||||
mode = "virtualtext";
|
||||
};
|
||||
};
|
||||
otter.enable = true;
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
11
modules/nixvim/extraPlugins/default.nix
Normal file
11
modules/nixvim/extraPlugins/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ pkgs }:
|
||||
let
|
||||
overlay = pkgs.callPackage ./generated.nix {
|
||||
inherit (pkgs.vimUtils) buildVimPlugin buildNeovimPlugin;
|
||||
};
|
||||
plugins = overlay pkgs pkgs;
|
||||
in
|
||||
{
|
||||
inherit overlay;
|
||||
inherit (plugins) nvim-silicon;
|
||||
}
|
23
modules/nixvim/extraPlugins/generated.nix
Normal file
23
modules/nixvim/extraPlugins/generated.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
# GENERATED by ./pkgs/applications/editors/vim/plugins/update.py. Do not edit!
|
||||
{
|
||||
lib,
|
||||
buildVimPlugin,
|
||||
buildNeovimPlugin,
|
||||
fetchFromGitHub,
|
||||
fetchgit,
|
||||
}:
|
||||
|
||||
final: prev: {
|
||||
nvim-silicon = buildVimPlugin {
|
||||
pname = "nvim-silicon";
|
||||
version = "2024-08-31";
|
||||
src = fetchFromGitHub {
|
||||
owner = "michaelrommel";
|
||||
repo = "nvim-silicon";
|
||||
rev = "9fe6001dc8cad4d9c53bcfc8649e3dc76ffa169c";
|
||||
sha256 = "1qczi06yndkr2pmwidlkgmk0395x189sznvscn4fnr96jx58j5yl";
|
||||
};
|
||||
meta.homepage = "https://github.com/michaelrommel/nvim-silicon/";
|
||||
};
|
||||
|
||||
}
|
2
modules/nixvim/extraPlugins/plugins
Normal file
2
modules/nixvim/extraPlugins/plugins
Normal file
|
@ -0,0 +1,2 @@
|
|||
repo,branch,alias
|
||||
https://github.com/michaelrommel/nvim-silicon/,,
|
229
modules/nixvim/mappings.nix
Normal file
229
modules/nixvim/mappings.nix
Normal file
|
@ -0,0 +1,229 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
cfg = config.jhome.nvim;
|
||||
in
|
||||
{
|
||||
config.keymaps =
|
||||
[
|
||||
# Quickfix
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qo";
|
||||
action = "<cmd>Copen<CR>";
|
||||
options.desc = "Quickfix Open";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qq";
|
||||
action = "<cmd>cclose<CR>";
|
||||
options.desc = "Quickfix Quit";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qj";
|
||||
action = "<cmd>cnext<CR>";
|
||||
options.desc = "Quickfix next [J]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qk";
|
||||
action = "<cmd>cprev<CR>";
|
||||
options.desc = "Quickfix previous [K]";
|
||||
}
|
||||
# Open or create file
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>gf";
|
||||
action = "<cmd>e <cfile><CR>";
|
||||
options.desc = "Go to File";
|
||||
}
|
||||
# Keep Selection when indenting
|
||||
{
|
||||
mode = "x";
|
||||
key = ">";
|
||||
action = ">gv";
|
||||
options.desc = "Indent Selection";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "<";
|
||||
action = "<gv";
|
||||
options.desc = "Deindent Selection";
|
||||
}
|
||||
# Diagnostics
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>dj";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
vim.diagnostic.goto_next
|
||||
'';
|
||||
options.desc = "Diagnostics next [J]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>dk";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
vim.diagnostic.goto_prev
|
||||
'';
|
||||
options.desc = "Diagnostics previous [K]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xs";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('symbols') end
|
||||
'';
|
||||
options.desc = "Toggle Diagnostics trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xd";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('diagnostics') end
|
||||
'';
|
||||
options.desc = "Toggle Diagnostics trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xq";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('quickfix') end
|
||||
'';
|
||||
options.desc = "Toggle Quickfix trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xl";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('loclist') end
|
||||
'';
|
||||
options.desc = "Toggle Loclist trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "gR";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('lsp_references') end
|
||||
'';
|
||||
options.desc = "Toggle lsp References trouble";
|
||||
}
|
||||
# Telescope
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ff";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').find_files
|
||||
'';
|
||||
options.desc = "Find Files";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fg";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').live_grep
|
||||
'';
|
||||
options.desc = "Find Grep";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fh";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').help_tags
|
||||
'';
|
||||
options.desc = "Find Help";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fb";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').buffers
|
||||
'';
|
||||
options.desc = "Find Buffer";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fd";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').diagnostics
|
||||
'';
|
||||
options.desc = "Find Diagnostics";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fq";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').quickfix
|
||||
'';
|
||||
options.desc = "Find Quickfix";
|
||||
}
|
||||
]
|
||||
# Nvim Silicon
|
||||
++ lib.optional (!cfg.reduceSize) {
|
||||
mode = "v";
|
||||
key = "<leader>sc";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('nvim-silicon').clip
|
||||
|
||||
'';
|
||||
options.desc = "Snap Code (to clipboard)";
|
||||
}
|
||||
++ lib.optional cfg.dev.enable {
|
||||
mode = "n";
|
||||
key = "<leader>w";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('conform').format
|
||||
'';
|
||||
options.desc = "Format buffer";
|
||||
};
|
||||
}
|
37
modules/nixvim/options.nix
Normal file
37
modules/nixvim/options.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
mkDisableOption =
|
||||
desc:
|
||||
mkEnableOption desc
|
||||
// {
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.jhome.nvim = {
|
||||
enable = mkDisableOption "jalil's Neovim configuration";
|
||||
reduceSize = mkEnableOption "reduce size by disabling big modules";
|
||||
dev = mkOption {
|
||||
type = types.submodule {
|
||||
options = {
|
||||
enable = mkDisableOption "development configuration";
|
||||
bundleLSPs = mkDisableOption "bundling LSPs with Neovim (decreases size when disabled)";
|
||||
bundleGrammars = mkDisableOption "bundling treesitter grammars with Neovim (barely decreases size when disabled)";
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
example = {
|
||||
enable = false;
|
||||
};
|
||||
description = ''
|
||||
Development options
|
||||
|
||||
Disabling this is advised for headless setups (e.g. servers), where you
|
||||
won't be doing software development and would prefer to instead have a
|
||||
smaller package.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
178
modules/nixvim/plugins.nix
Normal file
178
modules/nixvim/plugins.nix
Normal file
|
@ -0,0 +1,178 @@
|
|||
{ lib, helpers, ... }:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
in
|
||||
{
|
||||
config.plugins = {
|
||||
cmp = {
|
||||
enable = true;
|
||||
cmdline = {
|
||||
"/" = {
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.cmdline()
|
||||
'';
|
||||
sources = [
|
||||
{ name = "rg"; }
|
||||
{ name = "buffer"; }
|
||||
];
|
||||
};
|
||||
":" = {
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.cmdline()
|
||||
'';
|
||||
sources = [
|
||||
{ name = "path"; }
|
||||
{ name = "cmdline"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
settings = {
|
||||
# Snippets
|
||||
snippet.expand =
|
||||
# lua
|
||||
''
|
||||
function(args) require('luasnip').lsp_expand(args.body) end
|
||||
'';
|
||||
# Completion Sources
|
||||
sources = [
|
||||
{
|
||||
name = "buffer";
|
||||
groupIndex = 3;
|
||||
}
|
||||
{
|
||||
name = "calc";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "conventionalcommits";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "crates";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "luasnip";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp_document_symbol";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp_signature_help";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "path";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "spell";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "treesitter";
|
||||
groupIndex = 2;
|
||||
}
|
||||
];
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.insert({
|
||||
["<C-n>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-p>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-u>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").choice_active() then
|
||||
require("luasnip").next_choice()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete { },
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
gitsigns.enable = true;
|
||||
lualine = {
|
||||
enable = true;
|
||||
settings.options.theme = lib.mkForce "gruvbox";
|
||||
};
|
||||
luasnip = {
|
||||
enable = true;
|
||||
settings.update_events = "TextChanged,TextChangedI";
|
||||
};
|
||||
noice = {
|
||||
enable = true;
|
||||
settings = {
|
||||
lsp.override = {
|
||||
"vim.lsp.util.convert_input_to_markdown_lines" = true;
|
||||
"vim.lsp.util.stylize_markdown" = true;
|
||||
"cmp.entry.get_documentation" = true;
|
||||
};
|
||||
presets = {
|
||||
# use a classic bottom cmdline for search
|
||||
bottom_search = true;
|
||||
# position the cmdline and popupmenu together
|
||||
command_palette = false;
|
||||
# long messages will be sent to a split
|
||||
long_message_to_split = true;
|
||||
# enables an input dialog for inc-rename.nvim
|
||||
inc_rename = false;
|
||||
# add a border to hover docs and signature help
|
||||
lsp_doc_border = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
notify = {
|
||||
enable = true;
|
||||
settings.background_colour = "#000000";
|
||||
};
|
||||
telescope = {
|
||||
enable = true;
|
||||
extensions = {
|
||||
ui-select.enable = true;
|
||||
fzy-native.enable = true;
|
||||
};
|
||||
};
|
||||
trouble = {
|
||||
enable = true;
|
||||
settings.auto_close = true;
|
||||
};
|
||||
web-devicons.enable = true;
|
||||
};
|
||||
}
|
104
modules/nixvim/standalone.nix
Normal file
104
modules/nixvim/standalone.nix
Normal file
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jhome.nvim;
|
||||
plugins = pkgs.vimPlugins;
|
||||
extraPlugins = import ./extraPlugins { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./plugins.nix
|
||||
./dev-plugins.nix
|
||||
./mappings.nix
|
||||
./augroups.nix
|
||||
];
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
withRuby = false;
|
||||
globals.mapleader = " ";
|
||||
# Appearance
|
||||
colorschemes.gruvbox = {
|
||||
enable = true;
|
||||
settings = {
|
||||
bold = true;
|
||||
transparent_mode = true;
|
||||
terminal_colors = true;
|
||||
};
|
||||
};
|
||||
opts = {
|
||||
number = true;
|
||||
relativenumber = true;
|
||||
colorcolumn = "+1";
|
||||
cursorline = true;
|
||||
wrap = false;
|
||||
splitright = true;
|
||||
# Tabs & indentation
|
||||
smarttab = true;
|
||||
autoindent = true;
|
||||
smartindent = true;
|
||||
# Search path
|
||||
path = ".,/usr/include,**";
|
||||
wildmenu = true;
|
||||
hlsearch = true;
|
||||
incsearch = true;
|
||||
ignorecase = true; # Search ignores cases
|
||||
smartcase = true; # Unless it has a capital letter
|
||||
# Enable local configuration :h 'exrc'
|
||||
exrc = true; # safe since nvim 0.9
|
||||
};
|
||||
extraPlugins = [
|
||||
plugins.nui-nvim
|
||||
plugins.nvim-web-devicons
|
||||
plugins.vim-jjdescription # FIXME: included since neovim nightly
|
||||
];
|
||||
extraPackages = [ pkgs.luajitPackages.jsregexp ];
|
||||
extraConfigLuaPre =
|
||||
# lua
|
||||
''
|
||||
-- Lua Pre Config
|
||||
if vim.fn.has 'termguicolors' then
|
||||
-- Enable RGB colors
|
||||
vim.g.termguicolors = true
|
||||
end
|
||||
|
||||
-- Useful function
|
||||
local has_words_before = function()
|
||||
-- unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0
|
||||
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
|
||||
end
|
||||
-- END: Lua Pre Config
|
||||
'';
|
||||
}
|
||||
# Big packages that are kinda unnecessary
|
||||
(lib.mkIf (!cfg.reduceSize) {
|
||||
extraPlugins = [ extraPlugins.nvim-silicon ];
|
||||
extraPackages = [ pkgs.silicon ];
|
||||
extraConfigLua =
|
||||
# lua
|
||||
''
|
||||
-- Lua Config
|
||||
require("nvim-silicon").setup {
|
||||
theme = "gruvbox-dark",
|
||||
pad_horiz = 16,
|
||||
pad_vert = 16,
|
||||
-- Current buffer name
|
||||
window_title = function()
|
||||
return vim.fn.fnamemodify(
|
||||
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
|
||||
":t"
|
||||
)
|
||||
end,
|
||||
}
|
||||
-- END: Lua Config
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue