From 8b86c01550da3e058f45a886a7ddd60bddf40685 Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sun, 29 Dec 2024 19:59:56 -0700 Subject: [PATCH] fix: Configure Neovim using a wrappers --- README.org | 27 +++++++++++++++++++++++---- users/crumb/programs/nvim.nix | 35 +++++++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/README.org b/README.org index b77ea89..6004eb9 100755 --- a/README.org +++ b/README.org @@ -15,6 +15,23 @@ A second try at NixOS, now that I have a better idea of what I'm doing. The effo Modules, but lightweight. +* Principles + +** User configuration + +In order of descending preference, user programs should be configured by... + +1. Wrappers, with config files optionally living somewhere under =/persist/dots=. +2. home-manager's modules. +3. ~home.file~ and similar. +4. Mutable symlinks using ~home.file~ and ~mkOutOfStoreSymlink~. + +* Conventions + +** Impermanence and persistence + +- Persistent files to be linked into ~/~ go under ~/persist/root~ + * Tasks ** Emacs @@ -166,6 +183,10 @@ Or Qtile Or Niri +** TODO Convenient way to wrap programs + +[[https://github.com/viperML/wrapper-manager][wrapper-manager]] looks like it will be really annoying to integrate into my config without a NixOS/HM module. + ** TODO tf2.nix - declaratively configure tf2 @@ -228,10 +249,6 @@ https://discourse.nixos.org/t/what-to-do-with-a-full-boot-partition/2049 Remove a given host from =~/.ssh/known_hosts=. Something like =sed -i -e '/192.168.122.54/d' .ssh/known_hosts=. -* Impermanence and persistence - -- Persistent files to be linked into ~/~ go under ~/persist/root~ - * References Following is a subset of the many places I've learnt from. @@ -242,3 +259,5 @@ Following is a subset of the many places I've learnt from. - [[https://github.com/hlissner/dotfiles/][hlissner/dotfiles]] - [[https://github.com/Shawn8901/nix-configuration/tree/af71d51998a6772a300f842795b947e27202fa73][Shawn8901/nix-configuration]] - [cite:@christensen2020erase] +- [cite:@ayats2024dropping] +- [cite:@zaynetdinov2024you] diff --git a/users/crumb/programs/nvim.nix b/users/crumb/programs/nvim.nix index 69fd5a2..e131388 100755 --- a/users/crumb/programs/nvim.nix +++ b/users/crumb/programs/nvim.nix @@ -1,12 +1,31 @@ { config, lib, pkgs, ... }: -{ - home.file.".vimrc".text = '' - imap jk - xmap JK - ''; +let + my-vimrc = + pkgs.writeTextFile { + name = "vimrc"; + text = '' + imap jk + xmap JK + set number + set relativenumber + ''; + }; - xdg.configFile."nvim/init.vim".text = '' - so ~/.vimrc - ''; + my-neovim = + pkgs.symlinkJoin { + name = "neovim"; + paths = [ pkgs.neovim ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/nvim \ + --add-flags "-u ${my-vimrc}" + # Symlink {v,vi,vim} to nvim. + for i in {v,vi,vim}; do + ln -s $out/bin/nvim $out/bin/$i + done + ''; + }; +in { + home.packages = [ my-neovim ]; }