From 1443064ca84784f3e6f3cc9f2d2229701181e795 Mon Sep 17 00:00:00 2001 From: Oshgnacknak Date: Sat, 6 Sep 2025 19:12:35 +0200 Subject: [PATCH] Add flake.net to ad-hoc install dotfiles on nixos --- _config/nvim/plugin/lsp.lua | 4 +- _zshrc | 9 +-- flake.nix | 127 ++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 flake.nix diff --git a/_config/nvim/plugin/lsp.lua b/_config/nvim/plugin/lsp.lua index 31d9862..2383d58 100644 --- a/_config/nvim/plugin/lsp.lua +++ b/_config/nvim/plugin/lsp.lua @@ -38,9 +38,7 @@ vim.api.nvim_create_autocmd('LspAttach', { }) require("mason").setup() -require("mason-lspconfig").setup { - ensure_installed = { "rust_analyzer" }, -} +require("mason-lspconfig").setup({}) local cmp = require('cmp') local cmp_nvim_lsp = require('cmp_nvim_lsp') diff --git a/_zshrc b/_zshrc index a02d09f..dda566f 100755 --- a/_zshrc +++ b/_zshrc @@ -30,12 +30,13 @@ function zle-keymap-select { } zle -N zle-keymap-select +[ -f "$HOME/./config/bashrc" ] && emulate sh -c "source $HOME/./config/bashrc" [ -f "$HOME/.bashrc" ] && emulate sh -c "source $HOME/.bashrc" -source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh -source /usr/share/fzf/key-bindings.zsh -source /usr/share/fzf/completion.zsh +[ -f "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ] && source "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" +[ -f "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ] && source "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" +[ -f "/usr/share/fzf/key-bindings.zsh" ] && source "/usr/share/fzf/key-bindings.zsh" +[ -f "/usr/share/fzf/completion.zsh" ] && source "/usr/share/fzf/completion.zsh" setopt interactivecomments setopt HIST_IGNORE_SPACE diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dbf71a3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,127 @@ +{ + description = "OSHs dotfiles"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + home-manager.url = "github:nix-community/home-manager/release-24.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, home-manager, neovim-nightly-overlay, ... }: + let + system = builtins.currentSystem; + username = builtins.getEnv "USER"; + homeDir = builtins.getEnv "HOME"; + pkgs = import nixpkgs { inherit system; }; + in { + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + { + nixpkgs.overlays = [ + neovim-nightly-overlay.overlays.default + ]; + + home.username = username; + home.homeDirectory = homeDir; + # Only manage what you explicitly turn on below + # (this keeps you from overriding distro-level things) + programs.git = { + enable = true; + userName = "Oshgnacknak"; + userEmail = "osh@oshgnacknak.de"; + }; + + programs.neovim = { + enable = true; + package = neovim-nightly-overlay.packages.${pkgs.system}.default; + viAlias = true; + vimAlias = true; + }; + + programs.home-manager.enable = true; + + programs.zsh = { + enable = true; + + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + initExtra = '' + source ${pkgs.fzf}/share/fzf/key-bindings.zsh + source ${pkgs.fzf}/share/fzf/completion.zsh + source ${pkgs.fzf-zsh}/share/zsh/plugins/fzf-zsh/fzf-zsh.plugin.zsh + + [ -f "$HOME/.config/zshrc" ] && source $HOME/.config/zshrc + ''; + + plugins = [ + { + name = "manydots-magic"; + src = pkgs.fetchFromGitHub { + owner = "knu"; + repo = "zsh-manydots-magic"; + rev = "master"; + sha256 = "sha256-lv7e7+KBR/nxC43H0uvphLcI7fALPvxPSGEmBn0g8HQ="; + }; + file = "manydots-magic"; + } + ]; + + zplug = { + enable = true; + plugins = [ + { name = "zsh-users/zsh-autosuggestions"; } + ]; + }; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + # Put extra packages in the *user* profile (not system) + home.packages = with pkgs; [ + ripgrep + fd + tmux + xsel + fzf + fzf-zsh + thefuck + rust-analyzer + ]; + + # Link dotfiles without forcing overwrite (fails safely if a file already exists) + home.file.".tmux.conf".source = ./_tmux.conf; + home.file.".config/zshrc".source = ./_zshrc; + home.file.".config/bashrc".source = ./_bashrc; + + home.file.".local/share/nvim/site/autoload/plug.vim".source = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"; + sha256 = "c2d8998469a049a51225a71128a12917b379822d16b639493e29ea02d8787306"; + }; + + xdg.configFile."nvim" = { + source = ./_config/nvim; + recursive = true; + force = true; + }; + + # Environment variables only for this user/session + home.sessionVariables = { + EDITOR = "nvim"; + }; + + # Good HM hygiene + xdg.enable = true; + home.stateVersion = "24.05"; + } + ]; + }; + }; +} +