Skip to content

Commit

Permalink
New nix infrastructure
Browse files Browse the repository at this point in the history
- documenting the config file
- entries in ref.yml
  • Loading branch information
CohenCyril committed Mar 12, 2021
1 parent 6d0eada commit 2d149ea
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 94 deletions.
4 changes: 4 additions & 0 deletions coq-nix-toolbox.nix.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file was generated from meta.yml, please do not edit manually.
# Follow the instructions on https://github.com/coq-community/templates to regenerate.
# However, it not handled by mustache, but by a special eval command
\"$(git ls-remote https://github.com/coq-community/coq-nix-toolbox refs/heads/master | cut -f1)\"
62 changes: 31 additions & 31 deletions default.nix.mustache
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# This file was generated from `meta.yml`, please do not edit manually.
# Follow the instructions on https://github.com/coq-community/templates to regenerate.

{ pkgs ? (import <nixpkgs> {}), coq-version-or-url, shell ? false }:

{{# nix-default}}
{ config ? {}, withEmacs ? false, print-env ? false, do-nothing ? false,
update-nixpkgs ? false, ci-matrix ? false, ci-job ? null,
override ? {}, ocaml-override ? {}, global-override ? {},
ci ? (!isNull ci-job), inNixShell ? null
}@args:
let
coq-version-parts = builtins.match "([0-9]+).([0-9]+)" coq-version-or-url;
coqPackages =
if coq-version-parts == null then
pkgs.mkCoqPackages (import (fetchTarball coq-version-or-url) {})
else
pkgs."coqPackages_${builtins.concatStringsSep "_" coq-version-parts}";
{{# src}}
auto = {{src}};
{{/ src}}
{{^ src}}
auto = let p = ./nix/.coq-nix-toolbox.nix; in fetchGit {
url = "{{url}}{{^ url}}https://github.com/{{owner}}{{^ owner}}coq-community{{/ owner}}/coq-nix-toolbox.git{{/ url}}";
ref = "{{ref}}{{^ ref}}master{{/ ref}}";
rev = import ./.nix/coq-nix-toolbox.nix;
};
{{/ src}}
in
(import auto ({src = ./.;} // args)).{{attribute}}{{^ attribute}}nix-auto{{/ attribute}}
{{/ nix-default}}
{{^ nix-default}}
{ config ? {}, withEmacs ? false, print-env ? false, do-nothing ? false,
update-nixpkgs ? false, ci-matrix ? false, ci-job ? null,
override ? {}, ocaml-override ? {}, global-override ? {},
ci ? (!isNull ci-job), inNixShell ? null
}@args:
let auto = fetchGit {
url = "https://github.com/coq-community/coq-nix-toolbox.git";
ref = "master";
rev = import ./.nix/coq-nix-toolbox.nix;
}; in
(import auto ({src = ./.;} // args)).nix-auto
{{/ nix-default}}

with coqPackages;

pkgs.stdenv.mkDerivation {
name = "{{ shortname }}";
{{# plugin }}
buildInputs = with coq.ocamlPackages; [ ocaml findlib ]
++ pkgs.lib.optionals shell [ merlin ocp-indent ocp-index ];

{{/ plugin }}
propagatedBuildInputs = [
coq
{{# dependencies }}
{{ nix }}
{{/ dependencies }}
];

src = if shell then null else ./.;

installFlags = "COQMF_COQLIB=$(out)/lib/coq/${coq.coq-version}/";
}
77 changes: 77 additions & 0 deletions fallback-config.nix.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This file was generated from `meta.yml`, please do not edit manually.
# Follow the instructions on https://github.com/coq-community/templates to regenerate.

# *However*, you may copy paste it to `config.nix`
# in the same subdirectory .nix and extend it as needed.
# Note that this would completely deactivate this file.

{
## DO NOT CHANGE THIS
format = "1.0.0";
## unless you made an automated or manual update
## to another supported format.
## The attribute to build, either from nixpkgs
## of from the overlays located in `.nix/coq-overlays`
coq-attribute = "{{nix_name}}";
## If you want to select a different attribute
## to serve as a basis for nix-shell edit this
# coq-shell-attribute = "{{nix_name}}";
## Maybe the shortname of the library is different from
## the name of the nixpkgs attribute, if so, set it here:
{{^ shortname}}#{{/ shortname}}pname = "{{ shortname }}";

## Lists the dependencies, phrased in terms of nix attributes.
## No need to list Coq, it is already included.
## These dependencies will systematically be added to the currently
## known dependencies, if any more than Coq.
## /!\ Remove this field as soon as the package is available on nixpkgs.
## /!\ Manual overlays in `.nix/coq-overlays` should be preferred then.
{{^ nix-dependencies}}#{{/ nix-dependencies}}buildInputs = [ {{# nix-dependencies }}"{{.}}" {{/ nix-dependencies }}];

## Indicate the relative location of your _CoqProject
## If not specified, it defaults to "_CoqProject"
# coqproject = "_CoqProject";

## select an entry to build in the following `tasks` set
## defaults to "default"
select = "default";

## write one `tasks.name` attribute set per
## alternative configuration, the can be used to
## compute several ci jobs as well
tasks.default = {
## You can override Coq and other Coq coqPackages
## through the following attribute
# coqPackages.coq.override.version = "8.11";
## In some cases, light overrides are not available/enough
## in which case you can use either
# coqPackages.<coq-pkg>.overrideAttrs = o: <overrides>;
## or a "long" overlay to put in `.nix/coq-overlays
## you may use `nix-shell --run fetchOverlay <coq-pkg>`
## to automatically retrieve the one from nixpkgs
## if it exists and is correctly named/located
## You can override Coq and other Coq coqPackages
## throught the following attribute
## If <ocaml-pkg> does not support lights overrides,
## you may use `overrideAttrs` or long overlays
## located in `.nix/ocaml-overlays`
## (there is no automation for this one)
# ocamlPackages.<ocaml-pkg>.override.version = "x.xx";
## You can also override packages from the nixpkgs toplevel
# <nix-pkg>.override.overrideAttrs = o: <overrides>;
## Or put an overlay in `.nix/overlays`
## you may mark a package as a CI job as follows
# coqPackages.<another-pkg>.ci.job = "test";
## It can then be built throught
## nix-build --argstr ci "default" --arg ci-job "test";
};
}
58 changes: 41 additions & 17 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ get_yaml() {

for f in "$srcdir"/{,.}*.mustache; do
target=$(basename "$f" .mustache)
eval_instead_of_mustache=false
case "$target" in
coq.opam)
mustache='{{ opam_name }}'
opam_name=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$opam_name" ]; then
target=${target/coq/$opam_name}
else
mustache='{{ shortname }}'
shortname=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$shortname" ]; then
target=${target/coq/coq-$shortname}
if [ -n "$opam_name" ]; then
target=${target/coq/$opam_name}
else
continue
fi
mustache='{{ shortname }}'
shortname=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$shortname" ]; then
target=${target/coq/coq-$shortname}
else
continue
fi
fi
;;
extracted.opam)
Expand Down Expand Up @@ -95,20 +96,39 @@ for f in "$srcdir"/{,.}*.mustache; do
continue
fi
;;
config.yml)
mustache='{{ circleci }}'
bool=$(get_yaml meta.yml <<<"$mustache")
config.yml)
mustache='{{ circleci }}'
bool=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$bool" ] && [ "$bool" != false ]; then
mkdir -p -v .circleci && target=".circleci/$target"
else
continue
fi
;;
default.nix)
mustache='{{ nix }}'
bool=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$bool" ] && [ "$bool" != false ]; then
mkdir -p -v .circleci && target=".circleci/$target"
: noop
else
continue
fi
;;
default.nix)
coq-nix-toolbox.nix)
mustache='{{ nix }}'
bool=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$bool" ] && [ "$bool" != false ]; then
: noop
mkdir -p -v .nix && target=".nix/$target"
eval_instead_of_mustache=true
else
continue
fi
;;
fallback-config.nix)
mustache='{{ nix }}'
bool=$(get_yaml meta.yml <<<"$mustache")
if [ -n "$bool" ] && [ "$bool" != false ]; then
mkdir -p -v .nix && target=".nix/$target"
else
continue
fi
Expand All @@ -123,6 +143,10 @@ for f in "$srcdir"/{,.}*.mustache; do
if [ $# -gt 0 ] && [ $listed != true ]; then
continue
fi
echo "Generating $target..."
mustache meta.yml "$f" > "$target"
echo "Generating $target"
if [ "$eval_instead_of_mustache" = true ]; then
eval "echo \"$(cat $f)\"" > "$target"
else
mustache meta.yml "$f" > "$target"
fi
done
Loading

0 comments on commit 2d149ea

Please sign in to comment.