Is there a way to remove a config file from a fetchGit? I’d like to replace it with my own config. So far I’ve tried adding postFetch and prePatch, but neither of those are correct. Does anyone have any suggestions?
I’ve been trying to make my first derivation for the last couple of days, as suggested. At this point I’m still trying to get the github files to pull in as is, without modifying the config file, but I’m stuck with this unclear error message:
error: builder for '/nix/store/y8b2s9brarj5nqhknbrn3qqw6998j031-yazelix.drv' failed with exit code 2;
last 10 log lines:
> --norc
> --posix
> --pretty-print
> --rcfile
> --restricted
> --verbose
> --version
> Shell options:
> -ilrsD or -c command or -O shopt_option (invocation only)
> -abefhkmnptuvxBCEHPT or -o option
For full logs, run 'nix log /nix/store/y8b2s9brarj5nqhknbrn3qqw6998j031-yazelix.drv'.
I never said to use mkDerivation, though you can if you want…
I said to use pkgs.fetchFromGitHub which is a derivation itself.
xdg.configFile.yazelix.source = pkgs.fetchFromGitHub {
owner = "luccahuguet";
repo = "yazelix";
rev = "d5dade229a1fef57567516e57cfc392cfb7ba266";
hash = ""; # build and get the hash from the error
postFetch = ''
rm $out/zellij/config.kdl
'';
};
Or if you still want to use fetchGit (inherently slower for larger repos, and unparallelisable since it’s part of eval) then use lib.fileset.* to filter out files that you don’t want.
@waffle8946 thanks for the “removing the hash” tip - it revealed an error around that path, like you suspected. So I tried changing that path to an absolute path:
I’m not 100% sure what your local layout looks like but try modifying your postFetch as follows, wrapping the filename of the local relative file in ${...}:
You can’t do that, builds are sandboxed. @jchw gave one possible solution, which works because that path will be copied to the nix store first, thereby allowing the builder to access it.
That worked! Thanks everyone for the help. My system is now fully declarative - that was the last piece of the puzzle. Got my colemak-dh keybindings and everything themed . This community is awesome.