jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
138 stars 19 forks source link

Help: how to integrate clj-nix and buildFHSUserEnv #97

Closed das-monki closed 8 months ago

das-monki commented 10 months ago

Hi!

I'm using an embedded postgres in my tests (pg-embedded-clj), which fails on linux since apparently it expects to be run in an FHS environment. Since my knowledge of nix is still very limited, my approach would be to try and run the checkPhase in an FHS environment. However, I have no clue how I can combine clj-nix and buildFHSUserEnv..

Do you have any pointers how I could get this to work? Did you ever encounter such issues yourself?

Any help is very much appreciated. 😊

Btw, thank you a thousand times for the awesome clj-nix. I use it to build my backend as well as my cljs-frontend, and it works flawless. Also, I've learned a lot about nix by browsing through this repo. 🙏

jlesquembre commented 9 months ago

Did you consider using the postgresqlTestHook?

Something like this should give you a fresh DB you can use in the test phase:

mkCljBin{
    nativeCheckInputs = [
    postgresql
    postgresqlTestHook
  ];

  # Optional, I think only works on Linux
  postgresqlEnableTCP = "1";
}

In the previous link you can see a list of environment variables exported you can use to connect to the DB

jlesquembre commented 8 months ago

I hope my answer was helpful and you found a solution. Feel free to post here if you have related questions.