-
Hi! I'm trying to get I'm pretty new to both OCaml and opam-nix to this might be trivial and just me who am missing something. I've tried adding {
inputs = {
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
opam-nix.url = "github:tweag/opam-nix";
opam-nix.inputs.opam-repository.follows = "opam-repository";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.follows = "opam-nix/nixpkgs";
};
outputs = { self, flake-utils, opam-nix, opam-repository, nixpkgs }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
(on.listRepo (on.makeOpamRepo ./.));
devPackagesQuery = {
# You can add "development" packages here. They will get added to the devShell automatically.
ocaml-lsp-server = "*";
ocamlformat = "*";
};
query = devPackagesQuery // {
"ocaml-variants.4.14.1+wasocaml" = "*";
# Or should I do something else, like this?
# but that doesn't work either.
# ocaml-variants = "4.14.1+wasocaml";
};
wasocaml = pkgs.fetchFromGitHub {
owner = "ocamlpro";
repo = "wasocaml-opam";
rev = "8f835900925031618b09eac3cd6ca58a4ebe023c";
sha256 = "sha256-gef1VRleVa9hfcJFnlC6ZKCFom+SuroJx8T9wHFRg0U=";
};
scope = on.buildOpamProject' {
repos = ["${opam-repository}" "${wasocaml}"];
} ./. query;
overlay = final: prev:
{
# You can add overrides here
};
scope' = scope.overrideScope' overlay;
# Packages from devPackagesQuery
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
# Packages in this workspace
packages =
pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope';
in {
legacyPackages = scope';
packages = packages // { default = packages.backend; };
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues packages;
buildInputs = devPackages ++ [
# You can add packages from nixpkgs here
];
};
});
} Happy for any help or pointers! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I might've figured it out. Seems I need to pass |
Beta Was this translation helpful? Give feedback.
Currently, an
--impure
is required due to this line: https://github.com/OCamlPro/wasocaml-opam/blob/main/packages/ocaml-variants/ocaml-variants.4.14.1%2Bwasocaml/opam#L22It tells opam to fetch the latest version of
wasocaml
, which is obviously impure, and hence Nix requires you to pass--impure
.The proper fix would be to fetch the
wasocaml
repo yourself and get the package from there instead of using thewasocaml-opam
repository, something like this: