It’s not that it is forbidden from within an overlay, it’s forbidden from within any package build. What your overlay does is change the neovim
package in your instance of nixpkgs to be the package you write. The package you write is the result of taking the neovim package build instructions, and changing its postInstall
command.
This will make nix build a new neovim, and run your postInstall
command instead of the one from the original package.
“install” commands in nix land are not really installing anything onto the actual system, unlike for other distro’s packages (in case you’ve touched pkgbuilds before). They are supposed to place files in /nix/store
, you use the $out
variable to refer to the output directory of the build. Any attempt to write to anywhere except the $out
path will usually fail with read-only errors because the build sandbox prohibits this.
It’s called “install” mostly for historical reasons I guess, and because the abstraction is kind of similar.
So if you want to write to the system, you need to do something else…
home-manager is a very different beast. It also uses nix behind the scenes, but only to evaluate the configuration language and build packages.
Your home-manager configuration is condensed into a big ol’ bash script, called the “activation” script. When you run home-manager switch
, it goes and tells nix to build a package that depends on all the packages you added to home.packages
and such, and that package just contains this “activation” script that when you run it will create a whole bunch of symlinks to /nix/store
in your home-directory.
So when you spit files out of home-manager, you don’t really use nix to do so. You run a script called home-manager
which uses nix to build a different script, which it then executes to spit out all these files.
Hence, you can’t create files outside /nix/store
in the actual nix code.
Gotcha, my bad!
You can just use pkgs.vimUtils
. prev
as an overlay argument is exactly the same as pkgs
, but after any previous overlays in your overlay list were executed.
Yep, you don’t need to do anything that complex though. You can just use the home.file
option.
The passthru
attribute of a package build ends up in the final package as well. If passthrough
is a kind of typo, I think you should be able to access those with pkgs.neovim.packpathDirs
.
That said… This strikes me as a severe hack. This should just work out of the box. Maybe ask on matrix or IRC before going to these lengths?