Refactor codebase to use nix modules

This commit is contained in:
Julia Lange 2024-04-14 05:40:02 -07:00
parent a4735423b4
commit ffada2703c
114 changed files with 1018 additions and 744 deletions

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
{
options.beeper = {
enable = lib.mkEnableOption "Enables beeper";
};
config = lib.mkIf config.beeper.enable {
home.packages = with pkgs; [
beeper
];
};
}

View file

@ -0,0 +1,8 @@
{ config, pkgs, ... }:
{
imports = [
./discord
./beeper
];
}

View file

@ -0,0 +1,12 @@
{ config, pkgs, lib, ... }:
{
options.discord = {
enable = lib.mkEnableOption "Enables discord";
};
config = lib.mkIf config.discord.enable {
home.packages = with pkgs; [
vesktop # Base app
];
};
}

View file

@ -0,0 +1,18 @@
{ config, pkgs, ... }:
{
imports = [
./chat
./file-browsers
./gimp
./git
./hypr
./lutris
./media-viewers
./neovim
./obs
./rofi
./shells
./terminal-emulators
];
}

View file

@ -0,0 +1,8 @@
{ config, pkgs, lib, ... }:
{
imports = [
./lf
./nnn
];
}

View file

@ -0,0 +1,82 @@
{ config, pkgs, lib, ... }:
{
options.lf = {
enable = lib.mkEnableOption "Enables lf";
hiddenfiles = lib.mkOption { default = [ ".*" ]; };
leader = lib.mkOption { default = "<space>"; };
};
config = lib.mkIf config.lf.enable {
xdg.configFile."lf/icons".source = ./icons;
programs.lf = {
enable = true;
settings = {
# Hide specific files rather than "hidden" files
hiddenfiles = config.lf.hiddenfiles;
ratios = [
2
3
];
preview = true;
ignorecase = true;
icons = true;
number = true;
relativenumber = true;
};
commands = {
dragon-out = ''%${pkgs.xdragon}/bin/xdragon -a -x "$fx"'';
mkdir = ''
''${{
printf "Directory Name: "
read DIR
mkdir $DIR
}}
'';
mkfile = ''
''${{
printf "File Name: "
read FILE
mkdir $FILE
}}
'';
};
keybindings = let
leader = config.lf.leader;
in {
"${leader}" = "";
"v" = ":toggle; down";
"." = "set hidden!";
"${leader}d" = "mkdir";
"${leader}f" = "mkfile";
"${leader}m" = "dragon-out";
};
extraConfig =
let
previewer =
pkgs.writeShellScriptBin "pv.sh" ''
file=$1
w=$2
h=$3
x=$4
y=$5
if [[ "$( ${pkgs.file}/bin/file -Lb --mime-type "$file")" =~ ^image ]]; then
${pkgs.kitty}/bin/kitty +kitten icat --silent --stdin no --transfer-mode file --place "''${w}x''${h}@''${x}x''${y}" "$file" < /dev/null > /dev/tty
exit 1
fi
${pkgs.pistol}/bin/pistol "$file"
'';
cleaner = pkgs.writeShellScriptBin "clean.sh" ''
${pkgs.kitty}/bin/kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty
'';
in
''
set cleaner ${cleaner}/bin/clean.sh
set previewer ${previewer}/bin/pv.sh
'';
};
};
}

View file

@ -0,0 +1,361 @@
# vim:ft=conf
# These examples require Nerd Fonts or a compatible font to be used.
# See https://www.nerdfonts.com for more information.
# default values from lf (with matching order)
# ln l # LINK
# or l # ORPHAN
# tw t # STICKY_OTHER_WRITABLE
# ow d # OTHER_WRITABLE
# st t # STICKY
# di d # DIR
# pi p # FIFO
# so s # SOCK
# bd b # BLK
# cd c # CHR
# su u # SETUID
# sg g # SETGID
# ex x # EXEC
# fi - # FILE
# file types (with matching order)
ln  # LINK
or  # ORPHAN
tw t # STICKY_OTHER_WRITABLE
ow  # OTHER_WRITABLE
st t # STICKY
di  # DIR
pi p # FIFO
so s # SOCK
bd b # BLK
cd c # CHR
su u # SETUID
sg g # SETGID
ex  # EXEC
fi  # FILE
# file extensions (vim-devicons)
*.styl 
*.sass 
*.scss 
*.htm 
*.html 
*.slim 
*.haml 
*.ejs 
*.css 
*.less 
*.md 
*.mdx 
*.markdown 
*.rmd 
*.json 
*.webmanifest 
*.js 
*.mjs 
*.jsx 
*.rb 
*.gemspec 
*.rake 
*.php 
*.py 
*.pyc 
*.pyo 
*.pyd 
*.coffee 
*.mustache 
*.hbs 
*.conf 
*.ini 
*.yml 
*.yaml 
*.toml 
*.bat 
*.mk 
*.jpg 
*.jpeg 
*.bmp 
*.png 
*.webp 
*.gif 
*.ico 
*.twig 
*.cpp 
*.c++ 
*.cxx 
*.cc 
*.cp 
*.c 
*.cs 󰌛
*.h 
*.hh 
*.hpp 
*.hxx 
*.hs 
*.lhs 
*.nix 
*.lua 
*.java 
*.sh 
*.fish 
*.bash 
*.zsh 
*.ksh 
*.csh 
*.awk 
*.ps1 
*.ml λ
*.mli λ
*.diff 
*.db 
*.sql 
*.dump 
*.clj 
*.cljc 
*.cljs 
*.edn 
*.scala 
*.go 
*.dart 
*.xul 
*.sln 
*.suo 
*.pl 
*.pm 
*.t 
*.rss 
'*.f#' 
*.fsscript 
*.fsx 
*.fs 
*.fsi 
*.rs 
*.rlib 
*.d 
*.erl 
*.hrl 
*.ex 
*.exs 
*.eex 
*.leex 
*.heex 
*.vim 
*.ai 
*.psd 
*.psb 
*.ts 
*.tsx 
*.jl 
*.pp 
*.vue 
*.elm 
*.swift 
*.xcplayground 
*.tex 󰙩
*.r 󰟔
*.rproj 󰗆
*.sol 󰡪
*.pem 
# file names (vim-devicons) (case-insensitive not supported in lf)
*gruntfile.coffee 
*gruntfile.js 
*gruntfile.ls 
*gulpfile.coffee 
*gulpfile.js 
*gulpfile.ls 
*mix.lock 
*dropbox 
*.ds_store 
*.gitconfig 
*.gitignore 
*.gitattributes 
*.gitlab-ci.yml 
*.bashrc 
*.zshrc 
*.zshenv 
*.zprofile 
*.vimrc 
*.gvimrc 
*_vimrc 
*_gvimrc 
*.bashprofile 
*favicon.ico 
*license 
*node_modules 
*react.jsx 
*procfile 
*dockerfile 
*docker-compose.yml 
*docker-compose.yaml 
*compose.yml 
*compose.yaml 
*rakefile 
*config.ru 
*gemfile 
*makefile 
*cmakelists.txt 
*robots.txt 󰚩
# file names (case-sensitive adaptations)
*Gruntfile.coffee 
*Gruntfile.js 
*Gruntfile.ls 
*Gulpfile.coffee 
*Gulpfile.js 
*Gulpfile.ls 
*Dropbox 
*.DS_Store 
*LICENSE 
*React.jsx 
*Procfile 
*Dockerfile 
*Docker-compose.yml 
*Docker-compose.yaml 
*Rakefile 
*Gemfile 
*Makefile 
*CMakeLists.txt 
# file patterns (vim-devicons) (patterns not supported in lf)
# .*jquery.*\.js$ 
# .*angular.*\.js$ 
# .*backbone.*\.js$ 
# .*require.*\.js$ 
# .*materialize.*\.js$ 
# .*materialize.*\.css$ 
# .*mootools.*\.js$ 
# .*vimrc.* 
# Vagrantfile$ 
# file patterns (file name adaptations)
*jquery.min.js 
*angular.min.js 
*backbone.min.js 
*require.min.js 
*materialize.min.js 
*materialize.min.css 
*mootools.min.js 
*vimrc 
Vagrantfile 
# archives or compressed (extensions from dircolors defaults)
*.tar 
*.tgz 
*.arc 
*.arj 
*.taz 
*.lha 
*.lz4 
*.lzh 
*.lzma 
*.tlz 
*.txz 
*.tzo 
*.t7z 
*.zip 
*.z 
*.dz 
*.gz 
*.lrz 
*.lz 
*.lzo 
*.xz 
*.zst 
*.tzst 
*.bz2 
*.bz 
*.tbz 
*.tbz2 
*.tz 
*.deb 
*.rpm 
*.jar 
*.war 
*.ear 
*.sar 
*.rar 
*.alz 
*.ace 
*.zoo 
*.cpio 
*.7z 
*.rz 
*.cab 
*.wim 
*.swm 
*.dwm 
*.esd 
# image formats (extensions from dircolors defaults)
*.jpg 
*.jpeg 
*.mjpg 
*.mjpeg 
*.gif 
*.bmp 
*.pbm 
*.pgm 
*.ppm 
*.tga 
*.xbm 
*.xpm 
*.tif 
*.tiff 
*.png 
*.svg 
*.svgz 
*.mng 
*.pcx 
*.mov 
*.mpg 
*.mpeg 
*.m2v 
*.mkv 
*.webm 
*.ogm 
*.mp4 
*.m4v 
*.mp4v 
*.vob 
*.qt 
*.nuv 
*.wmv 
*.asf 
*.rm 
*.rmvb 
*.flc 
*.avi 
*.fli 
*.flv 
*.gl 
*.dl 
*.xcf 
*.xwd 
*.yuv 
*.cgm 
*.emf 
*.ogv 
*.ogx 
# audio formats (extensions from dircolors defaults)
*.aac 
*.au 
*.flac 
*.m4a 
*.mid 
*.midi 
*.mka 
*.mp3 
*.mpc 
*.ogg 
*.ra 
*.wav 
*.oga 
*.opus 
*.spx 
*.xspf 
# other formats
*.pdf 

View file

@ -0,0 +1,17 @@
{ config, pkgs, lib, ... }:
{
options.nnn = {
enable = lib.mkEnableOption "Enables nnn";
};
config = lib.mkIf config.nnn.enable {
programs.nnn.enable = true;
home.sessionVariables = {
NNN_FCOLORS = "0000E6310000000000000000";
NNN_OPTS = "eH";
NNN_FIFO = "/tmp/nnn.fifo";
NNN_TRASH = lib.mkIf config.trash.enable "1";
};
};
}

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
{
options.gimp = {
enable = lib.mkEnableOption "Enables gimp";
};
config = lib.mkIf config.gimp.enable {
home.packages = with pkgs; [
gimp
];
};
}

View file

@ -0,0 +1,19 @@
{ config, pkgs, lib, ... }:
{
options.git = {
enable = lib.mkEnableOption "Enables git";
username = lib.mkOption { default = config.home.username; };
email = lib.mkOption {
default = "git@" + config.home.username + ".com";
};
};
config = lib.mkIf config.git.enable {
programs.git = {
enable = true;
userName = config.git.username;
userEmail = config.git.email;
};
};
}

View file

@ -0,0 +1,50 @@
{ config, inputs, pkgs, lib, ... }:
let rootPath = ./.; in
{
options.hypr = {
enable = lib.mkEnableOption "Enables hyprland";
};
imports = [ inputs.hyprland.homeManagerModules.default ];
config = lib.mkIf config.hypr.enable {
wayland.windowManager.hyprland = {
enable = true;
extraConfig = ''
${builtins.readFile ./window_rules.conf}
${builtins.readFile ./league_rules.conf}
${builtins.readFile ./settings.conf}
${builtins.readFile ./nvidia.conf}
${builtins.readFile ./keybinds.conf}
${builtins.readFile ./xwaylandvideobridge.conf}
exec-once=${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1
env = HYPRCURSOR_THEME,miku
env = HYPRCURSOR_SIZE,64
'';
};
home.packages = with pkgs; [
socat # For hyprland scripts
swww # Wallpaper engine
wlr-randr # Xrandr for wayland
wl-clipboard # Clipboard manager for wayland
xdg-desktop-portal-hyprland # XDP for hyprland
hyprpicker # Colorpicker, needed for screenshot tool
hyprcursor # Hyprland cursor
inputs.hyprland-contrib.packages.${pkgs.system}.grimblast # Screenshot tool
polkit-kde-agent # Polkit handler
];
# Hyprland screenshot tool
xdg.configFile."hypr-scripts" = {
source = rootPath + "/scripts";
target = "hypr/scripts";
executable = true;
};
xdg.dataFile."hypr-icons" = {
source = rootPath + "/icons";
target = "icons/";
recursive = true;
};
};
}

View file

@ -0,0 +1,48 @@
$mainMod = SUPER
# Exec programs
bind = $mainMod, return, exec, kitty
bind = $mainMod SHIFT, return, exec, rofi -show run
bind = $mainMod, P, exec, grimblast --freeze copy area
bind = $mainMod SHIFT, P, exec, grimblast --freeze copysave area
# Hyprland Management
bind = $mainMod SHIFT, Q, exit,
# Workspace / Monitor Management
bind = $mainMod, h, focusmonitor, l
bind = $mainMod, l, focusmonitor, r
bind = $mainMod, j, cyclenext,
bind = $mainMod, k, cyclenext, prev
bind = $mainMod SHIFT, j, swapnext,
bind = $mainMod SHIFT, k, swapnext, prev
bind = $mainMod SHIFT, h, movecurrentworkspacetomonitor, -1
bind = $mainMod SHIFT, l, movecurrentworkspacetomonitor, +1
bind = $mainMod, 1, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh home
bind = $mainMod, 2, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh web
bind = $mainMod, 3, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh med
bind = $mainMod, 4, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh game
binde = $mainMod, 5, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh etc
binde = $mainMod, _, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh hell
binde = $mainMod, TAB, exec, $XDG_CONFIG_HOME/hypr/scripts/changesecondary.xsh
bind = $mainMod, m, togglespecialworkspace, mus
bind = $mainMod, i, togglespecialworkspace, scratch
# Window Management
bind = $mainMod, C, killactive,
bind = $mainMod, F, togglefloating,
bind = $mainMod SHIFT, F, fullscreen,
bind = $mainMod SHIFT, 1, movetoworkspacesilent, name:home
bind = $mainMod SHIFT, 2, movetoworkspacesilent, name:web
bind = $mainMod SHIFT, 3, movetoworkspacesilent, name:med
bind = $mainMod SHIFT, 4, movetoworkspacesilent, name:misc
bind = $mainMod SHIFT, _, movetoworkspacesilent, name:hell
bind = $mainMod SHIFT, TAB, movetoworkspacesilent, r-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

View file

@ -0,0 +1,25 @@
# no opacity
windowrulev2 = opacity 1 1, class:^(league of legends.exe)$ # loading text
windowrulev2 = opacity 1 override, class:^(leagueclientux.exe)$ # client
windowrulev2 = opacity 1 override, class:^(leagueclient.exe)$ # game
# nice loading text
windowrulev2 = noblur, class:^(leagueclient.exe)$
windowrulev2 = noborder, class:^(leagueclient.exe)$
windowrulev2 = nofocus, class:^(leagueclient.exe)$
windowrulev2 = noshadow, class:^(leagueclient.exe)$
# windowrulev2 = immediate, class:^(league of legends.exe)$
# windowrulev2 = immediate, class:^(overwatch.exe)$
# windowrulev2 = immediate, class:^(steam_app_1384160)$
windowrulev2 = fullscreen, class:^(overwatch.exe)$
windowrulev2 = fullscreen, class:^(steam_app_1384160)$
windowrulev2 = fullscreen, class:^(league of legends.exe)$
# workspaces
windowrule = workspace name:game, leagueclient.exe
windowrule = workspace name:game, leagueclientux.exe
windowrule = workspace name:game, league of legends.exe
windowrule = workspace name:game, overwatch.exe
windowrule = workspace name:game, 東方紅魔郷.exe
windowrule = workspace name:game, steam_app_1384160

View file

@ -0,0 +1,6 @@
# Nivida Settings
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1

View file

@ -0,0 +1,27 @@
#!/usr/bin/env xonsh
import shelve
# Usage:
# ./changeprimary.xsh workspace
# changes to that workspace
# if workspace is "etc" then changes to etcN where N is a number
workspace=$ARG1
monitor=$HYPR_MON_PRIMARY
current_workspace = "home"
with shelve.open($HYPR_WORK_DB) as db:
current_workspace = db.get("primary")
if workspace == "etc":
if current_workspace.startswith("etc"):
current = current_workspace[3:] % db.get("primary_extras")
current_workspace = "etc" + str(current)
else:
current_workspace = "etc0"
else:
current_workspace = workspace
db["primary"] = current_workspace
hyprctl dispatch moveworkspacetomonitor name:@(current_workspace) $HYPR_MON_PRIMARY >> /dev/null
hyprctl dispatch workspace name:@(current_workspace) >> /dev/null

View file

@ -0,0 +1,27 @@
#!/usr/bin/env xonsh
import shelve
import copy
# Usage:
# ./changesecondary.xsh
# cycles through the secondary workspaces
current_secondary = "chat"
with shelve.open($HYPR_WORK_DB) as db:
workspaces = db.get("secondaries").copy()
current_primary = db.get("primary")
current_secondary = db.get("secondary")
#extras = db.get("secondary_extras")
if current_primary in workspaces:
workspaces.remove(current_primary)
current_secondary = workspaces[
(workspaces.index(current_secondary)+1) % len(workspaces)
]
db["secondary"] = current_secondary
# Change primary to bind
hyprctl dispatch moveworkspacetomonitor name:@(current_secondary) $HYPR_MON_SECONDARY
hyprctl dispatch workspace name:@(current_secondary)

View file

@ -0,0 +1,13 @@
#!/usr/bin/env xonsh
import shelve
# Usage:
# ./initdb.xsh
# initialize a db for use hypr workspace scripts
with shelve.open($HYPR_WORK_DB) as db:
db["primary"] = "home"
db["secondary"] = "chat"
db["secondaries"] = ["chat", "web", "med"]
db["secondary_extras"] = 1
db["primary_extras"] = 1

View file

@ -0,0 +1,62 @@
# Monitor Settings
monitor=DP-2,2560x1440@60,0x0,1
monitor=DP-1,2560x1440@144,-2560x0,1
monitor=HDMI-A-1,disable
# Inits
exec-once = swww init
exec-once = swww img $HOME/med/pix/bg.png
exec-once = ags
# Settings
input {
kb_layout = us
follow_mouse = 1
accel_profile = flat
sensitivity = -0.52
#sensitivity = 0.2 # -1.0 - 1.0, 0 means no modification.
}
general {
gaps_in = 3
gaps_out = 3
border_size = 2
col.active_border = rgb(F5C2E7)
col.inactive_border = rgb(1E1D2F)
layout = master
}
decoration {
rounding = 2
blur {
enabled = true
size = 12
passes = 2
special = true
}
dim_special = 0.2
}
animations {
enabled = yes
animation = windows, 1, 4, default, popin 50%
animation = windowsOut, 1, 4, default, popin 50%
animation = windowsMove, 1, 3, default
animation = border, 1, 3, default
animation = fade, 1, 3, default
animation = workspaces, 1, 3, default
}
master {
no_gaps_when_only = true
new_is_master = false
mfact = 0.53
}
misc {
focus_on_activate = true
enable_swallow = false
swallow_regex = ^(Alacritty)$
}

View file

@ -0,0 +1,40 @@
env = HYPR_MON_PRIMARY, DP-2
env = HYPR_MON_SECONDARY, DP-1
# Primaries
workspace=name:home, monitor:DP-2, persistent:true, default:true
workspace=name:game, monitor:DP-2, persistent:true
workspace=name:etc0, monitor:DP-2, persistent:true
workspace=name:hell, monitor:DP-2, persistent:true
# Secondaries
workspace=name:chat, monitor:DP-1, persistent:true, default:true
workspace=name:misc0, monitor:DP-1, persistent:true
# Switches
workspace=name:web , monitor:DP-1, persistent:true
workspace=name:med , monitor:DP-1, persistent:true
# Pseudo
workspace=special:mus, persistent:true
workspace=special:scratch, on-created-empty: [float; size 50% 50%; center] kitty
windowrule = workspace name:web, librewolf
windowrulev2 = workspace name:med, librewolf,title:Picture-in-Picture
windowrule = workspace name:chat, discord
windowrule = workspace name:chat, Beeper
windowrule = workspace name:game, lutris
windowrule = workspace name:game, explorer.exe
windowrulev2 = opacity 0.94 fullscreen:0
windowrulev2 = opacity 0.79 override, class:^(Alacritty)$
windowrulev2 = opacity 0.79 override, class:^(kitty)$
windowrulev2 = opacity 1 override, initialTitle:^(Discord Popout)$
windowrulev2 = opacity 1 override, class:^(firefox)$
windowrulev2 = opacity 1 override, class:^(Gimp)$
windowrulev2 = opacity 1 override, class:^(feh)$
windowrulev2 = opacity 1 override, class:^(mpv)$
env = HYPR_WORK_DB,$XDG_CACHE_HOME/hypr/workspace.db
# exec-once = [workspace special:mus silent;float;size 70% 70%;center] mus client
exec-once = [workspace name:chat silent] vesktop
exec-once = [workspace name:chat silent] beeper

View file

@ -0,0 +1,5 @@
windowrulev2 = opacity 0.0 override 0.0 override,class:^(xwaylandvideobridge)$
windowrulev2 = noanim,class:^(xwaylandvideobridge)$
windowrulev2 = noinitialfocus,class:^(xwaylandvideobridge)$
windowrulev2 = maxsize 1 1,class:^(xwaylandvideobridge)$
windowrulev2 = noblur,class:^(xwaylandvideobridge)$

View file

@ -0,0 +1,16 @@
{ config, pkgs, lib, ... }:
{
options.librewolf = {
enable = lib.mkEnableOption "Enables librewolf";
};
config = lib.mkIf config.librewolf.enable {
home.packages = with pkgs; [
librewolf
];
home.sessionVariables = {
BROWSER = "librewolf";
};
};
}

View file

@ -0,0 +1,22 @@
{ config, pkgs, lib, ... }:
{
options.lutris = {
enable = lib.mkEnableOption "Enables lutris";
};
config = lib.mkIf config.lutris.enable {
home.packages = with pkgs; [
lutris
wineWowPackages.stable
# (lutris.override {
# extraLibraries = pkgs: [
# # List library dependencies here
# ];
# extraPkgs = pkgs: [
# # List package dependencies here
# ];
# })
];
};
}

View file

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
imports = [
./feh
./mpv
./zathura
];
}

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
{
options.feh = {
enable = lib.mkEnableOption "Enables feh";
};
config = lib.mkIf config.feh.enable {
programs.feh = {
enable = true;
};
};
}

View file

@ -0,0 +1,22 @@
{ config, pkgs, lib, ... }:
{
options.mpv = {
enable = lib.mkEnableOption "Enables mpv";
};
config = lib.mkIf config.mpv.enable {
home.packages = with pkgs; [
yt-dlp
];
programs.mpv = {
enable = true;
config = {
volume-max = 150;
force-window = "yes";
script-opts = "ytdl_hook-ytdl_path=yt-dlp";
ytdl-format = "bestvideo[height<=?1080][vcodec!=vp9]+bestaudio/best";
};
};
};
}

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
{
options.zathura = {
enable = lib.mkEnableOption "Enables zathura";
};
config = lib.mkIf config.zathura.enable {
programs.zathura = {
enable = true;
};
};
}

View file

@ -0,0 +1,86 @@
{ config, pkgs, lib, ... }:
{
options.neovim = {
enable = lib.mkEnableOption "Enables neovim";
};
config = lib.mkIf config.neovim.enable {
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
programs.neovim = {
enable = true;
extraConfig = ''
${builtins.readFile ./init.vim}
'';
plugins = with pkgs.vimPlugins; [
{ # Personal Wiki
plugin = vimwiki;
config = ''
let g:vimwiki_list = [{'path': '~/dox/wiki', 'links_space_char': '_',
\ 'ext': '.md', 'syntax': 'markdown'}]
'';
}
{ # NNN in vim
plugin = nnn-vim;
config = ''
let g:nnn#layout = { 'window': {
\ 'width': 0.35,
\ 'height': 0.5,
\ 'xoffset': 1.0,
\ 'highlight': 'Debug' } } " hover window
let g:nnn#action = {
\ '<c-t>': 'tab split',
\ '<c-s>': 'split',
\ '<c-v>': 'vsplit' }
let g:nnn#command = 'nnn -HoeT v'
let g:nnn#replace_netrw = 1
'';
}
{ # Fuzzy searches
plugin = fzf-vim;
config = ''
map <C-f> :Files<CR>
map <C-a> :Ag<CR>
'';
}
{ # Auto completions
plugin = coc-nvim;
config = ''
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
'';
}
vim-commentary # multi-line comments
vim-fugitive # Git Plugin
vimtex # Latex support
tagbar # File tagging
# === LOOK AND FEEL ===
{ # Status Bar
plugin = vim-airline;
config = ''
let g:airline#extensions#tagbar#flags = 'fs'
'';
}
{ # Rainbow Parenthesis
plugin = rainbow;
config = ''
let g:rainbow_actve = 1
'';
}
vim-polyglot # Syntax Highlighting
];
};
};
}

View file

@ -0,0 +1,68 @@
syntax on
let mapleader =" "
set encoding=utf-8
set nocompatible
filetype plugin on
set list
set updatetime=300
" Easy Split Navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Indentation
" set tabstop=2 softtabstop=0 shiftwidth=2 smarttab expandtab
set tabstop=8 softtabstop=0 shiftwidth=8
" Searching
set smartcase
" Backups
set noswapfile
set nobackup
set undodir=~/.config/nvim/undodir
set undofile
" Right column at 80 lines for good coding practice.
set colorcolumn=80
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" QoL
set showmatch " Show matching Brackets
set number relativenumber " Side numbers
" Fuzzy finding by allowing searching into subfolders
set path+=**
set wildmenu
" use :find to find, and * to make it fuzzy.
" Also make use of :b.
" Delete trailing white space and newlines at end of file on save.
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
" Easy copy and pasting to external programs
map <C-y> "+yy
map <C-p> "+P
autocmd BufRead,BufNewFile *.md call WritingMode()
autocmd BufRead,BufNewFile *.tex call WritingMode()
autocmd BufRead,BufNewFile *.svx call WritingMode()
autocmd BufRead,BufNewFile *.py call PythonMode()
function! WritingMode()
setlocal textwidth=80
setlocal wrap linebreak nolist
setlocal whichwrap+=<,>,h,l
nnoremap j gj
nnoremap k gk
setlocal spell spelllang=en_us
endfunction
function! PythonMode()
setlocal foldmethod=indent
setlocal foldlevel=99
endfunction

View file

@ -0,0 +1,17 @@
{ config, pkgs, lib, ... }:
{
options.obs = {
enable = lib.mkEnableOption "Enables obs";
};
config = lib.mkIf config.obs.enable {
programs.obs-studio = {
enable = true;
plugins = with pkgs.obs-studio-plugins; [
wlrobs
obs-backgroundremoval
obs-pipewire-audio-capture
];
};
};
}

View file

@ -0,0 +1,14 @@
{ config, pkgs, lib, ... }:
{
options.rofi = {
enable = lib.mkEnableOption "Enables rofi";
};
config = lib.mkIf config.rofi.enable {
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
};
};
}

View file

@ -0,0 +1,9 @@
{ config, pkgs, lib, ... }:
{
imports = [
./fish
./xonsh
./zsh
];
}

View file

@ -0,0 +1,45 @@
{ config, pkgs, lib, ... }:
{
options.fish = {
enable = lib.mkEnableOption "Enables fish";
};
config = lib.mkIf config.fish.enable {
programs.fish.enable = true;
programs.fish.functions = {
fish_greeting = "";
fish_prompt = ''
${builtins.readFile ./functions/fish_prompt.fish}
'';
fish_right_prompt = ''
${builtins.readFile ./functions/fish_right_prompt.fish}
'';
git_branch_name = ''
${builtins.readFile ./functions/git_branch_name.fish}
'';
git_is_dirty = ''
${builtins.readFile ./functions/git_is_dirty.fish}
'';
git_is_repo = ''
${builtins.readFile ./functions/git_is_repo.fish}
'';
git_is_staged = ''
${builtins.readFile ./functions/git_is_staged.fish}
'';
git_is_touched = ''
${builtins.readFile ./functions/git_is_touched.fish}
'';
git_is_worktree = ''
${builtins.readFile ./functions/git_is_worktree.fish}
'';
ssh = ''
${builtins.readFile ./functions/ssh.fish}
'';
n = lib.mkIf config.nnn.enable ''
${builtins.readFile ./functions/n.fish}
'';
};
};
}

View file

@ -0,0 +1,13 @@
set -l last_command_status $status
set -l symbol 'τ'
set -l normal_color (set_color normal)
set -l symbol_color (set_color blue -o)
set -l error_color (set_color red -o)
if test $last_command_status -eq 0
echo -n -s $symbol_color $symbol " " $normal_color
else
echo -n -s $error_color $symbol " " $normal_color
end

View file

@ -0,0 +1,61 @@
set -l cwd
set -l cwd_color (set_color blue)
set -l normal_color (set_color normal)
set -l branch_color (set_color yellow)
set -l meta_color (set_color red)
if git_is_repo
echo -n -s $branch_color (git_branch_name) $normal_color
set -l git_meta ""
if test (command git ls-files --others --exclude-standard | wc -w 2> /dev/null) -gt 0
set git_meta "$git_meta?"
end
if test (command git rev-list --walk-reflogs --count refs/stash 2> /dev/null)
set git_meta "$git_meta\$"
end
if git_is_touched
git_is_dirty && set git_meta "$git_meta"
git_is_staged && set git_meta "$git_meta"
end
set -l commit_count (command git rev-list --count --left-right (git remote)/(git_branch_name)"...HEAD" 2> /dev/null)
if test $commit_count
set -l behind (echo $commit_count | cut -f 1)
set -l ahead (echo $commit_count | cut -f 2)
if test $behind -gt 0
set git_meta "$git_meta🠋"
end
if test $ahead -gt 0
set git_meta "$git_meta🠉"
end
end
if test $git_meta
echo -n -s $meta_color " " $git_meta " " $normal_color
else
echo -n -s " "
end
set root_folder (command git rev-parse --show-toplevel 2> /dev/null)
set parent_root_folder (dirname $root_folder)
set cwd (echo $PWD | sed -e "s|$parent_root_folder/||")
else
set cwd (prompt_pwd)
end
echo -n -s $cwd_color "$cwd"
set_color --dim
set -l S (math $CMD_DURATION/1000)
set -l M (math $S/60)
echo -n -s " "
if test $M -gt 1
echo -n -s $M m
else if test $S -gt 1
echo -n -s $S s
else
echo -n -s $CMD_DURATION ms
end
set_color normal

View file

@ -0,0 +1,4 @@
git_is_repo; and begin
command git symbolic-ref --short HEAD 2> /dev/null;
or command git show-ref --head -s --abbrev | head -n1 2> /dev/null
end

View file

@ -0,0 +1 @@
git_is_worktree; and not command git diff --no-ext-diff --quiet --exit-code

View file

@ -0,0 +1,5 @@
test -d .git
or begin
set -l info (command git rev-parse --git-dir --is-bare-repository 2>/dev/null)
and test $info[2] = false
end

View file

@ -0,0 +1,3 @@
git_is_repo; and begin
not command git diff --cached --no-ext-diff --quiet --exit-code
end

View file

@ -0,0 +1,6 @@
git_is_worktree; and begin
# The first checks for staged changes, the second for unstaged ones.
# We put them in this order because checking staged changes is *fast*.
not command git diff-index --cached --quiet HEAD -- >/dev/null 2>&1
or not command git diff --no-ext-diff --quiet --exit-code >/dev/null 2>&1
end

View file

@ -0,0 +1,2 @@
git_is_repo
and test (command git rev-parse --is-inside-git-dir) = false

View file

@ -0,0 +1,30 @@
# Block nesting of nnn in subshells
if test -n "$NNNLVL"
if [ (expr $NNNLVL + 0) -ge 1 ]
exit
return
end
end
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, remove the "-x" as in:
# set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
# NOTE: NNN_TMPFILE is fixed, should not be modified
if test -n "$XDG_CONFIG_HOME"
set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
else
set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
end
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
nnn -T v $argv
if test -e $NNN_TMPFILE
source $NNN_TMPFILE
rm $NNN_TMPFILE
end

View file

@ -0,0 +1 @@
command ssh -o IPQoS=0 $argv;

View file

@ -0,0 +1,22 @@
{ config, pkgs, lib, ... }:
let rootPath = ./.; in
{
options.xonsh = {
enable = lib.mkEnableOption "Enables xonsh";
};
config = lib.mkIf config.xonsh.enable {
home.packages = with pkgs; [
xonsh
];
home.sessionVariables = {
PROMPT = "τ ";
RIGHT_PROMPT = "{YELLOW}{gitstatus: {} }{BLUE}{short_cwd}{DEFAULT}";
VI_MODE = 1;
};
xdg.configFile."xonshrc" = {
source = rootPath + "/rc.xsh";
target = "xonsh/rc.xsh";
};
};
}

View file

@ -0,0 +1,7 @@
#!/usr/bin/env xonsh
if $XONSH_INTERACTIVE:
if '__HM_SESS_VARS_SOURCED' in ${...}:
del $__HM_SESS_VARS_SOURCED
source-bash "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" --suppress-skip-message
cat "$HOME/.cache/wallust/sequences"

View file

@ -0,0 +1,47 @@
{ config, pkgs, lib, ... }:
{
options.zsh = {
enable = lib.mkEnableOption "Enable zsh";
};
config = lib.mkIf config.zsh.enable {
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
dotDir = ".config/zsh";
history.save = 10000;
history.size = 10000;
history.path = "${config.xdg.dataHome}/zsh/history";
initExtra = let
lf = lib.optionalString config.lf.enable ''
# Lf change directory command
lfcd () {
cd "$(command lf -print-last-dir "$@")"
}
bindkey -s '^o' 'lfcd\n'
'';
in lf + ''
# Nix-shell
${pkgs.nix-your-shell}/bin/nix-your-shell zsh | source /dev/stdin
# Prompt
autoload -U colors && colors
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '·*'
zstyle ':vcs_info:*' stagedstr '·+'
zstyle ':vcs_info:git:*' formats '%b%u%c'
export PROMPT="%(0?.%F{white}.%? %F{red})τ%f "
export RPROMPT="%F{yellow}\$vcs_info_msg_0_%f %F{blue}%~%f"
'';
};
};
}

View file

@ -0,0 +1,39 @@
{ config, pkgs, lib, ... }:
{
options.alacritty = {
enable = lib.mkEnableOption "Enables alacritty";
font = lib.mkOption { default = ""; };
font_size = lib.mkOption { default = 18; };
};
config = lib.mkIf config.alacritty.enable {
programs.alacritty.enable = true;
programs.alacritty.settings = {
font = let fam = config.alacritty.font; in {
normal = {
family = fam;
style = "Regular";
};
bold = {
family = fam;
style = "Bold";
};
italic = {
family = fam;
style = "Italic";
};
bold_italic = {
family = fam;
style = "Bold Italic";
};
offset = {
x = 0;
y = 0;
};
size = config.alacritty.font_size;
};
};
};
}

View file

@ -0,0 +1,8 @@
{ config, pkgs, lib, ... }:
{
imports = [
./kitty
./alacritty
];
}

View file

@ -0,0 +1,20 @@
{ config, pkgs, lib, ... }:
{
options.kitty = {
enable = lib.mkEnableOption "Enables kitty";
font = lib.mkOption { default = ""; };
font_size = lib.mkOption { default = 18; };
};
config = lib.mkIf config.kitty.enable {
programs.kitty = {
enable = true;
settings = {
font_family = config.kitty.font;
font_size = config.kitty.font_size;
enable_audio_bell = "no";
};
};
};
}