Hello!
I’m very new to NixOS and trying to get some packages working is proving quite difficult, so I want to ask for help with answers that point me to the solution (or the solution itself, of course!)
Summary:
How can I add custom directories and files to specific package paths in the nix-store, preventing that directory or file name prepending its hash? (For example, adding the ranger/ directory (with its respective files like rc.conf, rifle.conf…) to the /etc/ path of the package /nix/store/xxxxxxxxxx-ranger/ and thus the file /nix/ store/xxxxxxxx-ranger/etc/ranger/rc.conf exists, and said ranger/ directory has been imported from the one in my /home/user/.config/ranger so that the configuration will be applied to ranger even if I access as root.
Long history (multiple cases):
- I use a program called xournalpp, which allows you to create custom plugins to execute certain actions. Those plugins need to be in a very specific location: /usr/share/xournalpp/plugins/. I tried various ways to get my files to that location such as:
-
Make a wrapper for the package that will copy the files from my local repository ("/home/…/Nix/…") to the target path. This didn’t work as the path didn’t belong to the nix-store, so the wrapper couldn’t find any files to copy.
-
Applying antiquotating to escape the nix-store path worked fine because I was already able to access my “/home/…”, however when copying the plugins directory to the destination path, the directory was hashed ( and of course xournalpp doesn’t look for the plugins in xxxxxxxxxxx-plugins).
Wrapper used on mi home-manager packages list to make this try:
(runCommand “xournalpp” {
buildInputs = [ pkgs.makeWrapper ];
} ‘’
mkdir $out
ln -s ${pkgs.xournalpp}/* $out
cp -r /home/user/Nix/home-manager/Unused/xournalpp/ $out/usr/share/xournalpp/
I can currently use the plugins as they made a commit that allows the expected path to be changed, however I would really like to know what is the proper way to deal with this situation with Nix, in case there is no other option.
- By migrating my standard settings to Nix, I managed to get everything working perfectly when configuring lightdm, except for the background image. This image must be (per lightdm configuration requirement), an absolute path. Again, I don’t know how I would be able to locate the image I want, and which is in, say /home/user/images/image.jpg in the path /etc/lightdm/background-image.jpg (that etc being the one associated to the lightdm package, of course), in order to write to the lightdm configuration
…
background-image = “/etc/lightdm/background-image.jpg”
…
And the image can be read correctly.
Note: I know that unlike the first case, it is possible to add files to the global /etc/ via environment.etc. However when I do
environment.etc.“lightdm/background-image.jpg”.source = absolute-path-to-myhome , it only works if I use the --impure flag when doing nixos-rebuild and again I would like to ask if there is any better way to achieve this (preferably without having to add that flag).
I’ve mentioned the specific packages where the problem occurred, but I’d appreciate if the solutions were agnostic to the package I want to add the files to (so I’m guessing it’s something to do with overlays, wrappers, or something like that).
Thank you very much in advance for your help, and in case my approach/handling of the situation is wrong, I appreciate if you point me to the most appropriate way to do it!