From 127227205da48a9ea4b7aecb20169693dd451bf1 Mon Sep 17 00:00:00 2001 From: Semere Meharena Mebrahtom Date: Sun, 19 Jul 2026 16:08:17 +0200 Subject: [PATCH] reorganization into flat profile-based modules --- flake.nix | 5 +- hosts/nabro/default.nix | 13 +- modules/cli-tools.nix | 18 +++ modules/core.nix | 87 ++++++-------- modules/default.nix | 53 ++++++--- modules/desktop.nix | 223 +++++++++++++++++----------------- modules/dev.nix | 35 ++---- modules/git.nix | 27 +++++ modules/gpg.nix | 24 ++++ modules/helix.nix | 146 +++++++++++++++++++++++ modules/shell/default.nix | 66 ----------- modules/shell/helix.nix | 155 ------------------------ modules/shell/zsh.nix | 243 -------------------------------------- modules/user.nix | 29 ++--- modules/zsh.nix | 232 ++++++++++++++++++++++++++++++++++++ 15 files changed, 660 insertions(+), 696 deletions(-) create mode 100644 modules/cli-tools.nix create mode 100644 modules/git.nix create mode 100644 modules/gpg.nix create mode 100644 modules/helix.nix delete mode 100644 modules/shell/default.nix delete mode 100644 modules/shell/helix.nix delete mode 100644 modules/shell/zsh.nix create mode 100644 modules/zsh.nix diff --git a/flake.nix b/flake.nix index c56f93f..78d1555 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ in lib.nixosSystem { system = hostConfig.system; - specialArgs = { inherit userVars; }; + specialArgs = { inherit userVars self; }; modules = [ hostConfig.configModule ] @@ -45,7 +45,7 @@ home-manager = { useGlobalPkgs = true; useUserPackages = true; - extraSpecialArgs = { inherit userVars; }; + extraSpecialArgs = { inherit userVars self; }; backupFileExtension = "backup"; }; } @@ -55,5 +55,6 @@ in { inherit nixosConfigurations; + nixosModules = import ./modules { inherit lib self; }; }; } diff --git a/hosts/nabro/default.nix b/hosts/nabro/default.nix index 88ecb4b..ab14cc2 100644 --- a/hosts/nabro/default.nix +++ b/hosts/nabro/default.nix @@ -5,24 +5,15 @@ config, lib, pkgs, + self, ... }: { imports = [ ./hardware-configuration.nix - ../../modules + self.nixosModules.desktop-suite ]; networking.hostName = "nabro"; - - dotfiles = { - core.enable = true; - user.enable = true; - desktop.enable = true; - dev.enable = true; - shell.enable = true; - zsh.enable = true; - helix.enable = true; - }; }; } diff --git a/modules/cli-tools.nix b/modules/cli-tools.nix new file mode 100644 index 0000000..9ee629a --- /dev/null +++ b/modules/cli-tools.nix @@ -0,0 +1,18 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + environment.systemPackages = with pkgs; [ + wget + tealdeer + p7zip + btop + opencode + fd + ripgrep + ]; +} diff --git a/modules/core.nix b/modules/core.nix index 8eb1eeb..8017ebd 100644 --- a/modules/core.nix +++ b/modules/core.nix @@ -5,60 +5,51 @@ ... }: -let - cfg = config.dotfiles.core; -in { - options.dotfiles.core = { - enable = lib.mkEnableOption "Core system configuration"; - }; + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.consoleLogLevel = 0; + boot.initrd.verbose = false; + boot.kernelParams = [ + "quiet" + "splash" + "boot.shell_on_fail" + "loglevel=3" + "rd.systemd.show_status=false" + "rd.udev.log_level=3" + "udev.log_priority=3" + ]; - config = lib.mkIf cfg.enable { - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.kernelPackages = pkgs.linuxPackages_latest; - boot.consoleLogLevel = 0; - boot.initrd.verbose = false; - boot.kernelParams = [ - "quiet" - "splash" - "boot.shell_on_fail" - "loglevel=3" - "rd.systemd.show_status=false" - "rd.udev.log_level=3" - "udev.log_priority=3" - ]; + time.timeZone = "Europe/Berlin"; - time.timeZone = "Europe/Berlin"; + networking.networkmanager.enable = true; - networking.networkmanager.enable = true; + services.power-profiles-daemon.enable = true; - services.power-profiles-daemon.enable = true; - - services.logind = { - settings = { - Login = { - HandleLidSwitch = "suspend-then-hibernate"; - HibernateDelaySec = "1800"; - }; + services.logind = { + settings = { + Login = { + HandleLidSwitch = "suspend-then-hibernate"; + HibernateDelaySec = "1800"; }; }; - - nix = { - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - auto-optimise-store = true; - }; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - }; - - system.stateVersion = "26.05"; }; + + nix = { + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + auto-optimise-store = true; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + system.stateVersion = "26.05"; } diff --git a/modules/default.nix b/modules/default.nix index 3c8efa7..22c09e0 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,16 +1,41 @@ -{ - config, - lib, - pkgs, - ... -}: +{ lib, self, ... }: +let + moduleDirectoryList = builtins.filter ( + name: name != "default.nix" && lib.strings.hasSuffix ".nix" name + ) (builtins.attrNames (builtins.readDir ./.)); -{ - imports = [ - ./core.nix - ./user.nix - ./desktop.nix - ./dev.nix - ./shell - ]; + allModules = builtins.listToAttrs ( + builtins.map (entry: { + name = lib.strings.removeSuffix ".nix" entry; + value = ./. + "/${entry}"; + }) moduleDirectoryList + ); +in +allModules +// { + desktop-suite = { + imports = [ + self.nixosModules.core + self.nixosModules.user + self.nixosModules.desktop + self.nixosModules.dev + self.nixosModules.cli-tools + self.nixosModules.git + self.nixosModules.gpg + self.nixosModules.zsh + self.nixosModules.helix + ]; + }; + + core-suite = { + imports = [ + self.nixosModules.core + self.nixosModules.user + self.nixosModules.cli-tools + self.nixosModules.git + self.nixosModules.gpg + self.nixosModules.zsh + self.nixosModules.helix + ]; + }; } diff --git a/modules/desktop.nix b/modules/desktop.nix index 2760d69..75d9b10 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -6,135 +6,126 @@ ... }: -let - cfg = config.dotfiles.desktop; -in { - options.dotfiles.desktop = { - enable = lib.mkEnableOption "Graphical desktop environment (DWL)"; + programs.dwl.enable = true; + programs.dwl.package = pkgs.dwl.override { + configH = ../hosts/nabro/dwl-config.h; }; - config = lib.mkIf cfg.enable { - programs.dwl.enable = true; - programs.dwl.package = pkgs.dwl.override { - configH = ../hosts/nabro/dwl-config.h; - }; + services.pipewire = { + enable = true; + pulse.enable = true; + alsa.enable = true; + jack.enable = true; + }; - services.pipewire = { + fonts.packages = with pkgs; [ + nerd-fonts.jetbrains-mono + noto-fonts + noto-fonts-color-emoji + ]; + + fonts.fontconfig.defaultFonts = { + monospace = [ + "JetBrainsMono Nerd Font" + "Noto Sans Mono" + ]; + emoji = [ "Noto Color Emoji" ]; + }; + + hardware.graphics.enable = true; + security.polkit.enable = true; + security.pam.services.swaylock = { }; + + services.getty.autologinUser = "${userVars.username}"; + + environment.systemPackages = with pkgs; [ + pamixer + brightnessctl + wl-clipboard + wmenu + fnott + foot + firefox + tor-browser + grim + slurp + wlopm + ]; + + home-manager.users."${userVars.username}" = { + programs.foot = { enable = true; - pulse.enable = true; - alsa.enable = true; - jack.enable = true; + settings = { + main = { + font = "JetBrainsMono Nerd Font:size=13"; + }; + }; }; - fonts.packages = with pkgs; [ - nerd-fonts.jetbrains-mono - noto-fonts - noto-fonts-color-emoji - ]; + programs.swaylock = { + enable = true; + package = pkgs.swaylock-effects; + settings = { + clock = true; + indicator = true; + screenshots = true; + effect-blur = "7x5"; + effect-vignette = "0.5:0.5"; + ring-color = "b085f5"; + key-hl-color = "5e35b1"; + line-color = "00000000"; + inside-color = "00000088"; + separator-color = "00000000"; + fade-in = 0.2; + }; + }; - fonts.fontconfig.defaultFonts = { - monospace = [ - "JetBrainsMono Nerd Font" - "Noto Sans Mono" + services.swayidle = { + enable = true; + events = { + before-sleep = "${pkgs.swaylock-effects}/bin/swaylock -f"; + lock = "${pkgs.swaylock-effects}/bin/swaylock -f"; + }; + timeouts = [ + { + timeout = 300; + command = "${pkgs.swaylock-effects}/bin/swaylock -f"; + } + { + timeout = 600; + command = "${pkgs.wlopm}/bin/wlopm --off '*'"; + resumeCommand = "${pkgs.wlopm}/bin/wlopm --on '*'"; + } + { + timeout = 900; + command = "${pkgs.systemd}/bin/systemctl hibernate"; + } ]; - emoji = [ "Noto Color Emoji" ]; }; - hardware.graphics.enable = true; - security.polkit.enable = true; - security.pam.services.swaylock = { }; - - services.getty.autologinUser = "${userVars.username}"; - - environment.systemPackages = with pkgs; [ - pamixer - brightnessctl - wl-clipboard - wmenu - fnott - foot - firefox - tor-browser - grim - slurp - wlopm - ]; - - home-manager.users."${userVars.username}" = { - programs.foot = { - enable = true; - settings = { - main = { - font = "JetBrainsMono Nerd Font:size=13"; - }; - }; + services.wlsunset = { + enable = true; + latitude = "52.5"; + longitude = "13.4"; + temperature = { + day = 6500; + night = 4000; }; + }; - programs.swaylock = { - enable = true; - package = pkgs.swaylock-effects; - settings = { - clock = true; - indicator = true; - screenshots = true; - effect-blur = "7x5"; - effect-vignette = "0.5:0.5"; - ring-color = "b085f5"; - key-hl-color = "5e35b1"; - line-color = "00000000"; - inside-color = "00000088"; - separator-color = "00000000"; - fade-in = 0.2; - }; - }; - - services.swayidle = { - enable = true; - events = { - before-sleep = "${pkgs.swaylock-effects}/bin/swaylock -f"; - lock = "${pkgs.swaylock-effects}/bin/swaylock -f"; - }; - timeouts = [ - { - timeout = 300; - command = "${pkgs.swaylock-effects}/bin/swaylock -f"; - } - { - timeout = 600; - command = "${pkgs.wlopm}/bin/wlopm --off '*'"; - resumeCommand = "${pkgs.wlopm}/bin/wlopm --on '*'"; - } - { - timeout = 900; - command = "${pkgs.systemd}/bin/systemctl hibernate"; - } - ]; - }; - - services.wlsunset = { - enable = true; - latitude = "52.5"; - longitude = "13.4"; - temperature = { - day = 6500; - night = 4000; - }; - }; - - services.fnott = { - enable = true; - settings = { - main = { - font = "JetBrainsMono Nerd Font:size=11"; - background = "1a1a24e0"; - border-color = "b085f5ff"; - border-size = 2; - padding-vertical = 12; - padding-horizontal = 16; - summary-color = "ffffffff"; - body-color = "e0e0e0ff"; - }; + services.fnott = { + enable = true; + settings = { + main = { + font = "JetBrainsMono Nerd Font:size=11"; + background = "1a1a24e0"; + border-color = "b085f5ff"; + border-size = 2; + padding-vertical = 12; + padding-horizontal = 16; + summary-color = "ffffffff"; + body-color = "e0e0e0ff"; }; }; }; diff --git a/modules/dev.nix b/modules/dev.nix index c7575d1..a8412bd 100644 --- a/modules/dev.nix +++ b/modules/dev.nix @@ -5,27 +5,18 @@ ... }: -let - cfg = config.dotfiles.dev; -in { - options.dotfiles.dev = { - enable = lib.mkEnableOption "Development tools and language servers"; - }; - - config = lib.mkIf cfg.enable { - environment.systemPackages = with pkgs; [ - gcc - gnumake - clang-tools - lldb - python3 - uv - ruff - ty - nil - nixd - nixfmt - ]; - }; + environment.systemPackages = with pkgs; [ + gcc + gnumake + clang-tools + lldb + python3 + uv + ruff + ty + nil + nixd + nixfmt + ]; } diff --git a/modules/git.nix b/modules/git.nix new file mode 100644 index 0000000..35c05b9 --- /dev/null +++ b/modules/git.nix @@ -0,0 +1,27 @@ +{ + config, + lib, + pkgs, + userVars, + ... +}: + +{ + home-manager.users."${userVars.username}" = { + programs.git = { + enable = true; + settings = { + user = { + name = userVars.fullName; + email = userVars.email; + }; + commit.gpgsign = true; + gpg.program = "gpg"; + }; + signing = { + key = userVars.gpgKey; + signByDefault = true; + }; + }; + }; +} diff --git a/modules/gpg.nix b/modules/gpg.nix new file mode 100644 index 0000000..f60d8f9 --- /dev/null +++ b/modules/gpg.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + pkgs, + userVars, + ... +}: + +{ + environment.systemPackages = with pkgs; [ + gnupg + pass + pinentry-qt + ]; + + home-manager.users."${userVars.username}" = { + services.gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + pinentry.package = pkgs.pinentry-qt; + }; + }; +} diff --git a/modules/helix.nix b/modules/helix.nix new file mode 100644 index 0000000..127f984 --- /dev/null +++ b/modules/helix.nix @@ -0,0 +1,146 @@ +{ + config, + lib, + pkgs, + userVars, + ... +}: + +{ + home-manager.users."${userVars.username}" = { + programs.helix = { + enable = true; + defaultEditor = true; + + settings = { + theme = "ayu_dark"; + editor = { + line-number = "relative"; + mouse = false; + color-modes = true; + auto-format = true; + completion-timeout = 5; + completion-replace = true; + preview-completion-insert = true; + scrolloff = 8; + cursorline = true; + auto-info = true; + rulers = [ 80 ]; + bufferline = "multiple"; + shell = [ + "zsh" + "-c" + ]; + jump-label-alphabet = "asdfghjklqwertyuiopzxcvbnm"; + + cursor-shape = { + insert = "bar"; + normal = "block"; + select = "underline"; + }; + + inline-diagnostics = { + cursor-line = "warning"; + other-lines = "disable"; + }; + + file-picker = { + hidden = false; + git-ignore = true; + git-global = true; + }; + + statusline = { + left = [ + "mode" + "file-base-name" + "version-control" + ]; + center = [ ]; + right = [ + "diagnostics" + "selections" + "position" + "file-encoding" + "file-type" + ]; + separator = "│"; + }; + + lsp = { + display-messages = true; + display-inlay-hints = true; + }; + + indent-guides = { + render = true; + character = "╎"; + skip-levels = 1; + }; + + soft-wrap = { + enable = true; + }; + + smart-tab = { + enable = true; + supersede-menu = true; + }; + }; + }; + + languages = { + language = [ + { + name = "python"; + language-servers = [ + "ty" + "ruff" + ]; + formatter = { + command = "ruff"; + args = [ + "format" + "-" + ]; + }; + auto-format = true; + } + { + name = "c"; + language-servers = [ "clangd" ]; + formatter = { + command = "clang-format"; + args = [ "--style=file" ]; + }; + auto-format = true; + } + { + name = "nix"; + language-servers = [ "nixd" ]; + formatter = { + command = "nixfmt"; + }; + auto-format = true; + } + ]; + + language-server = { + nixd = { + command = "nixd"; + }; + ruff = { + command = "ruff"; + }; + ty = { + command = "ty"; + args = [ "server" ]; + }; + clangd = { + command = "clangd"; + }; + }; + }; + }; + }; +} diff --git a/modules/shell/default.nix b/modules/shell/default.nix deleted file mode 100644 index bca1e04..0000000 --- a/modules/shell/default.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - config, - lib, - pkgs, - userVars, - ... -}: - -let - cfg = config.dotfiles.shell; - - shellDir = ./.; - otherShellFiles = builtins.filter ( - name: name != "default.nix" && lib.strings.hasSuffix ".nix" name - ) (builtins.attrNames (builtins.readDir shellDir)); - importedModules = map (file: shellDir + "/${file}") otherShellFiles; -in -{ - imports = importedModules; - - options.dotfiles.shell = { - enable = lib.mkEnableOption "Shell, Git, GPG, and CLI environment"; - }; - - config = lib.mkIf cfg.enable { - environment.systemPackages = with pkgs; [ - git - wget - tealdeer - gnupg - pass - p7zip - btop - helix - opencode - fd - ripgrep - ]; - - home-manager.users."${userVars.username}" = { - programs.git = { - enable = true; - settings = { - user = { - name = userVars.fullName; - email = userVars.email; - }; - commit.gpgsign = true; - gpg.program = "gpg"; - }; - signing = { - key = userVars.gpgKey; - signByDefault = true; - }; - }; - - services.gpg-agent = { - enable = true; - defaultCacheTtl = 1800; - enableSshSupport = true; - pinentry.package = pkgs.pinentry-qt; - }; - - }; - }; -} diff --git a/modules/shell/helix.nix b/modules/shell/helix.nix deleted file mode 100644 index 74ce005..0000000 --- a/modules/shell/helix.nix +++ /dev/null @@ -1,155 +0,0 @@ -{ - config, - lib, - pkgs, - userVars, - ... -}: - -let - cfg = config.dotfiles.helix; -in -{ - options.dotfiles.helix = { - enable = lib.mkEnableOption "Fully configured Helix editor"; - }; - - config = lib.mkIf cfg.enable { - home-manager.users."${userVars.username}" = { - programs.helix = { - enable = true; - defaultEditor = true; - - settings = { - theme = "ayu_dark"; - editor = { - line-number = "relative"; - mouse = false; - color-modes = true; - auto-format = true; - completion-timeout = 5; - completion-replace = true; - preview-completion-insert = true; - scrolloff = 8; - cursorline = true; - auto-info = true; - rulers = [ 80 ]; - bufferline = "multiple"; - shell = [ - "zsh" - "-c" - ]; - jump-label-alphabet = "asdfghjklqwertyuiopzxcvbnm"; - - cursor-shape = { - insert = "bar"; - normal = "block"; - select = "underline"; - }; - - inline-diagnostics = { - cursor-line = "warning"; - other-lines = "disable"; - }; - - file-picker = { - hidden = false; - git-ignore = true; - git-global = true; - }; - - statusline = { - left = [ - "mode" - "file-base-name" - "version-control" - ]; - center = [ ]; - right = [ - "diagnostics" - "selections" - "position" - "file-encoding" - "file-type" - ]; - separator = "│"; - }; - - lsp = { - display-messages = true; - display-inlay-hints = true; - }; - - indent-guides = { - render = true; - character = "╎"; - skip-levels = 1; - }; - - soft-wrap = { - enable = true; - }; - - smart-tab = { - enable = true; - supersede-menu = true; - }; - }; - }; - - languages = { - language = [ - { - name = "python"; - language-servers = [ - "ty" - "ruff" - ]; - formatter = { - command = "ruff"; - args = [ - "format" - "-" - ]; - }; - auto-format = true; - } - { - name = "c"; - language-servers = [ "clangd" ]; - formatter = { - command = "clang-format"; - args = [ "--style=file" ]; - }; - auto-format = true; - } - { - name = "nix"; - language-servers = [ "nixd" ]; - formatter = { - command = "nixfmt"; - }; - auto-format = true; - } - ]; - - language-server = { - nixd = { - command = "nixd"; - }; - ruff = { - command = "ruff"; - }; - ty = { - command = "ty"; - args = [ "server" ]; - }; - clangd = { - command = "clangd"; - }; - }; - }; - }; - }; - }; -} diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix deleted file mode 100644 index 95002a2..0000000 --- a/modules/shell/zsh.nix +++ /dev/null @@ -1,243 +0,0 @@ -{ - config, - lib, - pkgs, - userVars, - ... -}: - -let - cfg = config.dotfiles.zsh; -in -{ - options.dotfiles.zsh = { - enable = lib.mkEnableOption "Fully configured Zsh terminal environment"; - }; - - config = lib.mkIf cfg.enable { - programs.zsh.enable = true; - - users.users."${userVars.username}".shell = pkgs.zsh; - - home-manager.users."${userVars.username}" = { - programs.zsh = { - enable = true; - enableCompletion = false; - autosuggestion.enable = true; - syntaxHighlighting.enable = true; - - dotDir = "/home/${userVars.username}/.config/zsh"; - - initContent = '' - # -- GPG / SSH Configuration -- - export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" - - # Import Wayland environment to systemd for GUI tools (like pinentry-gnome3) - if [ -n "$WAYLAND_DISPLAY" ]; then - systemctl --user import-environment WAYLAND_DISPLAY DISPLAY DBUS_SESSION_BUS_ADDRESS 2>/dev/null - dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY DBUS_SESSION_BUS_ADDRESS 2>/dev/null - fi - - # Automatically start dwl on TTY 1 - if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then - exec dwl - fi - ''; - - history = { - size = 10000; - save = 10000; - path = "$HOME/.local/share/zsh/history"; - ignoreDups = true; - ignoreAllDups = true; - ignoreSpace = true; - share = true; - extended = true; - }; - - plugins = [ - { - name = "fast-syntax-highlighting"; - src = pkgs.zsh-fast-syntax-highlighting.src; - } - { - name = "zsh-autosuggestions"; - src = pkgs.zsh-autosuggestions.src; - } - { - name = "zsh-history-substring-search"; - src = pkgs.zsh-history-substring-search.src; - } - { - name = "fzf-tab"; - src = pkgs.zsh-fzf-tab.src; - } - ]; - - shellAliases = { - ls = "eza --group-directories-first"; - ll = "eza -l --group-directories-first --git"; - la = "eza -la --group-directories-first --git"; - lt = "eza --tree --level=2"; - cat = "bat --paging=never"; - grep = "grep --color=auto"; - gs = "git status -sb"; - gd = "git diff"; - gc = "git commit"; - gp = "git push"; - ga = "git add -A"; - gm = "git add -m"; - gl = "git log --oneline"; - cleanup = "sudo nix-collect-garbage -d"; - ".." = "cd .."; - "..." = "cd ../.."; - }; - }; - - programs.starship = { - - enable = true; - enableZshIntegration = true; - - settings = { - add_newline = false; - command_timeout = 500; - scan_timeout = 10; - - format = lib.concatStrings [ - "$directory" - "$git_branch" - "$git_status" - "$nix_shell" - "$python" - "$c" - "$rust" - "$cmd_duration" - "$jobs" - "$line_break" - "$character" - ]; - - character = { - success_symbol = "[❯](bold green)"; - error_symbol = "[❯](bold red)"; - vimcmd_symbol = "[❮](bold yellow)"; - }; - - directory = { - style = "bold cyan"; - truncation_length = 3; - truncate_to_repo = true; - truncation_symbol = "…/"; - read_only = " 🔒"; - }; - - git_branch = { - style = "bold purple"; - format = "[$symbol$branch]($style) "; - symbol = " "; - }; - - git_status = { - style = "bold red"; - format = "([$all_status$ahead_behind]($style)) "; - conflicted = "="; - ahead = "⇡\${count}"; - behind = "⇣\${count}"; - diverged = "⇕⇡\${ahead_count}⇣\${behind_count}"; - staged = "+\${count}"; - modified = "!\${count}"; - untracked = "?\${count}"; - stashed = "\$"; - }; - - nix_shell = { - style = "bold blue"; - format = "[$symbol$state( \($name\))]($style) "; - symbol = "❄ "; - impure_msg = "impure"; - pure_msg = "pure"; - }; - - python = { - style = "bold yellow"; - format = "[$symbol( \($virtualenv\))]($style) "; - symbol = " "; - detect_extensions = [ "py" ]; - detect_files = [ - "pyproject.toml" - "requirements.txt" - "uv.lock" - ]; - }; - - c = { - style = "bold dimmed white"; - format = "[$symbol($version(-$name))]($style) "; - symbol = " "; - detect_extensions = [ - "c" - "h" - ]; - }; - - rust = { - disabled = true; - }; - - cmd_duration = { - style = "bold yellow"; - format = "[$duration]($style) "; - min_time = 2000; - show_notifications = false; - }; - - jobs = { - style = "bold blue"; - symbol = "✦"; - number_threshold = 1; - }; - - aws.disabled = true; - gcloud.disabled = true; - docker_context.disabled = true; - kubernetes.disabled = true; - package.disabled = true; - battery.disabled = true; - }; - - }; - - programs.zoxide = { - enable = true; - enableZshIntegration = true; - }; - - programs.eza = { - enable = true; - enableZshIntegration = true; - icons = "auto"; - }; - - programs.bat = { - enable = true; - config = { - theme = "ansi"; - }; - }; - - programs.direnv = { - enable = true; - enableZshIntegration = true; - nix-direnv.enable = true; - }; - - programs.fzf = { - enable = true; - enableBashIntegration = true; - enableZshIntegration = true; - defaultCommand = "fd --type f --hidden --exclude .git"; - }; - }; - }; -} diff --git a/modules/user.nix b/modules/user.nix index 1cfb85a..f14c475 100644 --- a/modules/user.nix +++ b/modules/user.nix @@ -6,27 +6,18 @@ ... }: -let - cfg = config.dotfiles.user; -in { - options.dotfiles.user = { - enable = lib.mkEnableOption "User configuration"; + users.users."${userVars.username}" = { + isNormalUser = true; + extraGroups = [ + "wheel" + "networkmanager" + ]; }; - config = lib.mkIf cfg.enable { - users.users."${userVars.username}" = { - isNormalUser = true; - extraGroups = [ - "wheel" - "networkmanager" - ]; - }; - - home-manager.users."${userVars.username}" = { - home.username = userVars.username; - home.homeDirectory = "/home/${userVars.username}"; - home.stateVersion = "26.05"; - }; + home-manager.users."${userVars.username}" = { + home.username = userVars.username; + home.homeDirectory = "/home/${userVars.username}"; + home.stateVersion = "26.05"; }; } diff --git a/modules/zsh.nix b/modules/zsh.nix new file mode 100644 index 0000000..d72665b --- /dev/null +++ b/modules/zsh.nix @@ -0,0 +1,232 @@ +{ + config, + lib, + pkgs, + userVars, + ... +}: + +{ + programs.zsh.enable = true; + + users.users."${userVars.username}".shell = pkgs.zsh; + + home-manager.users."${userVars.username}" = { + programs.zsh = { + enable = true; + enableCompletion = false; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + dotDir = "/home/${userVars.username}/.config/zsh"; + + initContent = '' + # -- GPG / SSH Configuration -- + export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" + + # Import Wayland environment to systemd for GUI tools (like pinentry-gnome3) + if [ -n "$WAYLAND_DISPLAY" ]; then + systemctl --user import-environment WAYLAND_DISPLAY DISPLAY DBUS_SESSION_BUS_ADDRESS 2>/dev/null + dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY DBUS_SESSION_BUS_ADDRESS 2>/dev/null + fi + + # Automatically start dwl on TTY 1 + if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then + exec dwl + fi + ''; + + history = { + size = 10000; + save = 10000; + path = "$HOME/.local/share/zsh/history"; + ignoreDups = true; + ignoreAllDups = true; + ignoreSpace = true; + share = true; + extended = true; + }; + + plugins = [ + { + name = "fast-syntax-highlighting"; + src = pkgs.zsh-fast-syntax-highlighting.src; + } + { + name = "zsh-autosuggestions"; + src = pkgs.zsh-autosuggestions.src; + } + { + name = "zsh-history-substring-search"; + src = pkgs.zsh-history-substring-search.src; + } + { + name = "fzf-tab"; + src = pkgs.zsh-fzf-tab.src; + } + ]; + + shellAliases = { + ls = "eza --group-directories-first"; + ll = "eza -l --group-directories-first --git"; + la = "eza -la --group-directories-first --git"; + lt = "eza --tree --level=2"; + cat = "bat --paging=never"; + grep = "grep --color=auto"; + gs = "git status -sb"; + gd = "git diff"; + gc = "git commit"; + gp = "git push"; + ga = "git add -A"; + gm = "git add -m"; + gl = "git log --oneline"; + cleanup = "sudo nix-collect-garbage -d"; + ".." = "cd .."; + "..." = "cd ../.."; + }; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + + settings = { + add_newline = false; + command_timeout = 500; + scan_timeout = 10; + + format = lib.concatStrings [ + "$directory" + "$git_branch" + "$git_status" + "$nix_shell" + "$python" + "$c" + "$rust" + "$cmd_duration" + "$jobs" + "$line_break" + "$character" + ]; + + character = { + success_symbol = "[❯](bold green)"; + error_symbol = "[❯](bold red)"; + vimcmd_symbol = "[❮](bold yellow)"; + }; + + directory = { + style = "bold cyan"; + truncation_length = 3; + truncate_to_repo = true; + truncation_symbol = "…/"; + read_only = " 🔒"; + }; + + git_branch = { + style = "bold purple"; + format = "[$symbol$branch]($style) "; + symbol = " "; + }; + + git_status = { + style = "bold red"; + format = "([$all_status$ahead_behind]($style)) "; + conflicted = "="; + ahead = "⇡\${count}"; + behind = "⇣\${count}"; + diverged = "⇕⇡\${ahead_count}⇣\${behind_count}"; + staged = "+\${count}"; + modified = "!\${count}"; + untracked = "?\${count}"; + stashed = "\$"; + }; + + nix_shell = { + style = "bold blue"; + format = "[$symbol$state( \($name\))]($style) "; + symbol = "❄ "; + impure_msg = "impure"; + pure_msg = "pure"; + }; + + python = { + style = "bold yellow"; + format = "[$symbol( \($virtualenv\))]($style) "; + symbol = " "; + detect_extensions = [ "py" ]; + detect_files = [ + "pyproject.toml" + "requirements.txt" + "uv.lock" + ]; + }; + + c = { + style = "bold dimmed white"; + format = "[$symbol($version(-$name))]($style) "; + symbol = " "; + detect_extensions = [ + "c" + "h" + ]; + }; + + rust = { + disabled = true; + }; + + cmd_duration = { + style = "bold yellow"; + format = "[$duration]($style) "; + min_time = 2000; + show_notifications = false; + }; + + jobs = { + style = "bold blue"; + symbol = "✦"; + number_threshold = 1; + }; + + aws.disabled = true; + gcloud.disabled = true; + docker_context.disabled = true; + kubernetes.disabled = true; + package.disabled = true; + battery.disabled = true; + }; + }; + + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; + + programs.eza = { + enable = true; + enableZshIntegration = true; + icons = "auto"; + }; + + programs.bat = { + enable = true; + config = { + theme = "ansi"; + }; + }; + + programs.direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + + programs.fzf = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + defaultCommand = "fd --type f --hidden --exclude .git"; + }; + }; +}