Setting up nix and git for mathcomp on HB - math-comp/math-comp GitHub Wiki
Follow the installation procedure documented here: https://github.com/math-comp/math-comp/wiki/Using-nix#nix-installation-pre-requisite-for-the-rest
This is one method among many. You can also work with your own setup, just make sure upstream
points to math-comp/math-comp
. (e.g. git clone [email protected]:math-comp/math-comp -o upstream
should suffice if you already registered your ssh-key on github).
I strongly advise you setup push.default
git option to current
-
Go to your repo, update the remotes
cd ~/git/math-comp/master && git remote update
-
Create a worktree for the
hierarchy-builder
branch and go thereHB=hierarchy-builder git worktree add -b $HB ../$HB upstream/$HB && cd ../$HB
-
Start working.
I strongly advise you work inside mathcomp's dedicated nix-shell by running
nix-shell
from the root of the repository (otherwise you will need to install HB by hand and update it by hand if we need to change it).
Before touching any file, and before compiling, inside the nix-shell, you can try to run
cachedMake # you may want to check the cache is there before cleaning your previous .vo make -C mathcomp clean cachedMake make -C mathcomp -t # to touch all .vo in order so that the next call to make does not recompile everything
- if it starts with
these paths will be fetched
, you just skipped ~20min of compilation of the current mathcomp port. - otherwise, go back to manual compilation:
make -j8 -k -C mathcomp
, or clean/stash your local modifications and wait for the CI to finish and retry againcachedMake
.
- if it starts with
-
Working on a file using one of the three following editors:
-
coqide
: if you rannix-shell
it is available, you can start working with it -
emacs
: you can run your own emacs if you installed proof-general and set thecoq-prog-name
variable tocoqtop
. Optionally, if you do not have emacs or proof-general installed you can runnix-shell --arg withEmacs true
to get a preconfigured emacs (independent from your$HOME
configuration). -
vscode
: you can installvscode
with thevscoq
extension, if you ran it from inside thenix-shell
it should be ready to use.
-
-
If you make changes to some files, commit before you stop working. Make sure rebase on top of the shared branch now and then.
git pull -r upstream hierarchy-builder
-
When you are ready to submit your work,
- push it
git push upstream hierarchy-builder # DO NOT FORCE
- if this failed, rebase on top of the current state of the branch
resolve potential conflicts (they should only occur
git pull -r upstream hierarchy-builder
mathcomp/Make
) and try to push again. - then go to #733 and tick/untick the appropriate boxes.
- push it
This is one method among many. You can also work with your own setup, just make sure origin
points to your fork GithubUsername/hierarchy-builder
and upstream
to math-comp/hierarchy-builder
.
However, I will often rely on the git worktree
command to avoid duplication of git metadata and objects, and thus save bandwidth and disk space, so I will initialize my repositories with the path ~/git/repo/master
and store branches other than master under git/repo/branch
.
To perform several github operations from the command line, I will assume that you have either installed the gh
utilities via your system package manager, or that you can started nix-shell -p gh
to get a shell with gh
accessible.
-
Install
gh
or runnix-shell -p gh
-
Run
gh auth login -w
copy the one-time code then press enter, and paste the code in the browser that just opened, identify if required and authorize the app. This will install an ssh-key and remember your username.
-
Fork
hierarchy-builder
on github:gh repo fork math-comp/hierarchy-builder --clone=false
(if you already have a fork this is a noop)
-
Prepare for the install:
mkdir -p ~/git/hierarchy-builder && cd ~/git/hierarchy-builder gh repo clone hierarchy-builder master && cd master
This will clone mathcomp and set the right
origin
andupstream
-
Setup local mirroring of PRs:
git config --add remote.upstream.fetch \ "+refs/pull/*/head:refs/remotes/upstream/pr/*" git remote update
-
Go to your repo, update the remotes
cd ~/git/hierarchy-builder/master && git remote update
-
Update you master branch to the latest revision
git merge --ff-only upstream/master
If this fails, it means your master branch has diverged from the upstream (
math-comp
) one, it also means that you might have used your master branch to develop or test something, which is a bad practice.- If you want to abandon modifications, do
git reset --hard upstream/master
⚠️ this will erase whatever you did on your master branch. - Otherwise, you may want to continue this tutorial, keeping in mind that you will then start from your own master rather than
hierarchy-builder
master.
- If you want to abandon modifications, do
-
Create a new branch (e.g.
test-PR
), in a new directory of the same name and go theregit worktree add ../test-PR && cd ../test-PR
-
Start working.
I strongly advise you work inside mathcomp's dedicated nix-shell by running
nix-shell
from the root of the repository.
Before touching any file, and before compiling, inside the nix-shell, try to run
cachedMake
- if it starts with
these paths will be fetched
, you just skipped ~10min of compilation of mathcomp. - otherwise, interrupt and go back to manual compilation:
make -j8 -k -C mathcomp
- if it starts with
-
Working on a file will only work with VS code (or codium) you need to install
vscode
with the three following extensions:-
vscoq
extension -
elpi
extension -
coq-elpi
extension if you ran it from inside thenix-shell
it should be ready to use.
-
-
If you make changes to some files, commit before you stop working. Make sure rebase on top of upstream master now and then.
git pull -r upstream master
-
Compile and run tests with
make
inside a nix-shell -
You can try it on
math-comp/math-comp
- on the branch
hierarchy-builder
by running(you can removenix-build --argstr bundle "coq-8.13" --argstr job "mathcomp-single"`
--argstr bundle "coq-8.13"
to try the three versions of coq at the same time) - on another branch by editing
.nix/config
and replacingbymathcomp.override.version = "hierarchy-builder";
mathcomp.override.version = "your-branch";
- on the branch
-
When you are ready to submit a PR, push it to your own fork:
git push origin test-PR
and follow the given link to create a new PR. It has the shape
https://github.com/<your-github-username>/hierarchy-builder/pull/new/<your-PR>
⚠️ Never ever push directly to upstream master⚠️ Never usegit push
without a repo and a branch