From c19ceb54b794586fffec286af51e74d539ad1d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 17 May 2024 18:50:01 +0200 Subject: [PATCH] [fix] *.nix: statix checks --- flake.nix | 53 ++-- home/default.nix | 263 ++++++++++-------- home/gui/default.nix | 146 +++++----- home/gui/sway-config.nix | 2 +- home/gui/waybar-settings.nix | 189 ++++++------- home/options.nix | 46 +-- machines/capricorn/default.nix | 53 ++-- machines/capricorn/hardware-configuration.nix | 58 ++-- machines/gemini/default.nix | 56 ++-- machines/gemini/hardware-configuration.nix | 74 ++--- machines/libra/default.nix | 72 ++--- machines/libra/hardware-configuration.nix | 60 ++-- machines/vm/default.nix | 2 +- nvim/augroups.nix | 8 +- nvim/nixvim.nix | 13 +- system/default.nix | 76 ++--- system/gui/default.nix | 125 +++++---- system/stylix-config.nix | 58 ++-- 18 files changed, 728 insertions(+), 626 deletions(-) diff --git a/flake.nix b/flake.nix index 5eeecd9..53c16f1 100644 --- a/flake.nix +++ b/flake.nix @@ -210,28 +210,31 @@ { time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "en_US.UTF-8"; - - users.users.jdoe.password = "example"; - users.users.jdoe.isNormalUser = true; - users.users.jdoe.extraGroups = [ - "wheel" - "video" - "networkmanager" - ]; - - home-manager.users.jdoe = { - home.username = "jdoe"; - home.homeDirectory = "/home/jdoe"; - - jhome.enable = true; - jhome.gui.enable = true; - jhome.dev.rust.enable = true; + users.users.jdoe = { + password = "example"; + isNormalUser = true; + extraGroups = [ + "wheel" + "video" + "networkmanager" + ]; + }; + home-manager.users.jdoe = { + home = { + username = "jdoe"; + homeDirectory = "/home/jdoe"; + }; + jhome = { + enable = true; + gui.enable = true; + dev.rust.enable = true; + }; }; - nix.registry.nixpkgs.flake = nixpkgs; - - jconfig.enable = true; - jconfig.gui.enable = true; + jconfig = { + enable = true; + gui.enable = true; + }; } ]; }; @@ -251,11 +254,11 @@ home-manager.nixosModules.home-manager ] ++ nixpkgs.lib.optional (lix != null && lix-module != null) lix-module.nixosModules.default; - - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = [homeManagerModuleNixOS]; - + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [homeManagerModuleNixOS]; + }; # Pin nixpkgs nix.registry.nixpkgs.flake = nixpkgs; }; diff --git a/home/default.nix b/home/default.nix index 14ffc99..10c5fff 100644 --- a/home/default.nix +++ b/home/default.nix @@ -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"; + }; }; }; }) diff --git a/home/gui/default.nix b/home/gui/default.nix index 5b28e8b..47fc172 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -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; }; diff --git a/home/gui/sway-config.nix b/home/gui/sway-config.nix index c3d48f6..1302086 100644 --- a/home/gui/sway-config.nix +++ b/home/gui/sway-config.nix @@ -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" diff --git a/home/gui/waybar-settings.nix b/home/gui/waybar-settings.nix index b2a0968..24d4a9c 100644 --- a/home/gui/waybar-settings.nix +++ b/home/gui/waybar-settings.nix @@ -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 = "{:%Y %B}\n{calendar}"; - 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 = "{:%Y %B}\n{calendar}"; + 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; } diff --git a/home/options.nix b/home/options.nix index 4b85acb..fe21d7a 100644 --- a/home/options.nix +++ b/home/options.nix @@ -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 + ]; + }; }; }; }; diff --git a/machines/capricorn/default.nix b/machines/capricorn/default.nix index 1960898..67afc47 100644 --- a/machines/capricorn/default.nix +++ b/machines/capricorn/default.nix @@ -7,32 +7,39 @@ nixos-hardware.nixosModules.common-pc-laptop-ssd nixos-hardware.nixosModules.common-cpu-intel ]; - - # Setup extra filesystem options - fileSystems."/".options = ["compress=zstd"]; - fileSystems."/home".options = ["compress=zstd"]; - fileSystems."/nix".options = [ - "compress=zstd" - "noatime" - ]; + fileSystems = { + # Setup extra filesystem options + "/".options = ["compress=zstd"]; + "/home".options = ["compress=zstd"]; + "/nix".options = [ + "compress=zstd" + "noatime" + ]; + }; hardware.bluetooth.enable = true; - - # Bootloader - boot.loader.systemd-boot.enable = true; - boot.loader.systemd-boot.configurationLimit = 10; - boot.loader.efi.canTouchEfiVariables = true; - + boot.loader = { + # Bootloader + systemd-boot = { + enable = true; + configurationLimit = 10; + }; + efi.canTouchEfiVariables = true; + }; # Network configuration - networking.hostName = "capricorn"; - networking.networkmanager.enable = true; - networking.networkmanager.wifi.backend = "iwd"; - networking.networkmanager.appendNameservers = [ - "1.1.1.1" - "1.0.0.1" - "8.8.8.8" - "8.4.4.8" - ]; + networking = { + hostName = "capricorn"; + networkmanager = { + enable = true; + wifi.backend = "iwd"; + appendNameservers = [ + "1.1.1.1" + "1.0.0.1" + "8.8.8.8" + "8.4.4.8" + ]; + }; + }; console.useXkbConfig = true; diff --git a/machines/capricorn/hardware-configuration.nix b/machines/capricorn/hardware-configuration.nix index c622743..f7ecf9d 100644 --- a/machines/capricorn/hardware-configuration.nix +++ b/machines/capricorn/hardware-configuration.nix @@ -8,37 +8,41 @@ ... }: { imports = [(modulesPath + "/installer/scan/not-detected.nix")]; - - boot.initrd.availableKernelModules = [ - "xhci_pci" - "ahci" - "usb_storage" - "sd_mod" - ]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-intel"]; - boot.extraModulePackages = []; - - fileSystems."/" = { - device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = ["subvol=root"]; + boot = { + initrd = { + availableKernelModules = [ + "xhci_pci" + "ahci" + "usb_storage" + "sd_mod" + ]; + kernelModules = []; + }; + kernelModules = ["kvm-intel"]; + extraModulePackages = []; }; + fileSystems = { + "/" = { + device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = ["subvol=root"]; + }; - fileSystems."/nix" = { - device = "/dev/disk/by-label/NIXROOT"; - fsType = "btrfs"; - options = ["subvol=nix"]; - }; + "/nix" = { + device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = ["subvol=nix"]; + }; - fileSystems."/home" = { - device = "/dev/disk/by-label/NIXHOME"; - fsType = "btrfs"; - }; + "/home" = { + device = "/dev/disk/by-label/NIXHOME"; + fsType = "btrfs"; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-label/NIXBOOT"; - fsType = "vfat"; + "/boot" = { + device = "/dev/disk/by-label/NIXBOOT"; + fsType = "vfat"; + }; }; swapDevices = [{device = "/dev/disk/by-label/NIXSWAP";}]; diff --git a/machines/gemini/default.nix b/machines/gemini/default.nix index 55f6968..d4680b6 100644 --- a/machines/gemini/default.nix +++ b/machines/gemini/default.nix @@ -11,40 +11,46 @@ nixos-hardware.nixosModules.common-cpu-amd nixos-hardware.nixosModules.common-gpu-amd ]; - - fileSystems."/".options = ["compress=zstd"]; - fileSystems."/steam".options = ["compress=zstd"]; - fileSystems."/home".options = ["compress=zstd"]; - fileSystems."/nix".options = [ - "compress=zstd" - "noatime" - ]; - - # Use the systemd-boot EFI boot loader. - boot.loader.systemd-boot.enable = true; - boot.loader.systemd-boot.configurationLimit = 3; - boot.loader.efi.canTouchEfiVariables = true; + fileSystems = { + "/".options = ["compress=zstd"]; + "/steam".options = ["compress=zstd"]; + "/home".options = ["compress=zstd"]; + "/nix".options = [ + "compress=zstd" + "noatime" + ]; + }; + boot.loader = { + systemd-boot = { + # Use the systemd-boot EFI boot loader. + enable = true; + configurationLimit = 3; + }; + efi.canTouchEfiVariables = true; + }; # Enable bluetooth hardware.bluetooth.enable = true; - - networking.hostName = "gemini"; - networking.networkmanager.enable = true; - networking.interfaces.enp4s0.wakeOnLan.enable = true; + networking = { + hostName = "gemini"; + networkmanager.enable = true; + interfaces.enp4s0.wakeOnLan.enable = true; + }; console = { # font = "Lat2-Terminus16"; # keyMap = "us"; useXkbConfig = true; # use xkbOptions in tty. }; - - # Configure keymap in X11 - # services.xserver.xkbOptions = { - # "caps:swapescape" # map caps to escape. - # }; - services.openssh.enable = true; - services.openssh.startWhenNeeded = true; - services.openssh.settings.AllowUsers = ["jalil"]; + services.openssh = { + # Configure keymap in X11 + # services.xserver.xkbOptions = { + # "caps:swapescape" # map caps to escape. + # }; + enable = true; + startWhenNeeded = true; + settings.AllowUsers = ["jalil"]; + }; # Enable CUPS to print documents. services.printing.enable = true; diff --git a/machines/gemini/hardware-configuration.nix b/machines/gemini/hardware-configuration.nix index 4482eba..045b0e4 100644 --- a/machines/gemini/hardware-configuration.nix +++ b/machines/gemini/hardware-configuration.nix @@ -8,46 +8,50 @@ ... }: { imports = [(modulesPath + "/installer/scan/not-detected.nix")]; - - boot.initrd.availableKernelModules = [ - "nvme" - "xhci_pci" - "ahci" - "usbhid" - "usb_storage" - "sd_mod" - ]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-amd"]; - boot.extraModulePackages = []; - - fileSystems."/" = { - # device = "/dev/disk/by-label/NIXOSROOT"; - device = "/dev/disk/by-label/NIXOSHOME"; - fsType = "btrfs"; - options = ["subvol=root"]; + boot = { + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + kernelModules = []; + }; + kernelModules = ["kvm-amd"]; + extraModulePackages = []; }; + fileSystems = { + "/" = { + # device = "/dev/disk/by-label/NIXOSROOT"; + device = "/dev/disk/by-label/NIXOSHOME"; + fsType = "btrfs"; + options = ["subvol=root"]; + }; - fileSystems."/steam" = { - device = "/dev/disk/by-label/STEAM"; - fsType = "btrfs"; - }; + "/steam" = { + device = "/dev/disk/by-label/STEAM"; + fsType = "btrfs"; + }; - fileSystems."/home" = { - device = "/dev/disk/by-label/NIXOSHOME"; - fsType = "btrfs"; - options = ["subvol=home"]; - }; + "/home" = { + device = "/dev/disk/by-label/NIXOSHOME"; + fsType = "btrfs"; + options = ["subvol=home"]; + }; - fileSystems."/nix" = { - device = "/dev/disk/by-label/NIXOSROOT"; - fsType = "btrfs"; - options = ["subvol=nix"]; - }; + "/nix" = { + device = "/dev/disk/by-label/NIXOSROOT"; + fsType = "btrfs"; + options = ["subvol=nix"]; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-label/BOOT"; - fsType = "vfat"; + "/boot" = { + device = "/dev/disk/by-label/BOOT"; + fsType = "vfat"; + }; }; swapDevices = [{device = "/dev/disk/by-label/SWAP";}]; diff --git a/machines/libra/default.nix b/machines/libra/default.nix index 3a16dd2..e4d4972 100644 --- a/machines/libra/default.nix +++ b/machines/libra/default.nix @@ -20,39 +20,49 @@ "noatime" ]; }; + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernelParams = ["amdgpu.dcdebugmask=0x10"]; + loader = { + # Use the systemd-boot EFI boot loader. + timeout = 0; # Press Space to show the menu + efi.canTouchEfiVariables = true; + systemd-boot.enable = true; + systemd-boot.configurationLimit = 10; + }; + }; + # Fixes graphical issues + hardware = { + opengl.enable = true; + bluetooth.enable = true; + tuxedo-rs = { + enable = true; + tailor-gui.enable = true; + }; + }; + networking = { + hostName = "libra"; + networkmanager = { + enable = true; # Easiest to use and most distros use this by default. + # networking.networkmanager.wifi.backend = "iwd"; # Seems to cause problems + appendNameservers = [ + "1.1.1.1" + "1.0.0.1" + "8.8.8.8" + "8.4.4.8" + ]; + }; + }; - boot.kernelPackages = pkgs.linuxPackages_latest; - boot.kernelParams = ["amdgpu.dcdebugmask=0x10"]; # Fixes graphical issues + # use xkb.options in tty. + console.useXkbConfig = true; + services = { + # Enable CUPS to print documents. + printing.enable = true; - hardware.opengl.enable = true; - hardware.bluetooth.enable = true; - hardware.tuxedo-rs.enable = true; - hardware.tuxedo-rs.tailor-gui.enable = true; - - # Use the systemd-boot EFI boot loader. - boot.loader.timeout = 0; # Press Space to show the menu - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.systemd-boot.enable = true; - boot.loader.systemd-boot.configurationLimit = 10; - - networking.hostName = "libra"; - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. - # networking.networkmanager.wifi.backend = "iwd"; # Seems to cause problems - networking.networkmanager.appendNameservers = [ - "1.1.1.1" - "1.0.0.1" - "8.8.8.8" - "8.4.4.8" - ]; - - # Select internationalisation properties. - console.useXkbConfig = true; # use xkb.options in tty. - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable the OpenSSH daemon. - services.openssh.enable = true; + # Enable the OpenSSH daemon. + openssh.enable = true; + }; # This option defines the first version of NixOS you have installed on this particular machine, # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. diff --git a/machines/libra/hardware-configuration.nix b/machines/libra/hardware-configuration.nix index cd5d174..928cbbe 100644 --- a/machines/libra/hardware-configuration.nix +++ b/machines/libra/hardware-configuration.nix @@ -9,38 +9,42 @@ ... }: { imports = [(modulesPath + "/installer/scan/not-detected.nix")]; - - boot.initrd.availableKernelModules = [ - "nvme" - "xhci_pci" - "usb_storage" - "sd_mod" - ]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-amd"]; - boot.extraModulePackages = []; - - fileSystems."/" = { - device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; - fsType = "btrfs"; - options = ["subvol=root"]; + boot = { + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "usb_storage" + "sd_mod" + ]; + kernelModules = []; + }; + kernelModules = ["kvm-amd"]; + extraModulePackages = []; }; + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; + fsType = "btrfs"; + options = ["subvol=root"]; + }; - fileSystems."/home" = { - device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; - fsType = "btrfs"; - options = ["subvol=home"]; - }; + "/home" = { + device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; + fsType = "btrfs"; + options = ["subvol=home"]; + }; - fileSystems."/nix" = { - device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; - fsType = "btrfs"; - options = ["subvol=nix"]; - }; + "/nix" = { + device = "/dev/disk/by-uuid/efbda7f0-c286-4fb1-b780-d3128e4d1a3e"; + fsType = "btrfs"; + options = ["subvol=nix"]; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/4E80-8B60"; - fsType = "vfat"; + "/boot" = { + device = "/dev/disk/by-uuid/4E80-8B60"; + fsType = "vfat"; + }; }; swapDevices = []; diff --git a/machines/vm/default.nix b/machines/vm/default.nix index b50326b..e9c6397 100644 --- a/machines/vm/default.nix +++ b/machines/vm/default.nix @@ -1,4 +1,4 @@ -{...}: { +_: { services.qemuGuest.enable = true; boot.initrd.availableKernelModules = [ diff --git a/nvim/augroups.nix b/nvim/augroups.nix index 1f8b4ca..868fb20 100644 --- a/nvim/augroups.nix +++ b/nvim/augroups.nix @@ -1,7 +1,9 @@ { - autoGroups."highlightOnYank" = {}; - autoGroups."lspConfig" = {}; - autoGroups."restoreCursorPosition" = {}; + autoGroups = { + "highlightOnYank" = {}; + "lspConfig" = {}; + "restoreCursorPosition" = {}; + }; autoCmd = [ { group = "highlightOnYank"; diff --git a/nvim/nixvim.nix b/nvim/nixvim.nix index fc4b86d..bbac212 100644 --- a/nvim/nixvim.nix +++ b/nvim/nixvim.nix @@ -20,12 +20,15 @@ in { package = pkgs.neovim; globals.mapleader = " "; # Appearance - colorschemes = { - gruvbox.enable = true; - gruvbox.settings.bold = true; - gruvbox.settings.transparent_mode = true; - gruvbox.settings.terminal_colors = true; + colorschemes.gruvbox = { + enable = true; + settings = { + bold = true; + transparent_mode = true; + terminal_colors = true; + }; }; + opts = { number = true; relativenumber = true; diff --git a/system/default.nix b/system/default.nix index 05d6e6f..6ff101b 100644 --- a/system/default.nix +++ b/system/default.nix @@ -51,20 +51,29 @@ in { # Enable dev documentation documentation.dev.enable = cfg.dev.enable; - - # Shell prompt - programs.starship.enable = true; - programs.starship.settings = lib.mkIf cfg.styling.enable { - format = "$time$all"; - add_newline = false; - cmd_duration.min_time = 500; - cmd_duration.show_milliseconds = true; - time.format = "[$time](bold yellow) "; - time.disabled = false; - status.format = "[$signal_name$common_meaning$maybe_int](red)"; - status.symbol = "[✗](bold red)"; - status.disabled = false; - sudo.disabled = false; + programs = { + # Shell prompt + starship = { + enable = true; + settings = lib.mkIf cfg.styling.enable { + format = "$time$all"; + add_newline = false; + cmd_duration.min_time = 500; + cmd_duration.show_milliseconds = true; + time = { + format = "[$time](bold yellow) "; + disabled = false; + }; + status = { + format = "[$signal_name$common_meaning$maybe_int](red)"; + symbol = "[✗](bold red)"; + disabled = false; + }; + sudo.disabled = false; + }; + }; + # Default shell + zsh.enable = true; }; environment.etc = keysFromGithub; @@ -74,29 +83,32 @@ in { # Enable printer autodiscovery if printing is enabled services.avahi = { - enable = config.services.printing.enable; + inherit (config.services.printing) enable; nssmdns4 = true; openFirewall = true; }; - - # Default shell - programs.zsh.enable = true; users.defaultUserShell = pkgs.zsh; - # Open ports for spotifyd - networking.firewall.allowedUDPPorts = [5353]; - networking.firewall.allowedTCPPorts = [2020]; - + networking.firewall = { + allowedUDPPorts = [5353]; + allowedTCPPorts = [2020]; + }; # Nix Settings - nix.gc.automatic = true; - nix.gc.dates = "weekly"; - nix.gc.options = "--delete-older-than 30d"; - # run between 0 and 45min after boot if run was missed - nix.gc.randomizedDelaySec = "45min"; - nix.settings.auto-optimise-store = true; - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; + 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 = { + auto-optimise-store = true; + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + }; }; } diff --git a/system/gui/default.nix b/system/gui/default.nix index 9f8723f..7163712 100644 --- a/system/gui/default.nix +++ b/system/gui/default.nix @@ -17,65 +17,80 @@ in { 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; + 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" + ''; }; - # Fix xdg-portals issue issue: https://github.com/NixOS/nixpkgs/issues/189851 - systemd.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; - - programs.sway.enable = cfg.sway; - programs.sway.extraPackages = []; # No extra packages (by default it adds foot, dmenu, and other stuff) - programs.sway.wrapperFeatures.base = true; - programs.sway.wrapperFeatures.gtk = true; - - security.polkit.enable = true; - security.rtkit.enable = true; # Recommended for pipewire - - services.flatpak.enable = true; - # Audio - services.pipewire.enable = true; - services.pipewire.alsa.enable = true; - services.pipewire.alsa.support32Bit = true; - services.pipewire.pulse.enable = true; - services.pipewire.wireplumber.enable = true; - # Dbus - services.dbus.enable = true; - - # XDG portals - xdg.portal.enable = true; - xdg.portal.wlr.enable = true; - xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk]; - # Default to the gtk portal - xdg.portal.config.preferred.default = "gtk"; - # Use wlr for screenshots and screen recording - xdg.portal.config.preferred."org.freedesktop.impl.portal.Screenshot" = "wlr"; - xdg.portal.config.preferred."org.freedesktop.impl.portal.ScreenCast" = "wlr"; - # Consider using darkman like upstream - - hardware.opengl.enable = true; - hardware.uinput.enable = true; - hardware.steam-hardware.enable = cfg.steamHardwareSupport; + 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; + }; + 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 = { + opengl.enable = true; + uinput.enable = true; + steam-hardware.enable = cfg.steamHardwareSupport; + }; }) (lib.mkIf (enable && cfg."8bitdoFix") { # Udev rules to start or stop systemd service when controller is connected or disconnected diff --git a/system/stylix-config.nix b/system/stylix-config.nix index f15c672..76792eb 100644 --- a/system/stylix-config.nix +++ b/system/stylix-config.nix @@ -13,32 +13,36 @@ in { image = cfg.wallpaper; base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; polarity = "dark"; - fonts.monospace = [ - { - name = "JetBrains Mono"; - package = pkgs.jetbrains-mono; - } - fallbackSymbols - ]; - fonts.sansSerif = [ - { - name = "Noto Sans"; - package = pkgs.noto-fonts; - } - fallbackSymbols - ]; - fonts.serif = [ - { - name = "Noto Serif"; - package = pkgs.noto-fonts; - } - fallbackSymbols - ]; - fonts.emoji = { - package = pkgs.noto-fonts-emoji; - name = "Noto Color Emoji"; + fonts = { + monospace = [ + { + name = "JetBrains Mono"; + package = pkgs.jetbrains-mono; + } + fallbackSymbols + ]; + sansSerif = [ + { + name = "Noto Sans"; + package = pkgs.noto-fonts; + } + fallbackSymbols + ]; + serif = [ + { + name = "Noto Serif"; + package = pkgs.noto-fonts; + } + fallbackSymbols + ]; + emoji = { + package = pkgs.noto-fonts-emoji; + name = "Noto Color Emoji"; + }; + sizes.popups = 12; + }; + targets.plymouth = { + logoAnimated = false; + logo = cfg.bootLogo; }; - fonts.sizes.popups = 12; - targets.plymouth.logoAnimated = false; - targets.plymouth.logo = cfg.bootLogo; }