[fix] *.nix: statix checks

This commit is contained in:
Jalil David Salamé Messina 2024-05-17 18:50:01 +02:00
parent 15a60141ad
commit c19ceb54b7
Signed by: jalil
GPG key ID: F016B9E770737A0B
18 changed files with 728 additions and 626 deletions

View file

@ -36,135 +36,164 @@ in {
config = lib.mkMerge [
(lib.mkIf cfg.enable {
programs.bat = {
programs = {
# Better cat (bat)
enable = true;
config.style = "plain"; # Disable headers and numbers
bat = {
enable = true;
# Disable headers and numbers
config.style = "plain";
};
# Direnv
direnv = {
enable = true;
nix-direnv.enable = true;
};
# ls replacement
eza = {
enable = true;
git = true;
icons = true;
};
# GnuPG
gpg = {
enable = true;
homedir = "${config.xdg.dataHome}/gnupg";
};
# Mail client
himalaya.enable = true;
# Another shell
nushell.enable = true;
# Password manager
password-store = {
enable = 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;
};
};
# Direnv
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
# ls replacement
programs.eza.enable = true;
programs.eza.git = true;
programs.eza.icons = true;
# GnuPG
programs.gpg.enable = true;
programs.gpg.homedir = "${config.xdg.dataHome}/gnupg";
# Mail client
programs.himalaya.enable = true;
# Another shell
programs.nushell.enable = true;
# Password manager
programs.password-store.enable = true;
programs.password-store.package = pkgs.pass-nodmenu;
programs.password-store.settings.PASSWORD_STORE_DIR = "${config.xdg.dataHome}/pass";
# SSH
programs.ssh.enable = true;
# cd replacement
programs.zoxide.enable = true;
# Shell
programs.zsh.enable = true;
programs.zsh.autosuggestion.enable = true;
programs.zsh.enableCompletion = true;
programs.zsh.autocd = true;
programs.zsh.dotDir = ".config/zsh";
programs.zsh.history.path = "${config.xdg.dataHome}/zsh/zsh_history";
programs.zsh.syntaxHighlighting.enable = true;
# GPG Agent
services.gpg-agent.enable = true;
services.gpg-agent.maxCacheTtl = 86400;
services.gpg-agent.pinentryPackage =
if config.jhome.gui.enable
then pkgs.pinentry-qt
else pkgs.pinentry-curses;
services.gpg-agent.extraConfig = "allow-preset-passphrase";
# Spotifyd
services.spotifyd.enable = true;
services.spotifyd.settings.global.device_name = config.jhome.hostName;
services.spotifyd.settings.global.device_type = "computer";
services.spotifyd.settings.global.backend = "pulseaudio";
services.spotifyd.settings.global.zeroconf_port = 2020;
home.stateVersion = "22.11";
# Extra packages
home.packages = [
pkgs.gopass
pkgs.sshfs
pkgs.gitoxide
pkgs.xplr
];
# Extra variables
home.sessionVariables = {
CARGO_HOME = "${config.xdg.dataHome}/cargo";
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
GOPATH = "${config.xdg.dataHome}/go";
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.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";
home = {
stateVersion = "22.11";
# Extra packages
packages = [
pkgs.gopass
pkgs.sshfs
pkgs.gitoxide
pkgs.xplr
];
# 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;
xdg.userDirs.enable = true;
xdg.userDirs.createDirectories = true;
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;
programs.gh-dash.enable = true;
# Git
programs.git = {
enable = true;
difftastic.enable = true;
difftastic.background = "dark";
lfs.enable = true;
# Add diff to the commit message editor
extraConfig.commit.verbose = true;
# Improve submodule diff
extraConfig.diff.submodule = "log";
# Set the default branch name for new branches
extraConfig.init.defaultBranch = "main";
# Better conflicts (also shows parent commit state)
extraConfig.merge.conflictStyle = "zdiff3";
# Do not create merge commits when pulling (rebase but abort on conflict)
extraConfig.pull.ff = "only";
# Use `--set-upstream` if the remote does not have the branch
extraConfig.push.autoSetupRemote = true;
# If there are uncommitted changes, stash them before rebasing
extraConfig.rebase.autoStash = true;
# If there are fixup! commits, squash them while rebasing
extraConfig.rebase.autoSquash = true;
# Enable ReReRe (Reuse Recovered Resolution) auto resolve previously resolved conflicts
extraConfig.rerere.enabled = true;
# Improve submodule status
extraConfig.status.submoduleSummary = true;
};
programs.lazygit.enable = true;
# Jujutsu (alternative DVCS (git-compatible))
programs.jujutsu = {
enable = true;
settings = {
ui.pager = "bat";
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;
settings = {
ui.pager = "bat";
};
};
};
})

View file

@ -36,80 +36,84 @@ in {
++ lib.optional flatpakEnabled flatpak;
fonts.fontconfig.enable = true;
# Browser
programs.firefox.enable = true;
# Dynamic Menu
programs.fuzzel = {
enable = true;
settings.main = {
icon-theme = "Papirus-Dark";
terminal = cfg.terminal;
programs = {
firefox.enable = true;
# Dynamic Menu
fuzzel = {
enable = true;
settings.main = {
icon-theme = "Papirus-Dark";
inherit (cfg) terminal;
layer = "overlay";
};
};
# Video player
mpv = {
enable = true;
scripts = builtins.attrValues {inherit (pkgs.mpvScripts) uosc thumbfast;};
};
# Status bar
waybar = {
enable = true;
systemd.enable = true;
settings = import ./waybar-settings.nix {inherit config lib;};
style = ''
.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 = ''
config = {}
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";
zellij.enable = cfg.terminal == "alacritty"; # alacritty has no terminal multiplexerr built in
# PDF reader
zathura.enable = true;
# Auto start sway
zsh.loginExtra = lib.optionalString cfg.sway.autostart ''
# 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;
};
};
# Video player
programs.mpv = {
enable = true;
scripts = builtins.attrValues {inherit (pkgs.mpvScripts) uosc thumbfast;};
};
# Status bar
programs.waybar = {
enable = true;
systemd.enable = true;
settings = import ./waybar-settings.nix {inherit config lib;};
style = ''
.modules-left #workspaces button {
border-bottom: 3px solid @base01;
}
.modules-left #workspaces button.persistent {
border-bottom: 3px solid transparent;
}
'';
};
# Terminal
programs.wezterm = {
enable = cfg.terminal == "wezterm";
extraConfig = ''
config = {}
config.hide_tab_bar_if_only_one_tab = true
config.window_padding = { left = 1, right = 1, top = 1, bottom = 1 }
return config
'';
};
programs.alacritty.enable = cfg.terminal == "alacritty";
programs.zellij.enable = cfg.terminal == "alacritty"; # alacritty has no terminal multiplexerr built in
# PDF reader
programs.zathura.enable = true;
# Auto start sway
programs.zsh.loginExtra = lib.optionalString cfg.sway.autostart ''
# Start Sway on login to TTY 1
if [ "$TTY" = /dev/tty1 ]; then
exec sway
fi
'';
# Volume/Backlight control and notifications
services.avizo = {
enable = true;
settings.default = {
time = 0.8;
border-width = 0;
height = 176;
y-offset = 0.1;
block-spacing = 1;
};
};
# Sound tuning
services.easyeffects.enable = true;
# Auto configure displays
services.kanshi.enable = lib.mkDefault true;
# Notifications
services.mako = {
enable = true;
layer = "overlay";
borderRadius = 8;
defaultTimeout = 15000;
};
# Window Manager
wayland.windowManager.sway = {
enable = true;
@ -123,7 +127,7 @@ in {
# Set Gtk theme
gtk = {
enable = true;
iconTheme = iconTheme;
inherit iconTheme;
gtk3.extraConfig.gtk-application-prefer-dark-theme = 1;
gtk4.extraConfig.gtk-application-prefer-dark-theme = 1;
};

View file

@ -4,7 +4,7 @@
}: let
cfg = config.jhome.gui.sway;
modifier = "Mod4";
terminal = config.jhome.gui.terminal;
inherit (config.jhome.gui) terminal;
termCmd =
if terminal == "wezterm"
then "wezterm start"

View file

@ -4,103 +4,96 @@
}: let
cfg = config.jhome.gui;
in {
mainBar.layer = "top";
mainBar.position = "top";
mainBar.margin = "2 2 2 2";
# Choose the order of the modules
mainBar.modules-left = ["sway/workspaces"];
mainBar.modules-center = ["clock"];
mainBar.modules-right =
[
"pulseaudio"
"backlight"
"battery"
"sway/language"
"memory"
]
++ lib.optional (cfg.tempInfo != null) "temperature"
++ ["tray"];
mainBar."sway/workspaces".disable-scroll = true;
mainBar."sway/workspaces".persistent-workspaces."1" = [];
mainBar."sway/workspaces".persistent-workspaces."2" = [];
mainBar."sway/workspaces".persistent-workspaces."3" = [];
mainBar."sway/workspaces".persistent-workspaces."4" = [];
mainBar."sway/workspaces".persistent-workspaces."5" = [];
mainBar."sway/workspaces".persistent-workspaces."6" = [];
mainBar."sway/workspaces".persistent-workspaces."7" = [];
mainBar."sway/workspaces".persistent-workspaces."8" = [];
mainBar."sway/workspaces".persistent-workspaces."9" = [];
mainBar."sway/language".format = "{} ";
mainBar."sway/language".min-length = 5;
mainBar."sway/language".tooltip = false;
mainBar.memory.format = "{used:0.1f}/{total:0.1f}GiB ";
mainBar.memory.interval = 3;
mainBar.clock.timezone = "Europe/Berlin";
mainBar.clock.tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
mainBar.clock.format = "{:%a, %d %b, %H:%M}";
mainBar.pulseaudio.reverse-scrolling = 1;
mainBar.pulseaudio.format = "{volume}% {icon} {format_source}";
mainBar.pulseaudio.format-bluetooth = "{volume}% {icon} {format_source}";
mainBar.pulseaudio.format-bluetooth-muted = "{volume}% 󰖁 {icon} {format_source}";
mainBar.pulseaudio.format-muted = "{volume}% 󰖁 {format_source}";
mainBar.pulseaudio.format-source = "{volume}% ";
mainBar.pulseaudio.format-source-muted = "{volume}% 󰍭";
mainBar.pulseaudio.format-icons.headphone = "󰋋";
mainBar.pulseaudio.format-icons.hands-free = "";
mainBar.pulseaudio.format-icons.headset = "󰋎";
mainBar.pulseaudio.format-icons.phone = "󰘂";
mainBar.pulseaudio.format-icons.portable = "";
mainBar.pulseaudio.format-icons.car = "";
mainBar.pulseaudio.format-icons.default = [
"󰕿"
"󰖀"
"󰕾"
];
mainBar.pulseaudio.on-click = "pavucontrol";
mainBar.pulseaudio.min-length = 13;
mainBar.temperature = lib.optionalAttrs (cfg.tempInfo != null) {
inherit (cfg.tempInfo) hwmon-path;
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [
""
""
""
""
""
];
tooltip = false;
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;
};
};
mainBar.backlight.device = "intel_backlight";
mainBar.backlight.format = "{percent}% {icon}";
mainBar.backlight.format-icons = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
mainBar.backlight.min-length = 7;
mainBar.battery.states.warning = 30;
mainBar.battery.states.critical = 15;
mainBar.battery.format = "{capacity}% {icon}";
mainBar.battery.format-charging = "{capacity}% 󰂄";
mainBar.battery.format-plugged = "{capacity}% 󰚥";
mainBar.battery.format-alt = "{time} {icon}";
mainBar.battery.format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
mainBar.tray.icon-size = 16;
mainBar.tray.spacing = 0;
}

View file

@ -155,28 +155,30 @@ in {
description = "Setup development environment for programming languages.";
default = {};
type = types.submodule {
options.enable = lib.mkEnableOption "development settings";
options.neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
options.extraPackages = mkExtraPackagesOption "dev" [
["jq"] # json parser
["just"] # just a command runner
["typos"] # low false positive rate typo checker
["git-absorb"] # fixup! but automatic
["man-pages"] # gimme the man pages
["man-pages-posix"] # I said gimme the man pages!!!
];
options.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-kcov"] # code coverage
["cargo-msrv"] # minimum supported version
["cargo-nextest"] # better testing harness
["cargo-sort"] # sort deps and imports
["cargo-watch"] # watch for file changes and run commands
];
options = {
enable = lib.mkEnableOption "development settings";
neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
extraPackages = mkExtraPackagesOption "dev" [
["jq"] # json parser
["just"] # just a command runner
["typos"] # low false positive rate typo checker
["git-absorb"] # fixup! but automatic
["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-kcov"] # code coverage
["cargo-msrv"] # minimum supported version
["cargo-nextest"] # better testing harness
["cargo-sort"] # sort deps and imports
["cargo-watch"] # watch for file changes and run commands
];
};
};
};
};