Hello, I’m very new to NixOS so forgive me if I use wrong terminology.
So, basically I’m trying to build Dwm using my custom config, which I am able to do with this:
...
(dwm.overrideAttrs (oldAttrs: rec {
patches = [ ... ];
configFile = writeText "config.h" (builtins.readFile ./dwm-config.h);
postPatch = "${oldAttrs.postPatch}\n cp ${configFile} config.def.h";
}))
However, my configfile depends on a header that I created called “colors.h”.
How do I add that file to the “builddir” so it is accessible to the compiler?
Thank you in advance.
Options:
- replicate the current solutions
(dwm.overrideAttrs (oldAttrs: rec {
patches = [ ... ];
configFile = writeText "config.h" (builtins.readFile ./dwm-config.h);
colorsH = writeText "colors.h" (builtins.readFile ./colors.h);
postPatch = "${oldAttrs.postPatch}\n cp ${configFile} config.def.h \n cp ${colorsH} color.h";
}))
- passAsFile
(dwm.overrideAttrs (oldAttrs: rec {
patches = [ ... ];
configFile = writeText "config.h" (builtins.readFile ./dwm-config.h);
colorsH = builtins.readFile ./colors.h;
passAsFile = (oldAttrs.passAsFiles or []) ++ ["colorsH"];
postPatch = "${oldAttrs.postPatch}\n cp ${configFile} config.def.h; cp $colorsH color.h";
}))
- If i’m not wrong, when you pass a path is it does what writeText does for you.
(dwm.overrideAttrs (oldAttrs: rec {
patches = [ ... ];
configFile = writeText "config.h" (builtins.readFile ./dwm-config.h);
postPatch = ''
${oldAttrs.postPatch or ""}
cp ${configFile} config.def.h
cp ${./colors.h} color.h
'';
}))
edit: typos
Can confirm solution 1 works, only you wrote “color.h” intstead of “colors.h”. Thank you for your time!
1 Like