dune
dune copied to clipboard
chore(nix): support build for experimental feature
Following the merge of #10724, I have written this PR so we are able to build the executable using Nix Flake. I'm far from being a Nix expert, so if someone with a better expertise is able to reduce the amount of code, it would be happy to change the code :smile:
EDIT: Replace my solution with @gridbugs' one, as it is simpler and more elegant one. It consists in adding a function to the package default that could take some flags.
Heads up that I pushed a commit that fixes the failing nix test.
I pushed another change to remove the duplication of the experimental flags.
I think it's simpler and more idiomatic to use overrideAttrs to update the configureFlags of an existing derivation, I'll try something
how does it look @maiste ? I did a quick test and it seems to work but I'm not super familiar with the experimental flags so let me know if the resulting binaries work as you expect
On @gridbugs and my computer, the produced binary works as expected:
- No need to add some flags to get the compiler installed (no error about Ocaml when doing the
dune pkg lockcommand) - It displays the packages installed nicely when running
dune build
EDIT: I didn't realize I didn't update the branch before trying. I retried with the musl version, and it worked! :ok_hand:
Nice work @emillon, I didn't know about overrideAttrs. I gave this a test on both macos-aarch64 and linux-x86_64 and both binaries have the features I expected.
I have rebased and cleaned the history. If the tests pass, I think it's ok to merge it :+1:
Nice work @emillon, I didn't know about
overrideAttrs
The part that made it click for me is this comment - derivations are mkDerivation calls and overrideAttrs changes the input of this function.
{ stdenv, bar, baz }: # this part gets overriden by `override`
stdenv.mkDerivation { # This part gets overriden by overrideAttrs
pname = "test";
version = "0.0.1";
buildInputs = [bar baz];
phases = ["installPhase"];
installPhase = "touch $out";
}
@gridbugs @emillon, I don't have the merge right: can I gently ask one of you to do the merge? :)