HI. I had been trying use coq via nix.
But I had got it installed with nix-env and saw at https://nixos.org/guides/nix-pills/developing-with-nix-shell.html that it is not the best way.
Which other way would be good?
I am a total novice at nix, but had been using it without really knowing what is happening underneath. It worked okay till I tried install mathcomp library. But it wouldn't show up even when coq is there.
Found the stuff at https://github.com/coq-community/coq-nix-toolbox/ but had been hoping to have something more basic that we ourselves write. So that we would be in a position to at least attempt to fix it when something goes wrong.
I guess metacoq is not in nix.
I tried this as shell.nix:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
pkgs.coq_8_13
pkgs.coqPackages.mathcomp
];
}
and did nix-shell default.nix
.
The resulting shell has coqc v8.13 but it can't get mathcomp:
[nix-shell:~]$ coqtop
Welcome to Coq 8.13.2 (January 1980)
Coq < From mathcomp Require Import all_ssreflect.
Toplevel input, characters 29-42:
> From mathcomp Require Import all_ssreflect.
> ^^^^^^^^^^^^^
Error: Cannot find a physical path bound to logical path matching suffix
<> and prefix mathcomp.
Any idea why this is happening?
I haven't got any opam package installations now, but can opam installations and nix packages work together?
pkgs.coqPackages might not be the one for 8.13. (I cannot remember what is the default at the current master or unstable version of nixpkgs)
You should either do:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
pkgs.coq
pkgs.coqPackages.mathcomp
];
}
or
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
pkgs.coq_8_13
pkgs.coqPackages_8_13.mathcomp
];
}
But not mix versions...
Another way to write it in a more "uniform way" is:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs.coqPackages; [ coq mathcomp ];
}
Julin S said:
I guess metacoq is not in nix.
You don't even need a shell.nix
. You can just do nix-shell -p coq_8_13 coqPackages_8_13.mathcomp
and it should work.
I wonder why the metacoq package is not showing up in search.nixos.org?
I searched 'metacoq' but it said 'no packages found'.
(Sorry had to be away for a few days.)
And doing using the nix file that Cyril mentioned made mathcomp work as well.
Thanks!
How would we install metacoq via nix though?
I tried this:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
pkgs.coq_8_13
pkgs.coqPackages_8_13.mathcomp
pkgs.coqPackages_8_13.metacoq
];
}
But that said 'attribute metacoq missing'.
Oh I see that metacoq was a recent addition to nix: https://github.com/NixOS/nixpkgs/pull/162639
And I'm using an old nix channel (21.11) maybe that's the reason?
But why isn't metacoq showing up at nix.search.org though? Even in unstable channel.
No, that's not the actually reason. The reason is that the version of metacoq compatible with Coq 8.13 is not activated in coqPackages by default.
However, this version is still available. You can get it by doing a package override.
Though, you also need to override the equations version according to this comment, and I'm not completely sure how to do this without relying on the Coq Nix Toolbox.
Another solution would be to add versions 1.0 for Coq 8.14 and 8.15. This would avoid having to override the Equations version.
Last updated: Jun 10 2023 at 23:01 UTC