-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to find repositories specified in pin-depends
#1
Comments
pin-depends
pin-depends
It's indeed not possible to support For now, you can try passing yocaml as a repo. First, add an input to your flake:
Then, pass it (together with the default opam-repository) to the
|
opam-nix now supports |
Oh nice, thanks! Hmm for some reason the suggestion above doesn't seem to be working for me?
|
Ah, yeah, sorry. I forgot to
(Note that you'll also need the latest version of opam-nix since there was an overlay issue) |
Wooo, I think that worked! Thanks a bunch. Here's the full flake I made if it's of any use to anyone: {
description = "Static page generator for my digital garden";
inputs = {
# Utilities for writing flakes
flake-utils.url = github:numtide/flake-utils;
# Precisely filter files copied to the nix store
nix-filter.url = "github:numtide/nix-filter";
# Generate derivations from Dune and OCaml files
opam-nix.url = github:tweag/opam-nix;
# Static site generator for OCaml (not yet published to opam)
yocaml.url = "github:xhtmlboi/yocaml";
yocaml.flake = false;
};
outputs = { self, nixpkgs, flake-utils, nix-filter, opam-nix, yocaml }:
flake-utils.lib.eachDefaultSystem (system:
let
# Legacy packages that have not been converted to flakes
legacyPackages = nixpkgs.legacyPackages.${system};
# OCaml packages available on nixpkgs
ocamlPackages = legacyPackages.ocamlPackages;
# OCaml source files
ocaml-src = nix-filter.lib.filter {
root = ./.;
include = [
"dune-project"
"garden.opam.template"
(nix-filter.lib.inDirectory "bin")
];
};
in
{
# Executed by `nix build .#<name>`
packages.garden =
(opam-nix.lib.${system}.buildDuneProject
{
pinDepends = false;
repos = [
(opam-nix.lib.${system}.makeOpamRepo yocaml)
opam-nix.inputs.opam-repository
];
}
"garden"
ocaml-src
{
yocaml = null;
yocaml_unix = null;
yocaml_yaml = null;
yocaml_markdown = null;
}).garden;
# Executed by `nix build`
defaultPackage = self.packages.${system}.garden;
# Executed by `nix run .#<name>`
apps.garden = {
type = "app";
program = "${self.packages.${system}.garden}/bin/garden";
};
# Executed by `nix run`
defaultApp = self.apps.${system}.garden;
# Used by `nix develop`
devShell = legacyPackages.mkShell {
nativeBuildInputs = [
# Editor support
legacyPackages.fswatch # for `dune build --watch --terminal-persistence=clear-on-rebuild`
# legacyPackages.ocamlformat # FIXME: fails to build `uunf` on aarch64-darwin :(
ocamlPackages.merlin
ocamlPackages.ocaml-lsp
];
inputsFrom = [
self.defaultPackage.${system}
];
};
});
} |
Ahh wierd, for some reason when I do |
Ahh wait, I think that must be because of the recommended
|
Thanks to work of @rizo now non-master main branches are also supported! E.g. this works: https://github.com/tweag/opam-nix/blob/main/examples/readme/my-package/my-package.opam#L16 |
Should I be looking at https://github.com/tweag/opam-nix#examples-8 for this? |
No, it should just work with |
So I switched on flake.nix{
description = "Static page generator for my digital garden";
inputs = {
# Utilities for writing flakes
flake-utils.url = github:numtide/flake-utils;
# Precisely filter files copied to the nix store
nix-filter.url = "github:numtide/nix-filter";
# Generate derivations from Dune and OCaml files
opam-nix.url = github:tweag/opam-nix;
# Static site generator for OCaml (not yet published to opam)
yocaml.url = "github:xhtmlboi/yocaml";
yocaml.flake = false;
};
outputs = { self, nixpkgs, flake-utils, nix-filter, opam-nix, yocaml }:
flake-utils.lib.eachDefaultSystem (system:
let
# Legacy packages that have not been converted to flakes
legacyPackages = nixpkgs.legacyPackages.${system};
# OCaml packages available on nixpkgs
ocamlPackages = legacyPackages.ocamlPackages;
# OCaml source files
ocaml-src = nix-filter.lib.filter {
root = ./.;
include = [
"dune-project"
"garden.opam.template"
(nix-filter.lib.inDirectory "bin")
];
};
# Nix source files
nix-src = nix-filter.lib.filter {
root = ./.;
include = [
(nix-filter.lib.matchExt "nix")
];
};
in
{
# Used for `nixpkgs` packages, also accessible via `nix build .#<name>`
legacyPackages =
(opam-nix.lib.${system}.buildDuneProject
{
pinDepends = true;
repos = [
opam-nix.inputs.opam-repository
(opam-nix.lib.${system}.makeOpamRepo yocaml)
];
}
"garden"
ocaml-src
{
# Include `yocaml` packages
yocaml = null;
yocaml_markdown = null;
yocaml_mustache = null;
yocaml_unix = null;
yocaml_yaml = null;
# Ask `opam-nix `to include editor tools in the same scope as our
# package, ensuring that they will be built using the same
# compiler version etc.
merlin = null;
ocaml-lsp-server = null;
});
# Executed by `nix build`
defaultPackage = self.legacyPackages.${system}.garden;
# Executed by `nix run .#<name>`
apps.garden = {
type = "app";
program = "${self.legacyPackages.${system}.garden}/bin/garden";
};
# Executed by `nix run`
defaultApp = self.apps.${system}.garden;
# Used by `nix develop`
devShell = legacyPackages.mkShell {
nativeBuildInputs = [
# Editor support
legacyPackages.fswatch # for `dune build --watch --terminal-persistence=clear-on-rebuild`
# legacyPackages.ocamlformat # FIXME: fails to build `uunf` on aarch64-darwin :(
self.legacyPackages.${system}.merlin
self.legacyPackages.${system}.ocaml-lsp-server
];
inputsFrom = [
self.defaultPackage.${system}
];
};
});
} but now I am getting warnings like:
I also get a build error:
|
Oh, so I need to set a sha in |
I'm wondering if it's possible to use an opam lockfile to simplify this kind of thing? This is what naersk does, but I'm not too clear on the specifics of how opam works to know if it's possible here too… eg. I'm not sure how to generate the lockfile in the first place. I'm guessing it might require opam to be installed globally? |
Well, the warning tells you exactly what to do: run your command again with
That error looks weird, I'll look into it |
Yeah, I didn't want to run it in
Ahh yeah, this might be me confused by opam's model… (which I find confoundingly frustrating at the best of times). Coming from Cargo git dependencies are automatically pinned in a lockfile - ie. the 'correct way' is enabled by default. I'll go ahead and add the sha to the Sorry again for all my confusion! |
Could it be that there is some weirdness in how
|
Certainly possible :) What is the exact problem you're experiencing? I've just checked and that snippet does what I would expect. Are you on latest opam-nix? |
Describe the bug
Opam-nix seems not to look for
pin-depends
.I've been trying to experiment with
yocaml
. It seems not to have been published to opam yet, and people seem to be usingpin-depends
as a way to use it in their projects?I searched on the
opam-nix
repo and it seems likepin-depends
is not mentioned, so maybe it is not yet supported? I understand that it might be tricky to do this while maintaining reproducibility however? So I'm not sure what that would look like.To Reproduce
flake.nix
dune-project
bin/dune
bin/garden.ml
garden.opam.template
After running
nix build
I get:nix log ...-garden-local.drv
The generated opam file is:
/nix/store/...-source-copy/garden.opam
Expected behavior
The build should find the dependencies
Environment
OS name + version: aarch64-darwin, macOS 12.1
Version of the code:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: