├── .gitignore ├── coq-shell └── Makefile ├── emacs-init.el ├── .nix ├── nixpkgs.nix ├── fallback-config.nix └── shellHook.sh ├── project-default.nix ├── LICENSE ├── config-parser-1.0.0 ├── ci.nix ├── normalize.nix ├── overlays.nix └── default.nix ├── deps.nix ├── template-overlay.nix ├── .github └── workflows │ ├── nix-action-rocq-master.yml │ ├── nix-action-master.yml │ ├── nix-action-rocq-9.0.yml │ └── nix-action-rocq-9.1.yml ├── template-config.nix ├── default.nix ├── action.nix └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /coq-shell/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: install 2 | install: 3 | echo "this is a fake package" 4 | -------------------------------------------------------------------------------- /emacs-init.el: -------------------------------------------------------------------------------- 1 | (require 'proof-site) 2 | (require 'cl) 3 | (require 'cl-extra) 4 | (when (fboundp 'electric-indent-mode) (electric-indent-mode 0)) 5 | (setq evil-want-abbrev-expand-on-insert-exit nil) 6 | -------------------------------------------------------------------------------- /.nix/nixpkgs.nix: -------------------------------------------------------------------------------- 1 | fetchTarball { 2 | url = "https://github.com/NixOS/nixpkgs/archive/44ac20273df09e0ea9a85d3776df059cf0c871d9.tar.gz"; 3 | sha256 = "0ysk2y41sq769lbqp8iq4yja0d9wxw53lm6fl805w5nqyxf29vr5"; 4 | } 5 | -------------------------------------------------------------------------------- /project-default.nix: -------------------------------------------------------------------------------- 1 | { config ? {}, withEmacs ? false, print-env ? false, do-nothing ? false, 2 | update-nixpkgs ? false, ci-matrix ? false, 3 | override ? {}, coq-override ? {}, ocaml-override ? {}, global-override ? {}, 4 | bundle ? null, job ? null, inNixShell ? null, src ? ./., 5 | }@args: 6 | let auto = fetchGit { 7 | url = "https://github.com/coq-community/coq-nix-toolbox.git"; 8 | ref = "master"; 9 | rev = import .nix/coq-nix-toolbox.nix; 10 | }; 11 | in 12 | import auto ({inherit src;} // args) 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 coq-community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config-parser-1.0.0/ci.nix: -------------------------------------------------------------------------------- 1 | { lib, pkgs, this-shell-pkg, bundle }: 2 | with builtins; with lib; 3 | let 4 | dependencies = (this-shell-pkg.nativeBuildInputs or []) ++ 5 | (this-shell-pkg.buildInputs or []) ++ 6 | (this-shell-pkg.propagatedBuildInputs or []); 7 | collect-job = v: if v?job && v.job != "_excluded" then [ v.job ] else []; 8 | collect-jobs = p: flatten (map collect-job (attrValues p)); 9 | bundle-packages = (bundle.coqPackages or {}) // (bundle.rocqPackages or {}); 10 | jobs = collect-jobs bundle-packages; 11 | excluded-pkg = n: v: if v?job && v.job == "_excluded" then [ n ] else []; 12 | excluded = flatten (mapAttrsToList excluded-pkg bundle-packages); 13 | main-job = v: if (v.main-job or false) && (v.job or "" != "_excluded") 14 | then [ v.job ] else []; 15 | main-jobs = p: flatten (map main-job (attrValues p)); 16 | mains = main-jobs bundle-packages; 17 | keep_ = tgt: job: (job != "_excluded") 18 | && (tgt == "_all" || tgt == job 19 | || (tgt == "_allJobs" && elem job jobs)); 20 | pkgs-packages = (pkgs.coqPackages or {}) // (pkgs.rocqPackages or {}); 21 | subpkgs = job: 22 | let keep = n: v: keep_ job (bundle-packages.${n}.job or n); in 23 | attrValues (filterAttrs keep pkgs-packages) 24 | ++ optionals (job == "_deps") dependencies; 25 | in 26 | { 27 | inherit jobs subpkgs excluded mains; 28 | set = listToAttrs (map (job: {name = job; value = subpkgs job; }) jobs); 29 | } 30 | -------------------------------------------------------------------------------- /.nix/fallback-config.nix: -------------------------------------------------------------------------------- 1 | with (import (import ./nixpkgs.nix) {}).lib; 2 | { 3 | ## DO NOT CHANGE THIS 4 | format = "1.0.0"; 5 | ## unless you made an automated or manual update 6 | ## to another supported format. 7 | 8 | ## The attribute to build, either from nixpkgs 9 | ## of from the overlays located in `.nix/rocq-overlays` or `.nix/coq-overlays` 10 | attribute = "rocq-core"; 11 | coq-attribute = "coq"; 12 | shell-attribute = "coq-shell"; 13 | src = ../coq-shell; 14 | 15 | ## select an entry to build in the following `bundles` set 16 | ## defaults to "default" 17 | default-bundle = "9.0"; 18 | 19 | ## write one `bundles.name` attribute set per 20 | ## alternative configuration, the can be used to 21 | ## compute several ci jobs as well 22 | bundles = (genAttrs [ "8.18" "8.19" "8.20" ] 23 | (v: { 24 | rocqPackages.rocq-core.override.version = v; 25 | rocqPackages.rocq-core.job = false; 26 | coqPackages.coq.override.version = v; 27 | })) // (genAttrs [ "9.0" "9.1" ] 28 | (v: { 29 | rocqPackages.rocq-core.override.version = v; 30 | coqPackages.coq.override.version = v; 31 | })) // { 32 | master = { 33 | rocqPackages.rocq-core.override.version = "master"; 34 | coqPackages.coq.override.version = "master"; 35 | coqPackages.heq.job = false; 36 | coqPackages.stdlib.job = false; 37 | }; 38 | "rocq-9.0" = { 39 | rocqPackages.rocq-core.override.version = "9.0"; 40 | }; 41 | "rocq-9.1" = { 42 | rocqPackages.rocq-core.override.version = "9.1"; 43 | }; 44 | "rocq-master" = { 45 | rocqPackages.rocq-core.override.version = "master"; 46 | }; 47 | }; 48 | 49 | cachix.coq = {}; 50 | cachix.math-comp = {}; 51 | cachix.coq-community.authToken = "CACHIX_AUTH_TOKEN"; 52 | } 53 | -------------------------------------------------------------------------------- /config-parser-1.0.0/normalize.nix: -------------------------------------------------------------------------------- 1 | # This file is a toolbox file to parse a ./nix/config.nix 2 | # file in format 1.0.0 3 | {lib, config, nixpkgs, src}@initial: 4 | with builtins; with lib; 5 | let 6 | normalize-coqpkg = name: pkg: let j = pkg.job or name; in 7 | pkg // { job = switch j [ 8 | { case = true; out = name; } 9 | { case = false; out = "_excluded"; } 10 | { case = isString; out = j; } 11 | ] (throw '' 12 | config-parser-1.0.0 normalize: job must be either: 13 | - true (the name of the job is the one of the attribute, 14 | this is the default behaviour) 15 | - false (the package is excluded from CI, always) 16 | - "_excluded" (the package is excluded from CI, always) 17 | - "_deps" (the package is considered by the CI as a dependency) 18 | - "_allJobs" (the job is triggered only when testing all existing jobs) 19 | - "_all" (the job is triggered only when testing all coqPackages) 20 | - a string which corresponds both to the job name 21 | and an attribute in coqPackages. 22 | ''); }; 23 | normalize-pkg = name: pkg: 24 | if name != "rocqPackages" && name != "coqPackages" then pkg else 25 | mapAttrs normalize-coqpkg pkg; 26 | normalize-bundle = _name: b: 27 | mapAttrs normalize-pkg b 28 | // { isRocq = b ? rocqPackages && !(b ? coqPackages); }; 29 | in rec { 30 | format = "1.0.0"; 31 | attribute = config.attribute or "template"; 32 | coq-attribute = config.coq-attribute or attribute; 33 | shell-attribute = config.shell-attribute or attribute; 34 | no-rocq-yet = config.no-rocq-yet or false; 35 | nixpkgs = config.nixpkgs or initial.nixpkgs; 36 | pname = config.pname or attribute; 37 | shell-pname = config.shell-pname or pname; 38 | coqproject = config.coqproject or "_CoqProject"; 39 | default-bundle = config.default-bundle or "default"; 40 | cachix = config.cachix or { coq = {}; }; 41 | bundles = mapAttrs normalize-bundle 42 | (config.bundles or { default = {}; }); 43 | buildInputs = config.buildInputs or []; 44 | src = config.src or 45 | (if pathExists (/. + initial.src) 46 | -> pathExists (/. + initial.src + "/.git") 47 | then fetchGit ( 48 | if false # replace by a version check when supported 49 | # cf https://github.com/NixOS/nix/issues/1837 50 | then { url = initial.src; shallow = true; } else initial.src) 51 | else /. + initial.src); 52 | } 53 | -------------------------------------------------------------------------------- /deps.nix: -------------------------------------------------------------------------------- 1 | # IDEA: do most of the resolution on longnames 2 | # check why we need shortnames as output? 3 | 4 | # shortname: mathcomp-ssreflect 5 | # longname: coq8.20-mathcomp-ssreflect-2.2.0 6 | { lib, coqPackages }: 7 | with builtins; with lib; 8 | let 9 | # keep all derivations inside coqPackages 10 | initialCoqPkgs = filterAttrs (_: isDerivation) coqPackages; 11 | # building a map longnames -> shortnames 12 | canonicalShortname = 13 | mapAttrs' (n: v: { name = "${v.name}"; value = n; }) initialCoqPkgs; 14 | # probably filtering out duplicates? (mathcomp-ssreflect = ssreflect,...) 15 | # keeping only packages whose shortname is the canonical one (determined just above) 16 | coqPkgs = filterAttrs (sn: _: elem sn (attrValues canonicalShortname)) initialCoqPkgs; 17 | # a map name -> list (shortname of derivations from {propagatedB,b}uildInputs) 18 | # keeping only derivations in coqPackages 19 | pkgsDeps = 20 | let 21 | # takes a derivation [x] as input and outputs a list 22 | # [ shortname of x ] if it exists, or [] 23 | findInput = x: let n = if isNull x then null else 24 | canonicalShortname."${x.name}" or null; in 25 | if isNull n then [ ] else [ n ]; 26 | # flattens arbitrary nested list in a list 27 | # whose elements are not lists anymore 28 | deepFlatten = l: if !isList l then l else if l == [] then [] else 29 | (if isList (head l) then deepFlatten (head l) else [ (head l) ]) 30 | ++ deepFlatten (tail l); 31 | in 32 | flip mapAttrs coqPkgs (n: v: flatten 33 | (map findInput (deepFlatten [v.buildInputs v.propagatedBuildInputs])) 34 | ); 35 | # list of all canonical shortnames, topologically sorted 36 | # according to dependencies (first has no dependencies) 37 | pkgsSorted = (toposort (x: y: elem x pkgsDeps.${y}) (attrNames coqPkgs)).result; 38 | # done: map canonical shortname -> its currently known reverse dependencies 39 | # as an attrSet shortname -> bool (where the boolean is always true) 40 | pkgsRevDepsSetNoAlias = foldl (done: p: foldl (done: d: 41 | done // { ${p} = done.${p} or {}; } 42 | // { ${d} = (done.${d} or {}) // { ${p} = true;} // (done.${p} or {});} 43 | ) done pkgsDeps.${p} 44 | ) {} (reverseList pkgsSorted); 45 | # map shortname -> set of shortnames (encoded as above) 46 | # for all shortnames (not just canonical ones) 47 | pkgsRevDepsSet = mapAttrs 48 | (_: p: let pname = canonicalShortname.${p.name} or p.name; in 49 | pkgsRevDepsSetNoAlias.${pname} or {}) initialCoqPkgs; 50 | # map shortname -> list of shortnames 51 | pkgsRevDeps = mapAttrs (n: v: attrNames v) pkgsRevDepsSet; 52 | in 53 | { 54 | inherit pkgsDeps pkgsRevDeps pkgsRevDepsSet; 55 | } 56 | -------------------------------------------------------------------------------- /template-overlay.nix: -------------------------------------------------------------------------------- 1 | ## File initially generated by createOverlay 2 | ## and then supposedly modified manually. 3 | ## Some hints for manual modifications are in the file, 4 | ## but the full doc is on nixos / nix packages website: 5 | ## https://nixos.org/manual/nixpkgs/stable/#sec-language-coq 6 | 7 | { lib, mkCoqDerivation, which, coq 8 | ## declare extra dependencies here, to be used in propagateBuildInputs e.g. 9 | # , mathcomp, coq-elpi 10 | , version ? null }: 11 | 12 | with lib; mkCoqDerivation { 13 | pname = "template"; 14 | ## you can configure the domain, owner and repository, the default are: 15 | # repo = "template"; 16 | # owner = "coq-community"; 17 | # domain = "github.com"; 18 | 19 | inherit version; 20 | ## The `defaultVersion` attribute is important for nixpkgs but can be kept unchanged 21 | ## for local usage since it will be ignored locally if 22 | ## - this derivation corresponds to the main attribute, 23 | ## - or its version is overridden (by a branch, PR, url or path) in `.nix/config.nix`. 24 | defaultVersion = with versions; switch coq.coq-version [ 25 | ## Example of possible dependencies 26 | # { case = range "8.13" "8.14"; out = "1.2.0"; } 27 | ## other predicates are `isLe v`, `isLt v`, `isGe v`, `isGt v`, `isEq v` etc 28 | ] null; 29 | 30 | ## Declare existing releases 31 | ## leave sha256 empty at first and then copy paste 32 | ## the resulting sha given by the error message 33 | # release."1.1.1".sha256 = ""; 34 | ## if the tag is not exactly the version number you can amend like this 35 | # release."1.1.1".rev = "v1.1.1"; 36 | ## if a consistent scheme gives the tag from the release number, you can do like this: 37 | # releaseRev = v: "v${v}"; 38 | 39 | ## Add dependencies in here. In particular you can add 40 | ## - arbitrary nix packages (you need to require them at the beginning of the file) 41 | ## - Coq packages (require them at the beginning of the file) 42 | ## - OCaml packages (use `coq.ocamlPackages.xxx`, no need to require them at the beginning of the file) 43 | # propagatedBuildInputs = [ ]; ## e.g. `= [ mathcomp coq-elpi ]` 44 | 45 | ## Does the package contain OCaml code? 46 | # mlPlugin = false; 47 | 48 | ## Give some meta data 49 | ## This is needed for submitting the package to nixpkgs but not required for local use. 50 | meta = { 51 | ## Describe your package in one sentence 52 | # description = ""; 53 | ## Kindly ask one of these people if they want to be an official maintainer. 54 | ## (You might also consider adding yourself to the list of maintainers) 55 | # maintainers = with maintainers; [ cohencyril siraben vbgl Zimmi48 ]; 56 | ## Pick a license from 57 | ## https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix 58 | # license = licenses.mit; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /.github/workflows/nix-action-rocq-master.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | rocq-core: 3 | needs: [] 4 | runs-on: ubuntu-latest 5 | steps: 6 | - name: Determine which commit to initially checkout 7 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 8 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 9 | }}\" >> $GITHUB_ENV\nfi\n" 10 | - name: Git checkout 11 | uses: actions/checkout@v6 12 | with: 13 | fetch-depth: 0 14 | ref: ${{ env.target_commit }} 15 | - name: Determine which commit to test 16 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 17 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 18 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 19 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 20 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 21 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 22 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 23 | \ fi\nfi\n" 24 | - name: Git checkout 25 | uses: actions/checkout@v6 26 | with: 27 | fetch-depth: 0 28 | ref: ${{ env.tested_commit }} 29 | - name: Cachix install 30 | uses: cachix/install-nix-action@v31 31 | with: 32 | nix_path: nixpkgs=channel:nixpkgs-unstable 33 | - name: Cachix setup coq-community 34 | uses: cachix/cachix-action@v16 35 | with: 36 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 37 | extraPullNames: coq, math-comp 38 | name: coq-community 39 | - id: stepGetDerivation 40 | name: Getting derivation for current job (rocq-core) 41 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 42 | \"rocq-master\" --argstr job \"rocq-core\" \\\n --dry-run 2> err > out || 43 | (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting 44 | derivation failed\"; exit 1; fi\n" 45 | - id: stepCheck 46 | name: Checking presence of CI target for current job 47 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 48 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 49 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 50 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 51 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 52 | - if: steps.stepCheck.outputs.status != 'fetched' 53 | name: Building/fetching current CI target 54 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 55 | "rocq-master" --argstr job "rocq-core" 56 | name: Nix CI for bundle rocq-master 57 | on: 58 | pull_request: 59 | paths: 60 | - .github/workflows/nix-action-rocq-master.yml 61 | pull_request_target: 62 | paths-ignore: 63 | - .github/workflows/nix-action-rocq-master.yml 64 | types: 65 | - opened 66 | - synchronize 67 | - reopened 68 | push: 69 | branches: 70 | - master 71 | -------------------------------------------------------------------------------- /config-parser-1.0.0/overlays.nix: -------------------------------------------------------------------------------- 1 | { overlays-dir, lib, rocq-overlays-dir, coq-overlays-dir, ocaml-overlays-dir, bundle, 2 | attribute, coq-attribute, no-rocq-yet, pname, shell-attribute, shell-pname, src }: 3 | with builtins; with lib; 4 | let 5 | mk-overlay = path: self: super: 6 | if !pathExists path then {} else 7 | let 8 | hasDefault = p: (readDir p)?"default.nix"; 9 | isOverlay = x: ty: ty == "directory" && hasDefault (path + "/${x}"); 10 | overlays = filterAttrs isOverlay (readDir path); 11 | in 12 | mapAttrs (x: _: self.callPackage (path + "/${x}") {}) overlays; 13 | do-override = pkg: cfg: 14 | let pkg' = if cfg?override 15 | then pkg.override or (x: pkg) cfg.override else pkg; in 16 | if cfg?overrideAttrs 17 | then pkg'.overrideAttrs cfg.overrideAttrs else pkg'; 18 | nixpkgs-overrides = 19 | self: super: mapAttrs (n: ov: do-override super.${n} ov) 20 | (removeAttrs bundle [ "rocqPackages" "coqPackages" "ocamlPackages" ]); 21 | ocaml-overrides = 22 | self: super: mapAttrs (n: ov: do-override super.${n} ov) 23 | (bundle.ocamlPackages or {}); 24 | rocq-overrides = 25 | self: super: 26 | let newRocqPkg = pname: args: makeOverridable self.mkRocqDerivation 27 | { inherit pname; version = "${src}"; } // args; 28 | in 29 | mapAttrs (n: ov: do-override (super.${n} or 30 | (switch n (optionals (!no-rocq-yet) [ 31 | { case = attribute; out = newRocqPkg pname {}; } 32 | { case = shell-attribute; out = newRocqPkg shell-pname {}; } 33 | ]) (newRocqPkg n ((super.${n}.mk or (_: {})) self)) 34 | )) ov) (bundle.rocqPackages or {}); 35 | coq-overrides = 36 | self: super: 37 | let newCoqPkg = pname: args: makeOverridable self.mkCoqDerivation 38 | { inherit pname; version = "${src}"; } // args; 39 | in 40 | mapAttrs (n: ov: do-override (super.${n} or 41 | (switch n [ 42 | { case = coq-attribute; out = newCoqPkg pname {}; } 43 | { case = shell-attribute; out = newCoqPkg shell-pname {}; } 44 | ] (newCoqPkg n ((super.${n}.mk or (_: {})) self)) 45 | )) ov) (bundle.coqPackages or {}); 46 | fold-override = foldl (fpkg: override: fpkg.overrideScope override); 47 | in 48 | [ 49 | (mk-overlay overlays-dir) 50 | nixpkgs-overrides 51 | (self: super: { rocqPackages = fold-override super.rocqPackages ([ 52 | (mk-overlay rocq-overlays-dir) 53 | rocq-overrides 54 | (self: super: { rocq-core = super.rocq-core.override { 55 | customOCamlPackages = fold-override super.rocq-core.ocamlPackages [ 56 | (mk-overlay ocaml-overlays-dir) 57 | ocaml-overrides 58 | ];};}) 59 | ]);}) 60 | (self: super: { rocqPackages = 61 | super.rocqPackages.filterPackages 62 | (! (super.rocqPackages.rocq-core.dontFilter or false)); }) 63 | (self: super: { coqPackages = fold-override super.coqPackages ([ 64 | (self2: super2: { coq = super2.coq.override { 65 | rocqPackages = super.rocqPackages; 66 | };}) 67 | (mk-overlay coq-overlays-dir) 68 | coq-overrides 69 | (self: super: { coq = super.coq.override { 70 | customOCamlPackages = fold-override super.coq.ocamlPackages [ 71 | (mk-overlay ocaml-overlays-dir) 72 | ocaml-overrides 73 | ];};}) 74 | ]);}) 75 | (self: super: { coqPackages = 76 | super.coqPackages.filterPackages 77 | (! (super.coqPackages.coq.dontFilter or false)); }) 78 | ] 79 | -------------------------------------------------------------------------------- /config-parser-1.0.0/default.nix: -------------------------------------------------------------------------------- 1 | # This file is a toolbox file to parse a ./nix/config.nix 2 | # file in format 1.0.0 3 | with builtins; 4 | { config, # in format 1.0.0 5 | nixpkgs, # source directory for nixpkgs to provide overlays 6 | pkgs ? import ../nixpkgs {}, # some instance of pkgs for libraries 7 | src ? ./., # the source directory 8 | overlays-dir, 9 | rocq-overlays-dir, 10 | coq-overlays-dir, 11 | ocaml-overlays-dir, 12 | override ? {}, 13 | coq-override ? {}, 14 | ocaml-override ? {}, 15 | global-override ? {}, 16 | lib, 17 | }@initial: 18 | with lib; 19 | let config = import ./normalize.nix 20 | { inherit (initial) src lib config nixpkgs; }; 21 | in with config; let 22 | 23 | bundle-ppaths = bundle: 24 | let 25 | path-to-attribute = config.path-to-attribute or [ "rocqPackages" ]; 26 | coq-path-to-attribute = config.path-to-attribute or [ "coqPackages" ]; 27 | path-to-shell-attribute = 28 | if hasAttr config.shell-attribute (bundle.rocqPackages or {}) 29 | then path-to-attribute else coq-path-to-attribute; 30 | in { 31 | # not configurable from config.nix: 32 | rocq = path-to-attribute ++ [ config.attribute ]; 33 | coq = coq-path-to-attribute ++ [ config.coq-attribute ]; 34 | shell = path-to-shell-attribute ++ [ config.shell-attribute ]; 35 | }; 36 | 37 | # preparing bundles 38 | bundles = let 39 | mk-main = path: j: 40 | setAttrByPath path 41 | { override.version = "${config.src}"; 42 | job = j; 43 | main-job = true; }; 44 | mk-bundles = pre: x: 45 | setAttrByPath pre (mapAttrs (n: v: {override.version = v;}) x); 46 | in mapAttrs 47 | (_: i: 48 | let ppaths = bundle-ppaths i; in 49 | foldl recursiveUpdate {} ( 50 | optional (i ? coqPackages) (mk-main ppaths.shell config.shell-attribute) 51 | ++ optional ((i ? rocqPackages) && !(config.no-rocq-yet)) (mk-main ppaths.rocq config.attribute) 52 | ++ optional (i ? coqPackages) (mk-main ppaths.coq config.coq-attribute) 53 | ++ [ 54 | i 55 | (mk-bundles [ "rocqPackages" ] override) 56 | (mk-bundles [ "coqPackages" ] coq-override) 57 | (mk-bundles [ "ocamlPackages" ] ocaml-override) 58 | (mk-bundles [ ] global-override) 59 | ])) config.bundles; 60 | 61 | buildInputFrom = pkgs: str: 62 | pkgs.rocqPackages.${str} or pkgs.coqPackages.${str} or pkgs.ocamlPackages.${str} or pkgs.${str}; 63 | 64 | mk-instance = bundleName: bundle: let 65 | overlays = import ./overlays.nix 66 | { inherit lib overlays-dir rocq-overlays-dir coq-overlays-dir ocaml-overlays-dir bundle; 67 | inherit (config) attribute coq-attribute no-rocq-yet pname shell-attribute shell-pname src; }; 68 | 69 | pkgs = import config.nixpkgs { inherit overlays; }; 70 | 71 | ci = import ./ci.nix { inherit lib this-shell-pkg pkgs bundle; }; 72 | 73 | genCI = import ../deps.nix 74 | { inherit lib; 75 | coqPackages = 76 | (optionalAttrs (!bundle.isRocq) pkgs.coqPackages) 77 | // pkgs.rocqPackages; }; 78 | jsonPkgsDeps = toJSON genCI.pkgsDeps; 79 | jsonPkgsRevDeps = toJSON genCI.pkgsRevDeps; 80 | 81 | jobs = let 82 | jdeps = genAttrs ci.mains (n: genCI.pkgsRevDepsSet.${n} or {}); 83 | in 84 | attrNames (removeAttrs 85 | (jdeps // genAttrs ci.jobs (_: true) 86 | // foldAttrs (_: _: true) true (attrValues jdeps)) 87 | ci.excluded); 88 | 89 | inherit (import ../action.nix { inherit lib; }) mkAction; 90 | action = mkAction { 91 | inherit (config) cachix; 92 | inherit jobs; 93 | bundles = bundleName; 94 | deps = genCI.pkgsDeps; 95 | } { 96 | push-branches = bundle.push-branches or [ "master" ]; 97 | }; 98 | jsonAction = toJSON action; 99 | jsonActionFile = pkgs.writeTextFile { 100 | name = "jsonAction"; 101 | text = jsonAction; 102 | }; 103 | 104 | patchBIPkg = pkg: 105 | let bi = map (buildInputFrom pkgs) (config.buildInputs or []); in 106 | if bi == [] then pkg else 107 | pkg.overrideAttrs (o: { buildInputs = o.buildInputs ++ bi;}); 108 | 109 | ppaths = bundle-ppaths bundle; 110 | notfound-ppath = throw "config-parser-1.0.0: not found: ${toString ppaths.coq}"; 111 | notfound-shell-ppath = throw "config-parser-1.0.0: not found: ${toString ppaths.shell}"; 112 | this-pkg = patchBIPkg (attrByPath ppaths.coq notfound-ppath pkgs); 113 | this-shell-pkg = patchBIPkg (attrByPath ppaths.shell (attrByPath ppaths.coq notfound-ppath pkgs) pkgs); 114 | 115 | in rec { 116 | inherit bundle pkgs this-pkg this-shell-pkg ci; 117 | inherit jsonPkgsDeps jsonPkgsRevDeps; 118 | inherit action jsonActionFile; 119 | inherit jobs; 120 | jsonBundle = toJSON bundle; 121 | }; 122 | in 123 | { 124 | instances = mapAttrs mk-instance bundles; 125 | inherit bundles config; 126 | } 127 | -------------------------------------------------------------------------------- /template-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | ## DO NOT CHANGE THIS 3 | format = "1.0.0"; 4 | ## unless you made an automated or manual update 5 | ## to another supported format. 6 | 7 | ## The attribute to build from the local sources, 8 | ## either using nixpkgs data or the overlays located in `.nix/rocq-overlays` 9 | ## and `.nix/coq-overlays` 10 | ## Will determine the default main-job of the bundles defined below 11 | attribute = "template"; 12 | 13 | ## The attribute for coq compat shim, default to attribute 14 | ## set this when you need both to differ 15 | ## (for instance "rocq-elpi" and "coq-elpi") 16 | # coq-attribute = "template"; 17 | 18 | ## Set this when the package has no rocqPackages version yet 19 | ## (either in nixpkgs or in .nix/rocq-overlays) 20 | # no-rocq-yet = true; 21 | 22 | ## If you want to select a different attribute (to build from the local sources as well) 23 | ## when calling `nix-shell` and `nix-build` without the `--argstr job` argument 24 | # shell-attribute = "{{nix_name}}"; 25 | 26 | ## Maybe the shortname of the library is different from 27 | ## the name of the nixpkgs attribute, if so, set it here: 28 | # pname = "{{shortname}}"; 29 | 30 | ## Lists the dependencies, phrased in terms of nix attributes. 31 | ## No need to list Coq, it is already included. 32 | ## These dependencies will systematically be added to the currently 33 | ## known dependencies, if any more than Coq. 34 | ## /!\ Remove this field as soon as the package is available on nixpkgs. 35 | ## /!\ Manual overlays in `.nix/rocq-overlays` or `.nix/coq-overlays` 36 | ## should be preferred then. 37 | # buildInputs = [ ]; 38 | 39 | ## Indicate the relative location of your _CoqProject 40 | ## If not specified, it defaults to "_CoqProject" 41 | # coqproject = "_CoqProject"; 42 | 43 | ## select an entry to build in the following `bundles` set 44 | ## defaults to "default" 45 | default-bundle = "default"; 46 | 47 | ## write one `bundles.name` attribute set per 48 | ## alternative configuration 49 | ## When generating GitHub Action CI, one workflow file 50 | ## will be created per bundle 51 | bundles.default = { 52 | ## You can override Rocq and other Rocq rocqPackages 53 | ## through the following attribute 54 | # rocqPackages.rocq-core.override.version = "9.0"; 55 | 56 | ## You can override Coq and other Coq coqPackages 57 | ## through the following attribute 58 | # coqPackages.coq.override.version = "8.11"; 59 | 60 | ## In some cases, light overrides are not available/enough 61 | ## in which case you can use either 62 | # rocqPackages..overrideAttrs = o: ; 63 | # coqPackages..overrideAttrs = o: ; 64 | ## or a "long" overlay to put in `.nix/rocq-overlays` or `.nix/coq-overlays` 65 | ## you may use `nix-shell --run fetchOverlay ` 66 | ## to automatically retrieve the one from nixpkgs 67 | ## if it exists and is correctly named/located 68 | 69 | ## You can override Coq and other coqPackages 70 | ## through the following attribute 71 | ## If does not support light overrides, 72 | ## you may use `overrideAttrs` or long overlays 73 | ## located in `.nix/ocaml-overlays` 74 | ## (there is no automation for this one) 75 | # ocamlPackages..override.version = "x.xx"; 76 | 77 | ## You can also override packages from the nixpkgs toplevel 78 | # .override.overrideAttrs = o: ; 79 | ## Or put an overlay in `.nix/overlays` 80 | 81 | ## you may mark a package as a main CI job (one to take deps and 82 | ## rev deps from) as follows 83 | # coqPackages..main-job = true; 84 | ## by default the current package and its shell attributes are main jobs 85 | 86 | ## you may mark a package as a CI job as follows 87 | # rocqPackages..job = "test"; 88 | # coqPackages..job = "test"; 89 | ## It can then built through 90 | ## nix-build --argstr bundle "default" --arg job "test"; 91 | ## in the absence of such a directive, the job "another-pkg" will 92 | ## is still available, but will be automatically included in the CI 93 | ## via the command genNixActions only if it is a dependency or a 94 | ## reverse dependency of a job flagged as "main-job" (see above). 95 | 96 | ## Run on push on following branches (default [ "master" ]) 97 | # push-branches = [ "master" "branch2" ]; 98 | }; 99 | 100 | ## Cachix caches to use in CI 101 | ## Below we list some standard ones 102 | cachix.coq = {}; 103 | cachix.math-comp = {}; 104 | cachix.coq-community = {}; 105 | 106 | ## If you have write access to one of these caches you can 107 | ## provide the auth token or signing key through a secret 108 | ## variable on GitHub. Then, you should give the variable 109 | ## name here. For instance, coq-community projects can use 110 | ## the following line instead of the one above: 111 | # cachix.coq-community.authToken = "CACHIX_AUTH_TOKEN"; 112 | 113 | ## Or if you have a signing key for a given Cachix cache: 114 | # cachix.my-cache.signingKey = "CACHIX_SIGNING_KEY" 115 | 116 | ## Note that here, CACHIX_AUTH_TOKEN and CACHIX_SIGNING_KEY 117 | ## are the names of secret variables. They are set in 118 | ## GitHub's web interface. 119 | } 120 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | # This file is a toolbox file to parse a .nix directory and make 2 | # 1. a nix overlay 3 | # 2. a shell and a build derivation 4 | with builtins; 5 | let 6 | toolboxDir = ./.; 7 | get-path = src: f: let local = src + "/.nix/${f}"; in 8 | if pathExists local then local else ./. + "/.nix/${f}"; 9 | in 10 | { 11 | src ? ./., # provide the current directory 12 | config-file ? get-path src "config.nix", 13 | fallback-file ? get-path src "fallback-config.nix", 14 | nixpkgs-file ? get-path src "nixpkgs.nix", 15 | shellHook-file ? get-path src "shellHook.sh", 16 | overlays-dir ? get-path src "overlays", 17 | rocq-overlays-dir ? get-path src "rocq-overlays", 18 | coq-overlays-dir ? get-path src "coq-overlays", 19 | ocaml-overlays-dir ? get-path src "ocaml-overlays", 20 | ci-matrix ? false, 21 | config ? {}, 22 | override ? {}, 23 | coq-override ? {}, 24 | ocaml-override ? {}, 25 | global-override ? {}, 26 | withEmacs ? false, 27 | print-env ? false, 28 | do-nothing ? false, 29 | update-nixpkgs ? false, 30 | job ? null, 31 | bundle ? null, 32 | inNixShell ? null 33 | }@args: 34 | let 35 | optionalImport = f: d: 36 | if (isPath f || isString f) && pathExists f then import f else d; 37 | do-nothing = (args.do-nothing or false) || update-nixpkgs || ci-matrix; 38 | unNull = default: value: if isNull value then default else value; 39 | initial = { 40 | config = (optionalImport config-file (optionalImport fallback-file {})) 41 | // config; 42 | nixpkgs = optionalImport nixpkgs-file (throw "cannot find nixpkgs"); 43 | pkgs = import initial.nixpkgs {}; 44 | src = src; 45 | lib = (initial.pkgs.coqPackages.lib or tmp-pkgs.lib) 46 | // { diag = f: x: f x x; }; 47 | inherit overlays-dir rocq-overlays-dir coq-overlays-dir ocaml-overlays-dir; 48 | inherit global-override override coq-override ocaml-override; 49 | }; 50 | my-throw = x: throw "Coq nix toolbox error: ${x}"; 51 | in 52 | with initial.lib; let 53 | inNixShell = args.inNixShell or trivial.inNixShell; 54 | setup = switch initial.config.format [ 55 | { case = "1.0.0"; out = import ./config-parser-1.0.0 initial; } 56 | { case = x: !isString x; out = my-throw "config.format must be a string."; } 57 | ] (my-throw "config.format ${initial.config.format} not supported"); 58 | instances = setup.instances; 59 | selectedBundle = let dflt = setup.config.default-bundle; in 60 | if isNull bundle || bundle == "_all" then dflt else bundle; 61 | allBundles = bundle == "_all"; 62 | selected-instance = instances."${selectedBundle}"; 63 | shellHook = readFile shellHook-file 64 | + optionalString print-env "\nprintNixEnv; exit" 65 | + optionalString update-nixpkgs "\nupdateNixpkgsUnstable; exit" 66 | + optionalString ci-matrix "\nnixBundles; exit"; 67 | jsonBundles = toJSON (attrNames setup.bundles); 68 | jsonBundleSet = toJSON setup.bundles; 69 | jsonBundle = toJSON selected-instance.bundle; 70 | coq-lsp = if selected-instance.pkgs.coqPackages?coq-lsp then 71 | [ selected-instance.pkgs.coqPackages.coq-lsp ] else []; 72 | vscoq = if selected-instance.pkgs.coqPackages?vscoq-language-server then 73 | [ selected-instance.pkgs.coqPackages.vscoq-language-server ] else []; 74 | emacs = selected-instance.pkgs.emacs.pkgs.withPackages 75 | (epkgs: with epkgs.melpaPackages; [ proof-general ]); 76 | emacsInit = ./emacs-init.el; 77 | 78 | jsonSetupConfig = toJSON setup.config; 79 | 80 | ciByBundle = flip mapAttrs setup.instances (_: v: 81 | mapAttrs (_: x: map (x: x.name) x) v.ci.set); 82 | jsonCIbyBundle = toJSON ciByBundle; 83 | 84 | ciByJob = 85 | let 86 | jobs-list = attrValues (flip mapAttrs ciByBundle (tn: tv: 87 | flip mapAttrs tv (jn: jv: {${tn} = jv;}))); 88 | push-list = foldAttrs (n: a: [n] ++ a) []; 89 | in 90 | flip mapAttrs (push-list jobs-list) 91 | (jn: jv: mapAttrs (_: flatten) (push-list jv)); 92 | jsonCIbyJob = toJSON ciByJob; 93 | 94 | mkDeriv = shell: 95 | if !inNixShell then shell 96 | else with selected-instance; shell.overrideAttrs (old: { 97 | inherit (setup.config) nixpkgs coqproject; 98 | inherit jsonBundle jsonBundles jsonSetupConfig jsonCIbyBundle jsonBundleSet 99 | jsonCIbyJob shellHook toolboxDir selectedBundle 100 | jsonPkgsDeps jsonPkgsRevDeps jsonActionFile; 101 | 102 | bundles = attrNames setup.bundles; 103 | 104 | passthru = (old.passthru or {}) // {inherit action pkgs;}; 105 | 106 | COQBIN = optionalString (!do-nothing) ""; 107 | 108 | coq_version = optionalString (!do-nothing) 109 | pkgs.coqPackages.coq.coq-version; 110 | 111 | nativeBuildInputs = optionals (!do-nothing) 112 | ((old.nativeBuildInputs or []) ++ coq-lsp ++ vscoq) ++ [ pkgs.remarshal ]; 113 | 114 | propagatedNativeBuildInputs = optionals (!do-nothing) 115 | (old.propagatedNativeBuildInputs or []); 116 | 117 | buildInputs = optionals (!do-nothing) (old.buildInputs or []); 118 | 119 | propagatedBuildInputs = optionals (!do-nothing) 120 | (old.propagatedBuildInputs or []); 121 | } 122 | // optionalAttrs withEmacs { 123 | inherit emacsInit; 124 | emacsBin = "${emacs}" + "/bin/emacs"; 125 | }); 126 | 127 | nix-ci = job: map mkDeriv (if allBundles 128 | then flatten (mapAttrsToList (_: i: i.ci.subpkgs job) instances) 129 | else instances.${selectedBundle}.ci.subpkgs job); 130 | nix-default = if allBundles 131 | then mapAttrsToList (_: i: mkDeriv i.this-shell-pkg) instances 132 | else mkDeriv selected-instance.this-shell-pkg; 133 | nix-auto = if isNull job then nix-default else nix-ci job; 134 | in 135 | if !isDerivation nix-auto then nix-auto 136 | else nix-auto.overrideAttrs (o: { 137 | passthru = (o.passthru or {}) 138 | // { inherit initial setup shellHook; 139 | inherit nix-default nix-ci nix-auto; }; 140 | }) 141 | -------------------------------------------------------------------------------- /action.nix: -------------------------------------------------------------------------------- 1 | { lib }: 2 | with builtins; with lib; let 3 | stepCommitToInitiallyCheckout = { 4 | name = "Determine which commit to initially checkout"; 5 | run = '' 6 | if [ ''${{ github.event_name }} = "push" ]; then 7 | echo "target_commit=''${{ github.sha }}" >> $GITHUB_ENV 8 | else 9 | echo "target_commit=''${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV 10 | fi 11 | ''; 12 | }; 13 | stepCheckout1 = { 14 | name = "Git checkout"; 15 | uses = "actions/checkout@v6"; 16 | "with" = { 17 | fetch-depth = 0; 18 | ref = "\${{ env.target_commit }}"; 19 | }; 20 | }; 21 | stepCommitToTest = { 22 | name = "Determine which commit to test"; 23 | run = '' 24 | if [ ''${{ github.event_name }} = "push" ]; then 25 | echo "tested_commit=''${{ github.sha }}" >> $GITHUB_ENV 26 | else 27 | merge_commit=$(git ls-remote ''${{ github.event.repository.html_url }} refs/pull/''${{ github.event.number }}/merge | cut -f1) 28 | mergeable=$(git merge --no-commit --no-ff ''${{ github.event.pull_request.base.sha }} > /dev/null 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true) 29 | if [ -z "$merge_commit" -o "x$mergeable" != "x0" ]; then 30 | echo "tested_commit=''${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV 31 | else 32 | echo "tested_commit=$merge_commit" >> $GITHUB_ENV 33 | fi 34 | fi 35 | ''; 36 | }; 37 | stepCheckout2 = { 38 | name = "Git checkout"; 39 | uses = "actions/checkout@v6"; 40 | "with" = { 41 | fetch-depth = 0; 42 | ref = "\${{ env.tested_commit }}"; 43 | }; 44 | }; 45 | stepCachixInstall = { 46 | name = "Cachix install"; 47 | uses = "cachix/install-nix-action@v31"; 48 | "with".nix_path = "nixpkgs=channel:nixpkgs-unstable"; 49 | }; 50 | stepCachixUse = { name, authToken ? null, 51 | signingKey ? null, extraPullNames ? null }: { 52 | name = "Cachix setup ${name}"; 53 | uses = "cachix/cachix-action@v16"; 54 | "with" = { inherit name; } // 55 | (optionalAttrs (!isNull authToken) { 56 | authToken = "\${{ secrets.${authToken} }}"; 57 | }) // (optionalAttrs (!isNull signingKey) { 58 | signingKey = "\${{ secrets.${signingKey} }}"; 59 | }) // (optionalAttrs (!isNull extraPullNames) { 60 | extraPullNames = concatStringsSep ", " extraPullNames; 61 | }); 62 | }; 63 | stepCachixUseAll = cachixAttrs: let 64 | cachixList = attrValues 65 | (mapAttrs (name: v: {inherit name;} // v) cachixAttrs); in 66 | if cachixList == [] then [] else let 67 | writableAuth = filter (v: v?authToken) cachixList; 68 | writableToken = filter (v: v?signingKey) cachixList; 69 | readonly = filter (v: !v?authToken && !v?signingKey) cachixList; 70 | reordered = writableAuth ++ writableToken ++ readonly; 71 | in 72 | if length writableToken + length writableAuth > 1 then 73 | throw ("Cannot have more than one authToken " + 74 | "or signingKey over all cachix") 75 | else [ (stepCachixUse (head reordered // { 76 | extraPullNames = map (v: v.name) (tail reordered); 77 | })) ]; 78 | 79 | stepGetDerivation = { job, bundles ? [] }: 80 | let bundlestr = if isList bundles then "\${{ matrix.bundle }}" else bundles; in { 81 | name = "Getting derivation for current job (${job})"; 82 | id = "stepGetDerivation"; 83 | run = '' 84 | NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \ 85 | --argstr bundle "${bundlestr}" --argstr job "${job}" \ 86 | --dry-run 2> err > out || (touch fail; true) 87 | cat out err 88 | if [ -e fail ]; then echo "Error: getting derivation failed"; exit 1; fi 89 | ''; 90 | }; 91 | 92 | stepCheck = { 93 | name = "Checking presence of CI target for current job"; 94 | id = "stepCheck"; 95 | run = '' 96 | if $(cat out err | grep -q "built:") ; then 97 | echo "CI target needs actual building" 98 | if $(cat out err | grep -q "derivations will be built:") ; then 99 | echo "waiting a bit for derivations that should be in cache" 100 | sleep 30 101 | fi 102 | else 103 | echo "CI target already built" 104 | echo "status=fetched" >> $GITHUB_OUTPUT 105 | fi 106 | ''; 107 | }; 108 | 109 | stepBuild = {job, bundles ? [], current ? false}: 110 | let bundlestr = if isList bundles then "\${{ matrix.bundle }}" else bundles; in { 111 | name = if current then "Building/fetching current CI target" 112 | else "Building/fetching previous CI target: ${job}"; 113 | "if" = "steps.stepCheck.outputs.status != 'fetched'"; 114 | run = "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle \"${bundlestr}\" --argstr job \"${job}\""; 115 | }; 116 | 117 | mkJob = { job, jobs ? [], bundles ? [], deps ? {}, cachix ? {} }: 118 | let 119 | jdeps = deps.${job} or []; 120 | in { 121 | "${job}" = rec { 122 | runs-on = "ubuntu-latest"; 123 | needs = map (j: "${j}") (filter (j: elem j jobs) jdeps); 124 | steps = [ stepCommitToInitiallyCheckout stepCheckout1 125 | stepCommitToTest stepCheckout2 stepCachixInstall ] 126 | ++ (stepCachixUseAll cachix) 127 | ++ [ (stepGetDerivation { inherit job bundles; }) stepCheck ] 128 | ++ (map (job: stepBuild { inherit job bundles; }) jdeps) 129 | ++ [ (stepBuild { inherit job bundles; current = true; }) ]; 130 | } // (optionalAttrs (isList bundles) {strategy.matrix.bundle = bundles;}); 131 | }; 132 | 133 | mkJobs = { jobs ? [], bundles ? [], deps ? {}, cachix ? {} }@args: 134 | foldl (action: job: action // (mkJob ({ inherit job; } // args))) {} jobs; 135 | 136 | mkActionFromJobs = { actionJobs, bundles ? [], push-branches ? [] }: 137 | let 138 | workflow_path = ".github/workflows/nix-action-${toString bundles}.yml"; 139 | in { 140 | name = "Nix CI for bundle ${toString bundles}"; 141 | on = { 142 | push.branches = push-branches; 143 | pull_request.paths = [ workflow_path ]; 144 | pull_request_target = { 145 | types = [ "opened" "synchronize" "reopened" ]; 146 | paths-ignore = [ workflow_path ]; 147 | }; 148 | }; 149 | jobs = actionJobs; 150 | }; 151 | 152 | mkAction = { jobs ? [], bundles ? [], deps ? {}, cachix ? {} }@args: 153 | { push-branches ? [] }: 154 | mkActionFromJobs {inherit bundles push-branches; actionJobs = mkJobs args; }; 155 | 156 | in { inherit mkAction; } 157 | -------------------------------------------------------------------------------- /.nix/shellHook.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/bash 2 | 3 | export currentDir=$PWD 4 | export configDir=$currentDir/.nix 5 | 6 | nixCommands=() 7 | addNixCommand (){ 8 | nixCommands+=($1) 9 | } 10 | 11 | nixHelp (){ 12 | echo "Available commands:" 13 | for cmd in "${nixCommands[@]}"; do echo "- $cmd" ; done 14 | } 15 | 16 | printNixEnv () { 17 | echo "Here is your work environement" 18 | echo "nativeBuildInputs:" 19 | for x in $nativeBuildInputs; do printf -- "- "; echo $x | cut -d "-" -f "2-"; done 20 | echo "propagatedNativeBuildInputs:" 21 | for x in $propagatedNativeBuildInputs; do printf -- "- "; echo $x | cut -d "-" -f "2-"; done 22 | echo "buildInputs:" 23 | for x in $buildInputs; do printf -- "- "; echo $x | cut -d "-" -f "2-"; done 24 | echo "propagatedBuildInputs:" 25 | for x in $propagatedBuildInputs; do printf -- "- "; echo $x | cut -d "-" -f "2-"; done 26 | echo "you can pass option --arg override '{rocq-core = \"x.y\"; ...}' to nix-shell to change packages versions" 27 | } 28 | addNixCommand printNixEnv 29 | 30 | ppNixEnv () { 31 | echo "Available packages:" 32 | for x in $nativeBuildInputs 33 | do printf -- "- " 34 | pkgv=$(echo $x | cut -d "-" -f "2-") 35 | echo $(echo $pkgv | sed "s/rocq-core[0-9][^\-]*-//") 36 | done 37 | for x in $propagatedNativeBuildInputs 38 | do printf -- "- " 39 | pkgv=$(echo $x | cut -d "-" -f "2-") 40 | echo $(echo $pkgv | sed "s/rocq-core[0-9][^\-]*-//") 41 | done 42 | for x in $buildInputs 43 | do printf -- "- " 44 | pkgv=$(echo $x | cut -d "-" -f "2-") 45 | echo $(echo $pkgv | sed "s/rocq-core[0-9][^\-]*-//") 46 | done 47 | for x in $propagatedBuildInputs 48 | do printf -- "- " 49 | pkgv=$(echo $x | cut -d "-" -f "2-") 50 | echo $(echo $pkgv | sed "s/rocq-core[0-9][^\-]*-//") 51 | done 52 | } 53 | addNixCommand ppNixEnv 54 | 55 | nixEnv () { 56 | for x in $nativeBuildInputs; do echo $x; done 57 | for x in $propagatedNativeBuildInputs; do echo $x; done 58 | for x in $buildInputs; do echo $x; done 59 | for x in $propagatedBuildInputs; do echo $x; done 60 | } 61 | addNixCommand nixEnv 62 | 63 | updateNixToolBox () { 64 | HASH=$(git ls-remote https://github.com/coq-community/coq-nix-toolbox refs/heads/master | cut -f1) 65 | mkdir -p $configDir 66 | echo "\"$HASH\"" > $configDir/coq-nix-toolbox.nix 67 | } 68 | addNixCommand updateNixToolBox 69 | 70 | generateNixDefault () { 71 | cat $toolboxDir/project-default.nix > $currentDir/default.nix 72 | updateNixToolBox 73 | } 74 | addNixCommand generateNixDefault 75 | 76 | updateNixpkgsUnstable (){ 77 | HASH=$(git ls-remote https://github.com/NixOS/nixpkgs refs/heads/nixpkgs-unstable | cut -f1); 78 | URL=https://github.com/NixOS/nixpkgs/archive/$HASH.tar.gz 79 | SHA256=$(nix-prefetch-url --unpack $URL) 80 | mkdir -p $configDir 81 | echo "fetchTarball { 82 | url = \"$URL\"; 83 | sha256 = \"$SHA256\"; 84 | }" > $configDir/nixpkgs.nix 85 | } 86 | addNixCommand updateNixpkgsUnstable 87 | 88 | updateNixpkgsMaster (){ 89 | HASH=$(git ls-remote https://github.com/NixOS/nixpkgs refs/heads/master | cut -f1) 90 | URL=https://github.com/NixOS/nixpkgs/archive/$HASH.tar.gz 91 | SHA256=$(nix-prefetch-url --unpack $URL) 92 | mkdir -p $configDir 93 | echo "fetchTarball { 94 | url = \"$URL\"; 95 | sha256 = \"$SHA256\"; 96 | }" > $configDir/nixpkgs.nix 97 | } 98 | addNixCommand updateNixpkgsMaster 99 | 100 | updateNixpkgs (){ 101 | if [[ -n "$1" ]] 102 | then if [[ -n "$2" ]]; then B=$2; else B="master"; fi 103 | HASH=$(git ls-remote https://github.com/$1/nixpkgs refs/heads/$B | cut -f1) 104 | URL=https://github.com/$1/nixpkgs/archive/$HASH.tar.gz 105 | SHA256=$(nix-prefetch-url --unpack $URL) 106 | mkdir -p $configDir 107 | echo "fetchTarball { 108 | url = \"$URL\"; 109 | sha256 = \"$SHA256\"; 110 | }" > $configDir/nixpkgs.nix 111 | else 112 | echo "error: usage: updateNixpkgs [branch]" 113 | echo "otherwise use updateNixpkgsUnstable or updateNixpkgsMaster" 114 | fi 115 | } 116 | addNixCommand updateNixpkgs 117 | 118 | nixBundle (){ 119 | echo $jsonBundle 120 | } 121 | addNixCommand nixBundle 122 | 123 | ppBundle (){ 124 | echo $jsonBundle | json2yaml 125 | } 126 | addNixCommand ppBundle 127 | 128 | nixBundles (){ 129 | echo $jsonBundles 130 | } 131 | addNixCommand nixBundles 132 | 133 | ppBundles (){ 134 | echo $jsonBundles | json2yaml 135 | } 136 | addNixCommand ppBundles 137 | 138 | ppBundleSet (){ 139 | echo $jsonBundleSet | json2yaml 140 | } 141 | addNixCommand ppBundleSet 142 | 143 | ppCIbyBundle (){ 144 | echo $jsonCIbyBundle | json2yaml 145 | } 146 | addNixCommand ppCIbyBundle 147 | 148 | ppCIbyJob (){ 149 | echo $jsonCIbyJob | json2yaml 150 | } 151 | addNixCommand ppCIbyJob 152 | 153 | ppDeps (){ 154 | echo $jsonPkgsDeps | json2yaml 155 | } 156 | addNixCommand ppDeps 157 | 158 | ppRevDeps (){ 159 | echo $jsonPkgsRevDeps | json2yaml 160 | } 161 | addNixCommand ppRevDeps 162 | 163 | ppSetupConfig (){ 164 | echo $jsonSetupConfig | json2yaml 165 | } 166 | addNixCommand ppSetupConfig 167 | 168 | ppNixAction (){ 169 | cat $jsonActionFile | json2yaml 170 | } 171 | addNixCommand ppNixAction 172 | 173 | genNixActions (){ 174 | mkdir -p $currentDir/.github/workflows/ 175 | for t in $bundles; do 176 | echo "generating $currentDir/.github/workflows/nix-action-$t.yml" 177 | nix-shell --arg do-nothing true --argstr bundle $t --run "ppNixAction > $currentDir/.github/workflows/nix-action-$t.yml" 178 | done 179 | } 180 | addNixCommand genNixActions 181 | 182 | initNixConfig (){ 183 | Orig=$toolboxDir/template-config.nix 184 | F=$configDir/config.nix; 185 | if [[ -f $F ]]; then 186 | echo "$F already exists" 187 | else if [[ -n "$1" ]]; then 188 | mkdir -p $configDir 189 | cat $Orig > $F 190 | sed -i "s/template/$1/" $F 191 | else echo "usage: initNixConfig pname" 192 | fi 193 | fi 194 | } 195 | addNixCommand initNixConfig 196 | 197 | createOverlay (){ 198 | Orig=$toolboxDir/template-overlay.nix 199 | if [[ -n "$1" ]]; then 200 | D=$configDir/rocq-overlays/$1; 201 | mkdir -p $D 202 | cat $Orig > $D/default.nix 203 | sed -i "s/template/$1/" $D/default.nix 204 | else echo "usage: createOverlay pname" 205 | fi 206 | } 207 | addNixCommand createOverlay 208 | 209 | fetchCoqOverlay (){ 210 | F=$nixpkgs/pkgs/development/coq-modules/$1/default.nix 211 | D=$configDir/coq-overlays/$1/ 212 | if [[ -f "$F" ]] 213 | then mkdir -p $D; cp $F $D; chmod u+w ${D}default.nix; 214 | git add ${D}default.nix 215 | echo "You may now amend ${D}default.nix" 216 | else echo "usage: fetchCoqOverlay pname" 217 | fi 218 | } 219 | addNixCommand fetchCoqOverlay 220 | 221 | fetchRocqOverlay (){ 222 | F=$nixpkgs/pkgs/development/rocq-modules/$1/default.nix 223 | D=$configDir/rocq-overlays/$1/ 224 | if [[ -f "$F" ]] 225 | then mkdir -p $D; cp $F $D; chmod u+w ${D}default.nix; 226 | git add ${D}default.nix 227 | echo "You may now amend ${D}default.nix" 228 | else echo "usage: fetchRocqOverlay pname" 229 | fi 230 | } 231 | addNixCommand fetchRocqOverlay 232 | 233 | my-nix-build (){ 234 | if [ ${NIX_PATH} ]; then 235 | SET_NIX_PATH=NIX_PATH="${NIX_PATH}" 236 | fi 237 | if [ ${https_proxy} ]; then 238 | SET_https_proxy=https_proxy="${https_proxy}" 239 | fi 240 | env -i PATH=$PATH ${SET_NIX_PATH} ${SET_https_proxy} nix-build \ 241 | --argstr bundle "$selectedBundle" --no-out-link\ 242 | --option narinfo-cache-negative-ttl 0 $* 243 | } 244 | 245 | cachedMake (){ 246 | cproj=$currentDir/$coqproject 247 | cprojDir=$(dirname $cproj) 248 | nb_dry_run=$(my-nix-build --dry-run 2>&1 > /dev/null) 249 | if echo $nb_dry_run | grep -q "built:"; then 250 | echo "The compilation result is not in cache." 251 | echo "Either it is not in cache (yet) or your must check your cachix configuration." 252 | kill -INT $$ 253 | else 254 | build=$(my-nix-build) 255 | grep -e "^-R.*" $cproj | while read -r line; do 256 | realpath=$(echo $line | cut -d" " -f2) 257 | namespace=$(echo $line | cut -d" " -f3) 258 | logpath=${namespace/.//} 259 | vopath="$build/lib/coq/$coq_version/user-contrib/$logpath" 260 | dest=$cprojDir/$realpath 261 | if [[ -d $vopath ]] 262 | then echo "Compiling/Fetching and copying vo from $vopath to $realpath" 263 | cp -nr --no-preserve=mode,ownership $vopath/* $dest 264 | else echo "Error: cannot find compiled $logpath, check your .nix/config.nix" 265 | fi 266 | done 267 | fi 268 | } 269 | addNixCommand cachedMake 270 | 271 | if [[ -f $emacsBin ]] 272 | then 273 | emacs (){ 274 | F=$currentDir/.emacs 275 | if ! [[ -f "$F" ]] 276 | then cp -u $emacsInit $F 277 | fi 278 | $emacsBin -q --load $F $* 279 | } 280 | addNixCommand emacs 281 | fi 282 | -------------------------------------------------------------------------------- /.github/workflows/nix-action-master.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | coq: 3 | needs: 4 | - rocq-core 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Determine which commit to initially checkout 8 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 9 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 10 | }}\" >> $GITHUB_ENV\nfi\n" 11 | - name: Git checkout 12 | uses: actions/checkout@v6 13 | with: 14 | fetch-depth: 0 15 | ref: ${{ env.target_commit }} 16 | - name: Determine which commit to test 17 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 18 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 19 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 20 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 21 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 22 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 23 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 24 | \ fi\nfi\n" 25 | - name: Git checkout 26 | uses: actions/checkout@v6 27 | with: 28 | fetch-depth: 0 29 | ref: ${{ env.tested_commit }} 30 | - name: Cachix install 31 | uses: cachix/install-nix-action@v31 32 | with: 33 | nix_path: nixpkgs=channel:nixpkgs-unstable 34 | - name: Cachix setup coq-community 35 | uses: cachix/cachix-action@v16 36 | with: 37 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 38 | extraPullNames: coq, math-comp 39 | name: coq-community 40 | - id: stepGetDerivation 41 | name: Getting derivation for current job (coq) 42 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 43 | \"master\" --argstr job \"coq\" \\\n --dry-run 2> err > out || (touch fail; 44 | true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 45 | failed\"; exit 1; fi\n" 46 | - id: stepCheck 47 | name: Checking presence of CI target for current job 48 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 49 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 50 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 51 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 52 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 53 | - if: steps.stepCheck.outputs.status != 'fetched' 54 | name: 'Building/fetching previous CI target: rocq-core' 55 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 56 | "master" --argstr job "rocq-core" 57 | - if: steps.stepCheck.outputs.status != 'fetched' 58 | name: Building/fetching current CI target 59 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 60 | "master" --argstr job "coq" 61 | coq-shell: 62 | needs: 63 | - coq 64 | runs-on: ubuntu-latest 65 | steps: 66 | - name: Determine which commit to initially checkout 67 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 68 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 69 | }}\" >> $GITHUB_ENV\nfi\n" 70 | - name: Git checkout 71 | uses: actions/checkout@v6 72 | with: 73 | fetch-depth: 0 74 | ref: ${{ env.target_commit }} 75 | - name: Determine which commit to test 76 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 77 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 78 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 79 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 80 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 81 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 82 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 83 | \ fi\nfi\n" 84 | - name: Git checkout 85 | uses: actions/checkout@v6 86 | with: 87 | fetch-depth: 0 88 | ref: ${{ env.tested_commit }} 89 | - name: Cachix install 90 | uses: cachix/install-nix-action@v31 91 | with: 92 | nix_path: nixpkgs=channel:nixpkgs-unstable 93 | - name: Cachix setup coq-community 94 | uses: cachix/cachix-action@v16 95 | with: 96 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 97 | extraPullNames: coq, math-comp 98 | name: coq-community 99 | - id: stepGetDerivation 100 | name: Getting derivation for current job (coq-shell) 101 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 102 | \"master\" --argstr job \"coq-shell\" \\\n --dry-run 2> err > out || (touch 103 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 104 | failed\"; exit 1; fi\n" 105 | - id: stepCheck 106 | name: Checking presence of CI target for current job 107 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 108 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 109 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 110 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 111 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 112 | - if: steps.stepCheck.outputs.status != 'fetched' 113 | name: 'Building/fetching previous CI target: coq' 114 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 115 | "master" --argstr job "coq" 116 | - if: steps.stepCheck.outputs.status != 'fetched' 117 | name: Building/fetching current CI target 118 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 119 | "master" --argstr job "coq-shell" 120 | rocq-core: 121 | needs: [] 122 | runs-on: ubuntu-latest 123 | steps: 124 | - name: Determine which commit to initially checkout 125 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 126 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 127 | }}\" >> $GITHUB_ENV\nfi\n" 128 | - name: Git checkout 129 | uses: actions/checkout@v6 130 | with: 131 | fetch-depth: 0 132 | ref: ${{ env.target_commit }} 133 | - name: Determine which commit to test 134 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 135 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 136 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 137 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 138 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 139 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 140 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 141 | \ fi\nfi\n" 142 | - name: Git checkout 143 | uses: actions/checkout@v6 144 | with: 145 | fetch-depth: 0 146 | ref: ${{ env.tested_commit }} 147 | - name: Cachix install 148 | uses: cachix/install-nix-action@v31 149 | with: 150 | nix_path: nixpkgs=channel:nixpkgs-unstable 151 | - name: Cachix setup coq-community 152 | uses: cachix/cachix-action@v16 153 | with: 154 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 155 | extraPullNames: coq, math-comp 156 | name: coq-community 157 | - id: stepGetDerivation 158 | name: Getting derivation for current job (rocq-core) 159 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 160 | \"master\" --argstr job \"rocq-core\" \\\n --dry-run 2> err > out || (touch 161 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 162 | failed\"; exit 1; fi\n" 163 | - id: stepCheck 164 | name: Checking presence of CI target for current job 165 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 166 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 167 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 168 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 169 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 170 | - if: steps.stepCheck.outputs.status != 'fetched' 171 | name: Building/fetching current CI target 172 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 173 | "master" --argstr job "rocq-core" 174 | name: Nix CI for bundle master 175 | on: 176 | pull_request: 177 | paths: 178 | - .github/workflows/nix-action-master.yml 179 | pull_request_target: 180 | paths-ignore: 181 | - .github/workflows/nix-action-master.yml 182 | types: 183 | - opened 184 | - synchronize 185 | - reopened 186 | push: 187 | branches: 188 | - master 189 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Coq Nix Toolbox 2 | 3 | ## General presentation 4 | 5 | The [Nix package manager](https://nixos.org/) is a package manager with a strong focus on reproducibility and isolation. 6 | 7 | The Coq Nix Toolbox is a set of helper scripts to ease setting up a Coq project for use with Nix, for Nix and non-Nix users alike. One of its main features is to generate GitHub Actions configuration files to continuously test a Coq project and its reverse dependencies. 8 | 9 | Besides Nix, the Coq Nix Toolbox relies on the [nixpkgs package repository](https://github.com/NixOS/nixpkgs) and its large collection of Coq packages. 10 | 11 | The Coq Nix Toolbox provide the following features: 12 | 13 | 1. It can generate [GitHub Actions](https://github.com/features/actions) configuration files to trigger a CI for your Coq project and its reverse dependencies. This CI uses the Nix packaging system and a caching mechanism called [Cachix](https://www.cachix.org/). 14 | 15 | 2. It offers Nix configurations files so that one can locally obtain a shell with all dependencies preloaded by simply running `nix-shell` in the development root directory. 16 | 17 | 3. Multiple versions of dependencies (typically different versions of Coq) can be easily handled with "bundles" of (reverse) dependency versions/git refs. 18 | 19 | 4. One can retrieve locally builds already performed on CI thanks to Cachix. 20 | 21 | ## How to use 22 | 23 | ### Standalone 24 | 25 | Installing Nix locally is a prerequisite for this installation method (but a good thing to do anyway to take the most advantage of this toolbox). See https://nixos.org/download.html. 26 | Additionally, in order to use binary caches from recognized organizations, please do 27 | ```bash 28 | nix-env -iA nixpkgs.cachix && cachix use coq && cachix use coq-community && cachix use math-comp 29 | ``` 30 | This only needs to be performed once, after the installation of Nix. 31 | 32 | Then, run the following commands at the root of your project (using a project-specific name instead of YOURPACKAGENAME, below) : 33 | 34 | ```bash 35 | nix-shell https://github.com/rocq-community/coq-nix-toolbox/archive/master.tar.gz --arg do-nothing true --run generateNixDefault 36 | nix-shell --arg do-nothing true --run "initNixConfig YOURPACKAGENAME" 37 | ``` 38 | 39 | This will create an initial `.nix/config.nix` that you should now manually edit. 40 | This file contains comments explaining each available option. 41 | 42 | Once you have finished editing `.nix/config.nix`, you may generate GitHub Actions workflow(s) by running: 43 | 44 | ```bash 45 | nix-shell --arg do-nothing true --run "genNixActions" 46 | ``` 47 | 48 | Do not forget to commit the new files. 49 | 50 | Later, you may want to update to the latest version of the toolbox and regenerate GitHub Action workflow(s) by running: 51 | 52 | ```bash 53 | nix-shell --arg do-nothing true --run "updateNixToolBox & genNixActions" 54 | ``` 55 | 56 | ## Overlays 57 | 58 | You can create directories named after a Coq package and containing `default.nix` files in `.nix/rocq-overlays` or `.nix/coq-overlays` to override the contents of `rocqPackages` or `coqPackages` respectively. 59 | This can be useful in the following case: 60 | 61 | - You depend on a package or a version of a package that is not yet available in nixpkgs. 62 | - The package that you are building is available in nixpkgs but its dependencies have changed. 63 | - The package that you are building is not yet available in nixpkgs. 64 | 65 | 66 | To amend a package already present in nixpkgs, just run `nix-shell --arg do-nothing true --run "fetchRocqOverlay PACKAGENAME"` 67 | or `nix-shell --arg do-nothing true --run "fetchCoqOverlay PACKAGENAME"`. 68 | To create a package from scratch, run `nix-shell --arg do-nothing true --run "createOverlay PACKAGENAME"` and refer to the nixpkgs documentation available at https://nixos.org/manual/nixpkgs/unstable/#sec-language-coq. 69 | 70 | ## Bundles and jobs 71 | 72 | Bundles are defined in your `config.nix` file. If you didn't change this part of the auto-generated file, you have a single bundle called "default". 73 | Bundles are used to create sets of compatible packages. You can override the version of some packages and you can explicitly exclude some incompatible packages. 74 | 75 | Jobs represent buildable outputs. You can build any package in `rocqPackages` and `coqPackages` (including any package defined in your `.nix/rocq-overlays` and `.nix/coq-overlays` directories) with the following command: 76 | 77 | ``` 78 | nix-build --argstr job PACKAGENAME 79 | ``` 80 | One can replace `PACKAGENAME` with: 81 | - `_allJobs` to compile all Coq packages that are explicitly mentioned in the `config.nix` file and not explicitly excluded 82 | - `_all` to compile all Coq packages that are not explicitly excluded 83 | 84 | If the package depends on your main package, then it will use its local version as a dependency. 85 | 86 | You can also specify the bundle to use like this: 87 | ``` 88 | nix-build --argstr bundle BUNDLENAME --argstr job PACKAGENAME 89 | ``` 90 | 91 | In case the `bundle` argument is omitted, the default bundle defined in `config.nix` is used. 92 | 93 | If, for instance, you need to fix a reverse dependency of your project because it fails in CI, you can use the following command to get the dependencies for this reverse dependency: 94 | 95 | ``` 96 | nix-shell --argstr bundle BUNDLENAME --argstr job PACKAGENAME 97 | ``` 98 | 99 | This command will build all the dependencies of `PACKAGENAME`, including your project from the current sources. If these correspond to a version that has been tested in CI and you have activated Cachix (both so that CI pushes to it and on your local machine to use it), then this step should only fetch pre-built dependencies. 100 | 101 | Again, the `bundle` argument is optional. 102 | 103 | ## Available shell hooks 104 | 105 | When you run `nix-shell`, you get an environment with a few available commands: 106 | 107 | - `nixHelp`: lists the available commands. 108 | - `ppNixEnv`: displays the list of available packages and their versions. 109 | - `generateNixDefault`: regenerates the `default.nix` file from the template in *this* repository ([`project-default.nix`](project-default.nix)). 110 | This command should only be used in the **Standalone** installation method. 111 | - `ppBundle`: print debug information for the current bundle. A bundle is a set of compatible versions of packages, as described in `.nix/config.nix` (or `.nix/fallback-config.nix` if the latter does not exist). 112 | - `ppBundles`: print the name of all available bundles, each can be passed to `nix-shell` to get different packages in your shell. 113 | - `ppBundleSet`: print a detailed account of what each bundle contains. 114 | - `initNixConfig`: create an initial `.nix/config.nix` file. 115 | - `nixEnv`: displays the list of Nix store locations for all the available packages. 116 | - `fetchRocqOverlay`: fetch a derivation file from nixpkgs that you may then edit locally to override a package. 117 | - `fetchCoqOverlay`: fetch a derivation file from nixpkgs that you may then edit locally to override a package. 118 | - `createOverlay`: create a fresh derivation file from a template, which could then be added to nixpkgs. 119 | - `cachedMake`: compile the project by reusing build outputs cached (generally thanks to Cachix). 120 | - `genNixActions`: generates GitHub one actions file per bundle, for testing dependencies and reverse dependencies. 121 | 122 | These three commands update the nixpkgs version to use (will create or override `.nix/nixpkgs.nix`): 123 | - `updateNixpkgsUnstable`: update to the latest nixpkgs-unstable. 124 | - `updateNixpkgsMaster`: update to the head of `master` of nixpkgs. 125 | - `updateNixpkgs`: update to the specified owner and ref. 126 | 127 | After one of these three commands, you should leave and re-enter `nix-shell` if you want the update to be taken into account (e.g., before calling `genNixActions`). 128 | 129 | ## Arguments accepted by `nix-shell` 130 | 131 | One can pass the following arguments to `nix-shell` or `nix-build`: 132 | - `--arg do-nothing true`: do not even provide Coq, just enough context to execute the above commands. 133 | - `--argstr bundle t`: select the bundle `t` (one can use the above commands `ppBundles` to know the options and `ppBundleSet` to see their contents) 134 | - `--arg override '{p1 = v1; ...; pn = vn;}'`: a very condensed inline way to select specific versions of `rocq-core` or any package from `rocqPackages`, `coqPackages` (using `--arg coq-override`) or `ocamlPackages` (using `--arg ocaml-override`). E.g. `--arg override '{rocq-core = "9.0"; ...; mathcomp = "2.3.0";}'` to override the current default bundle with the given versions. 135 | - `--arg withEmacs true`: provide a ready to use version of emacs with proofgeneral; for the sake of reproducibility this will **not** use your system emacs nor will it use your user configuration. 136 | - `--argstr job p`: provide the dependencies for (in case of `nix-shell`) or build (in case of `nix-build`) Coq package `p` instead of the current project, but using the current version of the current project. Combined with `--argstr bundle t` this gives a fully configurable way to test reverse dependencies for various configurations. 137 | 138 | ## Testing `rocqPackages` updates in nixpkgs 139 | 140 | To test a PR on nixpkgs that modifies the `rocqPackages` set, clone this repository, `cd` into it, and run: 141 | 142 | ``` 143 | nix-shell --arg do-nothing true --run "updateNixpkgs " 144 | nix-shell --arg do-nothing true --run "genNixActions" 145 | ``` 146 | 147 | Then, open a draft PR with the generated changes here, please include a reference to the nixpkgs PR in the first message of the coq-nix-toolbox PR. 148 | 149 | Once the PR on nixpkgs has been merged, you can transform the draft PR into one that updates the version in use in coq-nix-toolbox by running the following commands, adapting the commit message and marking the PR as ready to merge: 150 | 151 | ``` 152 | nix-shell --arg do-nothing true --run "updateNixpkgsMaster" 153 | nix-shell --arg do-nothing true --run "genNixActions" 154 | ``` 155 | -------------------------------------------------------------------------------- /.github/workflows/nix-action-rocq-9.0.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | bignums: 3 | needs: 4 | - rocq-core 5 | - stdlib 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Determine which commit to initially checkout 9 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 10 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 11 | }}\" >> $GITHUB_ENV\nfi\n" 12 | - name: Git checkout 13 | uses: actions/checkout@v6 14 | with: 15 | fetch-depth: 0 16 | ref: ${{ env.target_commit }} 17 | - name: Determine which commit to test 18 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 19 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 20 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 21 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 22 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 23 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 24 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 25 | \ fi\nfi\n" 26 | - name: Git checkout 27 | uses: actions/checkout@v6 28 | with: 29 | fetch-depth: 0 30 | ref: ${{ env.tested_commit }} 31 | - name: Cachix install 32 | uses: cachix/install-nix-action@v31 33 | with: 34 | nix_path: nixpkgs=channel:nixpkgs-unstable 35 | - name: Cachix setup coq-community 36 | uses: cachix/cachix-action@v16 37 | with: 38 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 39 | extraPullNames: coq, math-comp 40 | name: coq-community 41 | - id: stepGetDerivation 42 | name: Getting derivation for current job (bignums) 43 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 44 | \"rocq-9.0\" --argstr job \"bignums\" \\\n --dry-run 2> err > out || (touch 45 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 46 | failed\"; exit 1; fi\n" 47 | - id: stepCheck 48 | name: Checking presence of CI target for current job 49 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 50 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 51 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 52 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 53 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 54 | - if: steps.stepCheck.outputs.status != 'fetched' 55 | name: 'Building/fetching previous CI target: rocq-core' 56 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 57 | "rocq-9.0" --argstr job "rocq-core" 58 | - if: steps.stepCheck.outputs.status != 'fetched' 59 | name: 'Building/fetching previous CI target: stdlib' 60 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 61 | "rocq-9.0" --argstr job "stdlib" 62 | - if: steps.stepCheck.outputs.status != 'fetched' 63 | name: Building/fetching current CI target 64 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 65 | "rocq-9.0" --argstr job "bignums" 66 | hierarchy-builder: 67 | needs: 68 | - rocq-core 69 | - rocq-elpi 70 | runs-on: ubuntu-latest 71 | steps: 72 | - name: Determine which commit to initially checkout 73 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 74 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 75 | }}\" >> $GITHUB_ENV\nfi\n" 76 | - name: Git checkout 77 | uses: actions/checkout@v6 78 | with: 79 | fetch-depth: 0 80 | ref: ${{ env.target_commit }} 81 | - name: Determine which commit to test 82 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 83 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 84 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 85 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 86 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 87 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 88 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 89 | \ fi\nfi\n" 90 | - name: Git checkout 91 | uses: actions/checkout@v6 92 | with: 93 | fetch-depth: 0 94 | ref: ${{ env.tested_commit }} 95 | - name: Cachix install 96 | uses: cachix/install-nix-action@v31 97 | with: 98 | nix_path: nixpkgs=channel:nixpkgs-unstable 99 | - name: Cachix setup coq-community 100 | uses: cachix/cachix-action@v16 101 | with: 102 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 103 | extraPullNames: coq, math-comp 104 | name: coq-community 105 | - id: stepGetDerivation 106 | name: Getting derivation for current job (hierarchy-builder) 107 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 108 | \"rocq-9.0\" --argstr job \"hierarchy-builder\" \\\n --dry-run 2> err > 109 | out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: 110 | getting derivation failed\"; exit 1; fi\n" 111 | - id: stepCheck 112 | name: Checking presence of CI target for current job 113 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 114 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 115 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 116 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 117 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 118 | - if: steps.stepCheck.outputs.status != 'fetched' 119 | name: 'Building/fetching previous CI target: rocq-core' 120 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 121 | "rocq-9.0" --argstr job "rocq-core" 122 | - if: steps.stepCheck.outputs.status != 'fetched' 123 | name: 'Building/fetching previous CI target: rocq-elpi' 124 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 125 | "rocq-9.0" --argstr job "rocq-elpi" 126 | - if: steps.stepCheck.outputs.status != 'fetched' 127 | name: Building/fetching current CI target 128 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 129 | "rocq-9.0" --argstr job "hierarchy-builder" 130 | parseque: 131 | needs: 132 | - rocq-core 133 | - stdlib 134 | runs-on: ubuntu-latest 135 | steps: 136 | - name: Determine which commit to initially checkout 137 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 138 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 139 | }}\" >> $GITHUB_ENV\nfi\n" 140 | - name: Git checkout 141 | uses: actions/checkout@v6 142 | with: 143 | fetch-depth: 0 144 | ref: ${{ env.target_commit }} 145 | - name: Determine which commit to test 146 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 147 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 148 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 149 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 150 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 151 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 152 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 153 | \ fi\nfi\n" 154 | - name: Git checkout 155 | uses: actions/checkout@v6 156 | with: 157 | fetch-depth: 0 158 | ref: ${{ env.tested_commit }} 159 | - name: Cachix install 160 | uses: cachix/install-nix-action@v31 161 | with: 162 | nix_path: nixpkgs=channel:nixpkgs-unstable 163 | - name: Cachix setup coq-community 164 | uses: cachix/cachix-action@v16 165 | with: 166 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 167 | extraPullNames: coq, math-comp 168 | name: coq-community 169 | - id: stepGetDerivation 170 | name: Getting derivation for current job (parseque) 171 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 172 | \"rocq-9.0\" --argstr job \"parseque\" \\\n --dry-run 2> err > out || (touch 173 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 174 | failed\"; exit 1; fi\n" 175 | - id: stepCheck 176 | name: Checking presence of CI target for current job 177 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 178 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 179 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 180 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 181 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 182 | - if: steps.stepCheck.outputs.status != 'fetched' 183 | name: 'Building/fetching previous CI target: rocq-core' 184 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 185 | "rocq-9.0" --argstr job "rocq-core" 186 | - if: steps.stepCheck.outputs.status != 'fetched' 187 | name: 'Building/fetching previous CI target: stdlib' 188 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 189 | "rocq-9.0" --argstr job "stdlib" 190 | - if: steps.stepCheck.outputs.status != 'fetched' 191 | name: Building/fetching current CI target 192 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 193 | "rocq-9.0" --argstr job "parseque" 194 | rocq-core: 195 | needs: [] 196 | runs-on: ubuntu-latest 197 | steps: 198 | - name: Determine which commit to initially checkout 199 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 200 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 201 | }}\" >> $GITHUB_ENV\nfi\n" 202 | - name: Git checkout 203 | uses: actions/checkout@v6 204 | with: 205 | fetch-depth: 0 206 | ref: ${{ env.target_commit }} 207 | - name: Determine which commit to test 208 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 209 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 210 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 211 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 212 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 213 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 214 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 215 | \ fi\nfi\n" 216 | - name: Git checkout 217 | uses: actions/checkout@v6 218 | with: 219 | fetch-depth: 0 220 | ref: ${{ env.tested_commit }} 221 | - name: Cachix install 222 | uses: cachix/install-nix-action@v31 223 | with: 224 | nix_path: nixpkgs=channel:nixpkgs-unstable 225 | - name: Cachix setup coq-community 226 | uses: cachix/cachix-action@v16 227 | with: 228 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 229 | extraPullNames: coq, math-comp 230 | name: coq-community 231 | - id: stepGetDerivation 232 | name: Getting derivation for current job (rocq-core) 233 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 234 | \"rocq-9.0\" --argstr job \"rocq-core\" \\\n --dry-run 2> err > out || (touch 235 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 236 | failed\"; exit 1; fi\n" 237 | - id: stepCheck 238 | name: Checking presence of CI target for current job 239 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 240 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 241 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 242 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 243 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 244 | - if: steps.stepCheck.outputs.status != 'fetched' 245 | name: Building/fetching current CI target 246 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 247 | "rocq-9.0" --argstr job "rocq-core" 248 | rocq-elpi: 249 | needs: 250 | - rocq-core 251 | runs-on: ubuntu-latest 252 | steps: 253 | - name: Determine which commit to initially checkout 254 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 255 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 256 | }}\" >> $GITHUB_ENV\nfi\n" 257 | - name: Git checkout 258 | uses: actions/checkout@v6 259 | with: 260 | fetch-depth: 0 261 | ref: ${{ env.target_commit }} 262 | - name: Determine which commit to test 263 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 264 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 265 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 266 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 267 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 268 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 269 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 270 | \ fi\nfi\n" 271 | - name: Git checkout 272 | uses: actions/checkout@v6 273 | with: 274 | fetch-depth: 0 275 | ref: ${{ env.tested_commit }} 276 | - name: Cachix install 277 | uses: cachix/install-nix-action@v31 278 | with: 279 | nix_path: nixpkgs=channel:nixpkgs-unstable 280 | - name: Cachix setup coq-community 281 | uses: cachix/cachix-action@v16 282 | with: 283 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 284 | extraPullNames: coq, math-comp 285 | name: coq-community 286 | - id: stepGetDerivation 287 | name: Getting derivation for current job (rocq-elpi) 288 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 289 | \"rocq-9.0\" --argstr job \"rocq-elpi\" \\\n --dry-run 2> err > out || (touch 290 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 291 | failed\"; exit 1; fi\n" 292 | - id: stepCheck 293 | name: Checking presence of CI target for current job 294 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 295 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 296 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 297 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 298 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 299 | - if: steps.stepCheck.outputs.status != 'fetched' 300 | name: 'Building/fetching previous CI target: rocq-core' 301 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 302 | "rocq-9.0" --argstr job "rocq-core" 303 | - if: steps.stepCheck.outputs.status != 'fetched' 304 | name: Building/fetching current CI target 305 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 306 | "rocq-9.0" --argstr job "rocq-elpi" 307 | stdlib: 308 | needs: 309 | - rocq-core 310 | runs-on: ubuntu-latest 311 | steps: 312 | - name: Determine which commit to initially checkout 313 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 314 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 315 | }}\" >> $GITHUB_ENV\nfi\n" 316 | - name: Git checkout 317 | uses: actions/checkout@v6 318 | with: 319 | fetch-depth: 0 320 | ref: ${{ env.target_commit }} 321 | - name: Determine which commit to test 322 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 323 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 324 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 325 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 326 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 327 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 328 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 329 | \ fi\nfi\n" 330 | - name: Git checkout 331 | uses: actions/checkout@v6 332 | with: 333 | fetch-depth: 0 334 | ref: ${{ env.tested_commit }} 335 | - name: Cachix install 336 | uses: cachix/install-nix-action@v31 337 | with: 338 | nix_path: nixpkgs=channel:nixpkgs-unstable 339 | - name: Cachix setup coq-community 340 | uses: cachix/cachix-action@v16 341 | with: 342 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 343 | extraPullNames: coq, math-comp 344 | name: coq-community 345 | - id: stepGetDerivation 346 | name: Getting derivation for current job (stdlib) 347 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 348 | \"rocq-9.0\" --argstr job \"stdlib\" \\\n --dry-run 2> err > out || (touch 349 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 350 | failed\"; exit 1; fi\n" 351 | - id: stepCheck 352 | name: Checking presence of CI target for current job 353 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 354 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 355 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 356 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 357 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 358 | - if: steps.stepCheck.outputs.status != 'fetched' 359 | name: 'Building/fetching previous CI target: rocq-core' 360 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 361 | "rocq-9.0" --argstr job "rocq-core" 362 | - if: steps.stepCheck.outputs.status != 'fetched' 363 | name: Building/fetching current CI target 364 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 365 | "rocq-9.0" --argstr job "stdlib" 366 | name: Nix CI for bundle rocq-9.0 367 | on: 368 | pull_request: 369 | paths: 370 | - .github/workflows/nix-action-rocq-9.0.yml 371 | pull_request_target: 372 | paths-ignore: 373 | - .github/workflows/nix-action-rocq-9.0.yml 374 | types: 375 | - opened 376 | - synchronize 377 | - reopened 378 | push: 379 | branches: 380 | - master 381 | -------------------------------------------------------------------------------- /.github/workflows/nix-action-rocq-9.1.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | bignums: 3 | needs: 4 | - rocq-core 5 | - stdlib 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Determine which commit to initially checkout 9 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 10 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 11 | }}\" >> $GITHUB_ENV\nfi\n" 12 | - name: Git checkout 13 | uses: actions/checkout@v6 14 | with: 15 | fetch-depth: 0 16 | ref: ${{ env.target_commit }} 17 | - name: Determine which commit to test 18 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 19 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 20 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 21 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 22 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 23 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 24 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 25 | \ fi\nfi\n" 26 | - name: Git checkout 27 | uses: actions/checkout@v6 28 | with: 29 | fetch-depth: 0 30 | ref: ${{ env.tested_commit }} 31 | - name: Cachix install 32 | uses: cachix/install-nix-action@v31 33 | with: 34 | nix_path: nixpkgs=channel:nixpkgs-unstable 35 | - name: Cachix setup coq-community 36 | uses: cachix/cachix-action@v16 37 | with: 38 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 39 | extraPullNames: coq, math-comp 40 | name: coq-community 41 | - id: stepGetDerivation 42 | name: Getting derivation for current job (bignums) 43 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 44 | \"rocq-9.1\" --argstr job \"bignums\" \\\n --dry-run 2> err > out || (touch 45 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 46 | failed\"; exit 1; fi\n" 47 | - id: stepCheck 48 | name: Checking presence of CI target for current job 49 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 50 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 51 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 52 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 53 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 54 | - if: steps.stepCheck.outputs.status != 'fetched' 55 | name: 'Building/fetching previous CI target: rocq-core' 56 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 57 | "rocq-9.1" --argstr job "rocq-core" 58 | - if: steps.stepCheck.outputs.status != 'fetched' 59 | name: 'Building/fetching previous CI target: stdlib' 60 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 61 | "rocq-9.1" --argstr job "stdlib" 62 | - if: steps.stepCheck.outputs.status != 'fetched' 63 | name: Building/fetching current CI target 64 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 65 | "rocq-9.1" --argstr job "bignums" 66 | hierarchy-builder: 67 | needs: 68 | - rocq-core 69 | - rocq-elpi 70 | runs-on: ubuntu-latest 71 | steps: 72 | - name: Determine which commit to initially checkout 73 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 74 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 75 | }}\" >> $GITHUB_ENV\nfi\n" 76 | - name: Git checkout 77 | uses: actions/checkout@v6 78 | with: 79 | fetch-depth: 0 80 | ref: ${{ env.target_commit }} 81 | - name: Determine which commit to test 82 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 83 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 84 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 85 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 86 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 87 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 88 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 89 | \ fi\nfi\n" 90 | - name: Git checkout 91 | uses: actions/checkout@v6 92 | with: 93 | fetch-depth: 0 94 | ref: ${{ env.tested_commit }} 95 | - name: Cachix install 96 | uses: cachix/install-nix-action@v31 97 | with: 98 | nix_path: nixpkgs=channel:nixpkgs-unstable 99 | - name: Cachix setup coq-community 100 | uses: cachix/cachix-action@v16 101 | with: 102 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 103 | extraPullNames: coq, math-comp 104 | name: coq-community 105 | - id: stepGetDerivation 106 | name: Getting derivation for current job (hierarchy-builder) 107 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 108 | \"rocq-9.1\" --argstr job \"hierarchy-builder\" \\\n --dry-run 2> err > 109 | out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: 110 | getting derivation failed\"; exit 1; fi\n" 111 | - id: stepCheck 112 | name: Checking presence of CI target for current job 113 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 114 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 115 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 116 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 117 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 118 | - if: steps.stepCheck.outputs.status != 'fetched' 119 | name: 'Building/fetching previous CI target: rocq-core' 120 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 121 | "rocq-9.1" --argstr job "rocq-core" 122 | - if: steps.stepCheck.outputs.status != 'fetched' 123 | name: 'Building/fetching previous CI target: rocq-elpi' 124 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 125 | "rocq-9.1" --argstr job "rocq-elpi" 126 | - if: steps.stepCheck.outputs.status != 'fetched' 127 | name: Building/fetching current CI target 128 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 129 | "rocq-9.1" --argstr job "hierarchy-builder" 130 | parseque: 131 | needs: 132 | - rocq-core 133 | - stdlib 134 | runs-on: ubuntu-latest 135 | steps: 136 | - name: Determine which commit to initially checkout 137 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 138 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 139 | }}\" >> $GITHUB_ENV\nfi\n" 140 | - name: Git checkout 141 | uses: actions/checkout@v6 142 | with: 143 | fetch-depth: 0 144 | ref: ${{ env.target_commit }} 145 | - name: Determine which commit to test 146 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 147 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 148 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 149 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 150 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 151 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 152 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 153 | \ fi\nfi\n" 154 | - name: Git checkout 155 | uses: actions/checkout@v6 156 | with: 157 | fetch-depth: 0 158 | ref: ${{ env.tested_commit }} 159 | - name: Cachix install 160 | uses: cachix/install-nix-action@v31 161 | with: 162 | nix_path: nixpkgs=channel:nixpkgs-unstable 163 | - name: Cachix setup coq-community 164 | uses: cachix/cachix-action@v16 165 | with: 166 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 167 | extraPullNames: coq, math-comp 168 | name: coq-community 169 | - id: stepGetDerivation 170 | name: Getting derivation for current job (parseque) 171 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 172 | \"rocq-9.1\" --argstr job \"parseque\" \\\n --dry-run 2> err > out || (touch 173 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 174 | failed\"; exit 1; fi\n" 175 | - id: stepCheck 176 | name: Checking presence of CI target for current job 177 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 178 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 179 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 180 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 181 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 182 | - if: steps.stepCheck.outputs.status != 'fetched' 183 | name: 'Building/fetching previous CI target: rocq-core' 184 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 185 | "rocq-9.1" --argstr job "rocq-core" 186 | - if: steps.stepCheck.outputs.status != 'fetched' 187 | name: 'Building/fetching previous CI target: stdlib' 188 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 189 | "rocq-9.1" --argstr job "stdlib" 190 | - if: steps.stepCheck.outputs.status != 'fetched' 191 | name: Building/fetching current CI target 192 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 193 | "rocq-9.1" --argstr job "parseque" 194 | rocq-core: 195 | needs: [] 196 | runs-on: ubuntu-latest 197 | steps: 198 | - name: Determine which commit to initially checkout 199 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 200 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 201 | }}\" >> $GITHUB_ENV\nfi\n" 202 | - name: Git checkout 203 | uses: actions/checkout@v6 204 | with: 205 | fetch-depth: 0 206 | ref: ${{ env.target_commit }} 207 | - name: Determine which commit to test 208 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 209 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 210 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 211 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 212 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 213 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 214 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 215 | \ fi\nfi\n" 216 | - name: Git checkout 217 | uses: actions/checkout@v6 218 | with: 219 | fetch-depth: 0 220 | ref: ${{ env.tested_commit }} 221 | - name: Cachix install 222 | uses: cachix/install-nix-action@v31 223 | with: 224 | nix_path: nixpkgs=channel:nixpkgs-unstable 225 | - name: Cachix setup coq-community 226 | uses: cachix/cachix-action@v16 227 | with: 228 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 229 | extraPullNames: coq, math-comp 230 | name: coq-community 231 | - id: stepGetDerivation 232 | name: Getting derivation for current job (rocq-core) 233 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 234 | \"rocq-9.1\" --argstr job \"rocq-core\" \\\n --dry-run 2> err > out || (touch 235 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 236 | failed\"; exit 1; fi\n" 237 | - id: stepCheck 238 | name: Checking presence of CI target for current job 239 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 240 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 241 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 242 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 243 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 244 | - if: steps.stepCheck.outputs.status != 'fetched' 245 | name: Building/fetching current CI target 246 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 247 | "rocq-9.1" --argstr job "rocq-core" 248 | rocq-elpi: 249 | needs: 250 | - rocq-core 251 | runs-on: ubuntu-latest 252 | steps: 253 | - name: Determine which commit to initially checkout 254 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 255 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 256 | }}\" >> $GITHUB_ENV\nfi\n" 257 | - name: Git checkout 258 | uses: actions/checkout@v6 259 | with: 260 | fetch-depth: 0 261 | ref: ${{ env.target_commit }} 262 | - name: Determine which commit to test 263 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 264 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 265 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 266 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 267 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 268 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 269 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 270 | \ fi\nfi\n" 271 | - name: Git checkout 272 | uses: actions/checkout@v6 273 | with: 274 | fetch-depth: 0 275 | ref: ${{ env.tested_commit }} 276 | - name: Cachix install 277 | uses: cachix/install-nix-action@v31 278 | with: 279 | nix_path: nixpkgs=channel:nixpkgs-unstable 280 | - name: Cachix setup coq-community 281 | uses: cachix/cachix-action@v16 282 | with: 283 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 284 | extraPullNames: coq, math-comp 285 | name: coq-community 286 | - id: stepGetDerivation 287 | name: Getting derivation for current job (rocq-elpi) 288 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 289 | \"rocq-9.1\" --argstr job \"rocq-elpi\" \\\n --dry-run 2> err > out || (touch 290 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 291 | failed\"; exit 1; fi\n" 292 | - id: stepCheck 293 | name: Checking presence of CI target for current job 294 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 295 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 296 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 297 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 298 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 299 | - if: steps.stepCheck.outputs.status != 'fetched' 300 | name: 'Building/fetching previous CI target: rocq-core' 301 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 302 | "rocq-9.1" --argstr job "rocq-core" 303 | - if: steps.stepCheck.outputs.status != 'fetched' 304 | name: Building/fetching current CI target 305 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 306 | "rocq-9.1" --argstr job "rocq-elpi" 307 | stdlib: 308 | needs: 309 | - rocq-core 310 | runs-on: ubuntu-latest 311 | steps: 312 | - name: Determine which commit to initially checkout 313 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ 314 | github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha 315 | }}\" >> $GITHUB_ENV\nfi\n" 316 | - name: Git checkout 317 | uses: actions/checkout@v6 318 | with: 319 | fetch-depth: 0 320 | ref: ${{ env.target_commit }} 321 | - name: Determine which commit to test 322 | run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ 323 | github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url 324 | }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git 325 | merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null 326 | 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ 327 | \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha 328 | }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ 329 | \ fi\nfi\n" 330 | - name: Git checkout 331 | uses: actions/checkout@v6 332 | with: 333 | fetch-depth: 0 334 | ref: ${{ env.tested_commit }} 335 | - name: Cachix install 336 | uses: cachix/install-nix-action@v31 337 | with: 338 | nix_path: nixpkgs=channel:nixpkgs-unstable 339 | - name: Cachix setup coq-community 340 | uses: cachix/cachix-action@v16 341 | with: 342 | authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} 343 | extraPullNames: coq, math-comp 344 | name: coq-community 345 | - id: stepGetDerivation 346 | name: Getting derivation for current job (stdlib) 347 | run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle 348 | \"rocq-9.1\" --argstr job \"stdlib\" \\\n --dry-run 2> err > out || (touch 349 | fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation 350 | failed\"; exit 1; fi\n" 351 | - id: stepCheck 352 | name: Checking presence of CI target for current job 353 | run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs 354 | actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ 355 | ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ 356 | \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ 357 | status=fetched\" >> $GITHUB_OUTPUT\nfi\n" 358 | - if: steps.stepCheck.outputs.status != 'fetched' 359 | name: 'Building/fetching previous CI target: rocq-core' 360 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 361 | "rocq-9.1" --argstr job "rocq-core" 362 | - if: steps.stepCheck.outputs.status != 'fetched' 363 | name: Building/fetching current CI target 364 | run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle 365 | "rocq-9.1" --argstr job "stdlib" 366 | name: Nix CI for bundle rocq-9.1 367 | on: 368 | pull_request: 369 | paths: 370 | - .github/workflows/nix-action-rocq-9.1.yml 371 | pull_request_target: 372 | paths-ignore: 373 | - .github/workflows/nix-action-rocq-9.1.yml 374 | types: 375 | - opened 376 | - synchronize 377 | - reopened 378 | push: 379 | branches: 380 | - master 381 | --------------------------------------------------------------------------------