tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

Question: Add build flags to specific package #64

Closed leana8959 closed 11 months ago

leana8959 commented 11 months ago

Hello,

First of all, apologies for opening an issue, I don't know where else to ask it.

I'm trying to put why3 v1.6.0 in a flake. The problem is that, I need to enable the IDE with the --enable-ide flag at build time (similar to configureFlags). Is there a way to do this currently? I've tried to use the overlay mechanism to add the flag, but it didn't work since it's more designed for env variables as far as I understand.

Here's the nix file I currently have:

{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
    opam-nix.url = "github:tweag/opam-nix";
  };

  outputs = {
    self,
    nixpkgs,
    opam-nix,
    flake-utils,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      why3 = let
        inherit (opam-nix.lib.${system}) queryToScope;
        scope = queryToScope {} {
          why3 = "1.6.0";
          ocaml-base-compiler = "*";
        };
        overlay = self: super: {
          why3 = super.why3.overrideAttrs (
            oa: { }
          );
        };
      in (scope.overrideScope' overlay).why3;

      pkgs = nixpkgs.legacyPackages.${system};
    in {
      devShell = pkgs.mkShell {
        packages = [
          why3
        ];
      };
    });
}

Thank you for your time :)