diff --git a/flake.lock b/flake.lock index 030f432..ac7a1b2 100644 --- a/flake.lock +++ b/flake.lock @@ -295,11 +295,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1706470195, - "narHash": "sha256-SBdC0Xx7iOxjYKgIlHWfoH6oRIae1CBRZcIRIO5Iymc=", + "lastModified": 1706712950, + "narHash": "sha256-17TOvi0vKtelaRCZJvDaXk7YTDphqYwUMtxyZmWtAF4=", "ref": "refs/heads/master", - "rev": "148f7fe77452628d33cc431421a7819f3365cb03", - "revCount": 6, + "rev": "edeed6fbbd204fb3eb9bd2a6342a6d142c8b7dac", + "revCount": 8, "type": "git", "url": "ssh://gitea@pi1.odie.intranet/odie/neovim-flake" }, diff --git a/flake.nix b/flake.nix index ca4e74e..23cff5b 100644 --- a/flake.nix +++ b/flake.nix @@ -8,12 +8,12 @@ home-manager = { url = "github:nix-community/home-manager"; }; - neovim = { - url = "git+ssh://gitea@pi1.odie.intranet/odie/neovim-flake"; - }; neovim-nightly-overlay = { url = "github:nix-community/neovim-nightly-overlay"; }; + neovim = { + url = "git+ssh://gitea@pi1.odie.intranet/odie/neovim-flake"; + }; }; outputs = inputs@{ self, nixpkgs, flake-utils, home-manager, ... }: @@ -32,29 +32,26 @@ }; }) ] ++ inputOverlays; - localLib = { - mkPkgs = system: - import nixpkgs { - inherit system overlays; - }; - mkHomeManagerConfiguration = user: modules: system: - { - ${user} = home-manager.lib.homeManagerConfiguration { - pkgs = (localLib.mkPkgs system).unstable; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs outputs; }; - inherit modules; - }; - }; - }; + mkPkgs = system: + import nixpkgs { + inherit system overlays; + }; in - { - homeConfigurations = localLib.mkHomeManagerConfiguration "odie" [ + rec { + homeManagerModules = [ (import ./modules) - ] "x86_64-linux"; + ]; + homeConfigurations = { + "odie@asgard" = home-manager.lib.homeManagerConfiguration { + pkgs = (mkPkgs "x86_64-linux").unstable; + extraSpecialArgs = { inherit inputs outputs; }; + modules = homeManagerModules; + }; + }; packages = flake-utils.lib.eachDefaultSystem (system: let - pkgs = localLib.mkPkgs system; + pkgs = mkPkgs system; in with pkgs; { inherit (unstable) hello; @@ -62,13 +59,10 @@ ); } // flake-utils.lib.eachDefaultSystem (system: let - pkgs = localLib.mkPkgs system; + pkgs = mkPkgs system; in { formatter = pkgs.alejandra; - packages = with pkgs; { - inherit (unstable) hello; - }; devShells = { default = pkgs.mkShell { name = "home-manager"; diff --git a/modules/default.nix b/modules/default.nix index 6aa47e9..4e09c0b 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -5,32 +5,21 @@ language.base = "de_DE.UTF-8"; packages = with pkgs; [ home-manager - #neovim-ide ]; - sessionVariables = { - MANPAGER = "sh -c 'col -bx | bat -l man -p'"; - MANROFFOPT = "-c"; - }; - shellAliases = { - cat = "bat"; - }; }; imports = [ ./shell - ./neovim.nix + ./neovim-ide.nix ]; programs = { - bat.enable = true; + neovim-ide.enable = true; }; services = { ssh-agent.enable = true; }; - home = { - }; - home.stateVersion = "23.05"; } diff --git a/modules/neovim-ide.nix b/modules/neovim-ide.nix new file mode 100644 index 0000000..f2d0d03 --- /dev/null +++ b/modules/neovim-ide.nix @@ -0,0 +1,10 @@ +{ pkgs, config, lib, ... }: { + options = { + programs.neovim-ide.enable = lib.mkEnableOption "neovim-ide"; + }; + config = lib.mkIf config.programs.neovim-ide.enable { + home = { + packages = with pkgs; [ neovim-ide ]; + }; + }; +} diff --git a/modules/neovim.nix b/modules/neovim.nix deleted file mode 100644 index d10c10e..0000000 --- a/modules/neovim.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs, ... }: { - home = { - packages = with pkgs; [ neovim-ide ]; - }; -} diff --git a/modules/shell/bat.nix b/modules/shell/bat.nix new file mode 100644 index 0000000..72c529b --- /dev/null +++ b/modules/shell/bat.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: lib.mkIf config.programs.bat.enable { + home = { + packages = with pkgs; [ + bat + ]; + sessionVariables = { + MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + MANROFFOPT = "-c"; + }; + shellAliases = { + cat = "bat"; + }; + }; +} diff --git a/modules/shell/btop.nix b/modules/shell/btop.nix index f5cc310..d3e5918 100644 --- a/modules/shell/btop.nix +++ b/modules/shell/btop.nix @@ -1,6 +1,5 @@ -_: { +{ config, lib, ... }: lib.mkIf config.programs.btop.enable { programs.btop = { - enable = true; settings = { color_theme = "Default"; theme_background = false; diff --git a/modules/shell/default.nix b/modules/shell/default.nix index 24a6b62..6af608d 100644 --- a/modules/shell/default.nix +++ b/modules/shell/default.nix @@ -1,4 +1,4 @@ -_: { +{ lib, ... }: with lib; { imports = [ ./direnv.nix ./fzf.nix @@ -11,5 +11,21 @@ _: { ./btop.nix ./zoxide.nix ./ssh.nix + ./bat.nix ]; + + programs = { + bat.enable = mkDefault true; + btop.enable = mkDefault true; + direnv.enable = mkDefault true; + fzf.enable = mkDefault true; + git.enable = mkDefault true; + lf.enable = mkDefault true; + lsd.enable = mkDefault true; + ssh.enable = mkDefault true; + starship.enable = mkDefault true; + tmux.enable = mkDefault true; + zoxide.enable = mkDefault true; + zsh.enable = mkDefault true; + }; } diff --git a/modules/shell/direnv.nix b/modules/shell/direnv.nix index 99c1a1b..720f5e2 100644 --- a/modules/shell/direnv.nix +++ b/modules/shell/direnv.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: { +{ pkgs, lib, config, ... }: lib.mkIf config.programs.direnv.enable { programs.direnv = { - enable = true; enableZshIntegration = true; - enableBashIntegration = true; config = { global = { disable_stdin = true; diff --git a/modules/shell/fzf.nix b/modules/shell/fzf.nix index 933e924..d65aef0 100644 --- a/modules/shell/fzf.nix +++ b/modules/shell/fzf.nix @@ -1,7 +1,6 @@ -_: { +{ config, lib, ... }: lib.mkIf config.programs.fzf.enable { programs = { fzf = { - enable = true; enableZshIntegration = true; defaultCommand = "fd --type f"; defaultOptions = [ diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 97d2a2d..06e025d 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -1,14 +1,13 @@ -{ - config, - pkgs, - ... -}: { +{ config +, pkgs +, lib +, ... +}: lib.mkIf config.programs.git.enable { home = { - packages = with pkgs; [pre-commit]; + packages = with pkgs; [ pre-commit ]; }; programs = { git = { - enable = true; userName = "Patrick Neff"; userEmail = "odie86@gmail.com"; extraConfig = { @@ -26,7 +25,7 @@ defaultBranch = "master"; }; }; - attributes = []; + attributes = [ ]; ignores = [ "# Created by https://www.toptal.com/developers/gitignore/api/vim,linux" "# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux" diff --git a/modules/shell/lf.nix b/modules/shell/lf.nix index 2191160..89696db 100644 --- a/modules/shell/lf.nix +++ b/modules/shell/lf.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: { +{ pkgs, config, lib, ... }: lib.mkIf config.programs.lf.enable { home = { packages = with pkgs; [ chafa @@ -14,7 +14,6 @@ }; }; programs.lf = { - enable = true; commands = { get-mime-type = "%xdg-mime query filetype \"$f\""; open = '' diff --git a/modules/shell/lsd.nix b/modules/shell/lsd.nix index c893c23..6e802be 100644 --- a/modules/shell/lsd.nix +++ b/modules/shell/lsd.nix @@ -1,7 +1,6 @@ -_: { +{lib, config, ...}: lib.mkIf config.programs.lsd.enable { programs = { lsd = { - enable = true; enableAliases = true; }; }; diff --git a/modules/shell/ssh.nix b/modules/shell/ssh.nix index 10dcf16..b9eaf6a 100644 --- a/modules/shell/ssh.nix +++ b/modules/shell/ssh.nix @@ -1,8 +1,7 @@ -{ pkgs, ... }: { +{ pkgs, config, lib, ... }: lib.mkIf config.programs.ssh.enable { home.packages = with pkgs; [ tea ]; programs = { ssh = { - enable = true; addKeysToAgent = "yes"; forwardAgent = true; }; diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix index 3dae570..3e91d9f 100644 --- a/modules/shell/starship.nix +++ b/modules/shell/starship.nix @@ -1,8 +1,7 @@ -{ lib, ... }: -{ +{ lib, config, ... }: +lib.mkIf config.programs.starship.enable { programs = { starship = { - enable = true; enableZshIntegration = true; settings = { add_newline = false; diff --git a/modules/shell/tmux.nix b/modules/shell/tmux.nix index 965d5e5..7766622 100644 --- a/modules/shell/tmux.nix +++ b/modules/shell/tmux.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, config, ... }: let localLib = pkgs.callPackage ../../lib { }; catppuccin = pkgs.callPackage ../../pkgs/tmuxPlugins/catppuccin.nix { @@ -6,82 +6,86 @@ let }; in { - programs.tmux = { - enable = true; - newSession = true; - mouse = true; - keyMode = "vi"; - historyLimit = 10240; - clock24 = true; - baseIndex = 1; - aggressiveResize = true; - shortcut = "a"; - sensibleOnTop = true; - escapeTime = 0; - tmuxp.enable = true; - plugins = with pkgs.tmuxPlugins; [ - sensible - yank - { - plugin = catppuccin; - extraConfig = '' - set -g @catppuccin_window_default_text "#W" # use "#W" for application instead of directory - set -g @catppuccin_window_current_text "#W" # use "#W" for application instead of directory - set -g @catppuccin_window_status_enable "yes" - set -g @catppuccin_status_modules_right "directory user host date_time session" - ''; - } - better-mouse-mode - { - plugin = tmux-fzf; - extraConfig = '' - unbind A - TMUX_FZF_LAUNCH_KEY="f" - TMUX_FZF_PANE_FORMAT="[#{window_name}] #{pane_current_command} [#{pane_width}x#{pane_height}] [history #{history_size}/#{history_limit}, #{history_bytes} bytes] #{?pane_active,[active],[inactive]}" - ''; - } - ]; - extraConfig = '' - # Quick pane cycling - unbind ^A - bind ^A last-window + options = { - #unbind 'Space' - #bind 'Space' next-window + }; + config = { + programs.tmux = lib.mkIf config.programs.tmux.enable { + newSession = true; + mouse = true; + keyMode = "vi"; + historyLimit = 10240; + clock24 = true; + baseIndex = 1; + aggressiveResize = true; + shortcut = "a"; + sensibleOnTop = true; + escapeTime = 0; + tmuxp.enable = true; + plugins = with pkgs.tmuxPlugins; [ + sensible + yank + { + plugin = catppuccin; + extraConfig = '' + set -g @catppuccin_window_default_text "#W" # use "#W" for application instead of directory + set -g @catppuccin_window_current_text "#W" # use "#W" for application instead of directory + set -g @catppuccin_window_status_enable "yes" + set -g @catppuccin_status_modules_right "directory user host date_time session" + ''; + } + better-mouse-mode + { + plugin = tmux-fzf; + extraConfig = '' + unbind A + TMUX_FZF_LAUNCH_KEY="f" + TMUX_FZF_PANE_FORMAT="[#{window_name}] #{pane_current_command} [#{pane_width}x#{pane_height}] [history #{history_size}/#{history_limit}, #{history_bytes} bytes] #{?pane_active,[active],[inactive]}" + ''; + } + ]; + extraConfig = '' + # Quick pane cycling + unbind ^A + bind ^A last-window - bind-key C-s split-window -v - bind-key C-v split-window -h + #unbind 'Space' + #bind 'Space' next-window - # Open new panes and windows with the current panes path - bind c new-window -c "#{pane_current_path}" - bind '"' split-window -c "#{pane_current_path}" - bind % split-window -h -c "#{pane_current_path}" + bind-key C-s split-window -v + bind-key C-v split-window -h - set-option -sa terminal-features ',xterm-256color:RGB' - set-option -sa terminal-features ',st-256color:RGB' - set-option -sa terminal-features ',xterm-kitty:RGB' + # Open new panes and windows with the current panes path + bind c new-window -c "#{pane_current_path}" + bind '"' split-window -c "#{pane_current_path}" + bind % split-window -h -c "#{pane_current_path}" - is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'" + set-option -sa terminal-features ',xterm-256color:RGB' + set-option -sa terminal-features ',st-256color:RGB' + set-option -sa terminal-features ',xterm-kitty:RGB' - bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' "" 'select-pane -L' } - bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' "" 'select-pane -D' } - bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' "" 'select-pane -U' } - bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' "" 'select-pane -R' } + is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'" - bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' "" 'select-pane -L' - bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' "" 'select-pane -D' - bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' "" 'select-pane -U' - bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' "" 'select-pane -R' + bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' + bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' + bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' + bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' - bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1' - bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1' - bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1' - bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1' + bind-key -T copy-mode-vi 'C-h' 'select-pane -L' + bind-key -T copy-mode-vi 'C-j' 'select-pane -D' + bind-key -T copy-mode-vi 'C-k' 'select-pane -U' + bind-key -T copy-mode-vi 'C-l' 'select-pane -R' - bind-key -T copy-mode-vi M-h resize-pane -L 1 - bind-key -T copy-mode-vi M-j resize-pane -D 1 - bind-key -T copy-mode-vi M-k resize-pane -U 1 - bind-key -T copy-mode-vi M-l resize-pane -R 1 - ''; + bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1' + bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1' + bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1' + bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1' + + bind-key -T copy-mode-vi M-h resize-pane -L 1 + bind-key -T copy-mode-vi M-j resize-pane -D 1 + bind-key -T copy-mode-vi M-k resize-pane -U 1 + bind-key -T copy-mode-vi M-l resize-pane -R 1 + ''; + }; }; } diff --git a/modules/shell/zoxide.nix b/modules/shell/zoxide.nix index ad82f9c..f6f6d13 100644 --- a/modules/shell/zoxide.nix +++ b/modules/shell/zoxide.nix @@ -1,7 +1,6 @@ -_: { +{ config, lib, ... }: lib.mkIf config.programs.zoxide.enable { programs = { zoxide = { - enable = true; enableZshIntegration = true; }; }; diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index 54c58c7..a76ae93 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -1,7 +1,6 @@ -{ config, ... }: { +{ config, lib, ... }: lib.mkIf config.programs.zsh.enable { programs = { zsh = { - enable = true; defaultKeymap = "emacs"; dotDir = ".config/zsh"; shellAliases = {