A very similar issue was reported here Menu unusable on Pantheon DE · Issue #680 · BespokeSynth/BespokeSynth · GitHub, it was caused from missing X11 related libraries that are dlopenned by bespokesynth, mkShell
does not populate these variable since they are not needed at build time. One solution might be to add a shell hook in mkshell
that setup LD_LIBRARY_PATH
appropriately, but this does not seem like a really clean solution. Instead, I would say that it is better to change the way bespoke is compiled, by adding a flag (see this discussion for, e.g., advices on how to debug it) that adds in the binary’s a rpath entry to help dlopen to find the file:
NIX_LDFLAGS = "-rpath ${lib.makeLibraryPath (with xorg; [ libX11 libXrandr libXinerama libXext libXcursor libXScrnSaver ])} $NIX_LDFLAGS";
dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath
(note that I’ve not tested the above code, but it should be close enough to the solution)
Regarding your build command, it might be enough (not sure if cmake needs additional hook to configure the environment… guess it’s fine if you can run the command), but note also that you can run the default phase (./configure
…) using exacly the command used by nix by using phases="phasesYou wantToRun" genericBuild
as described in more details here Nixpkgs/Create and debug packages - NixOS Wiki
Regarding the writeScriptBin
, I have to admit that I find that nix could provide some more user friendly way to automatically compile a project, but I’m not aware of a better strategy except for the generic way to run a phase described above.
Finally, regarding flake, of course you don’t need flake (you can use plain nix if you prefer for instance), but flake provides nice tools to help with purity, caching… Regarding nix develop
and zsh, one simple solution to use zsh inside nix develop
is to simply manually run zsh
inside nix develop
, it should work directly. You can also type:
$ nix develop -c zsh
as discussed here, possibly defining an alias if you use it a lot. There is also direnv
that is handy to automatically enter into the shell when changing folders…