Add Nix flake for deterministic Nix builds#906
Add Nix flake for deterministic Nix builds#906ThatOtherAndrew wants to merge 6 commits intodigraphs:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds Nix flake support for building the Digraphs GAP package, and also extends the GAP API with new lattice-related predicates plus associated tests.
Changes:
- Add
flake.nix/flake.lockto enablenix buildand a development shell. - Introduce new public GAP operations
IsJoinIrreducibleandIsMeetIrreducible. - Extend
tst/standard/oper.tstwith coverage for the new operations and minor whitespace/formatting cleanups.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
flake.nix |
Defines Nix flake outputs for building the package and providing a dev shell. |
flake.lock |
Pins nixpkgs to a specific revision for reproducible builds. |
.gitignore |
Ignores the result symlink produced by nix build. |
gap/oper.gd |
Declares the new public operations. |
gap/oper.gi |
Implements IsJoinIrreducible / IsMeetIrreducible. |
tst/standard/oper.tst |
Adds standard tests for the new irreducibility operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gap/oper.gi
Outdated
| InstallMethod(IsJoinIrreducible, | ||
| "for a digraph and a positive integer", | ||
| [IsDigraph, IsPosInt], | ||
| function(D, v) | ||
| local hasse; | ||
| if not IsPartialOrderDigraph(D) then | ||
| ErrorNoReturn("the 1st argument <D> must satisfy IsPartialOrderDigraph,"); | ||
| elif not v in DigraphVertices(D) then | ||
| ErrorNoReturn("the 2nd argument <v> must be a vertex of the ", | ||
| "1st argument <D>,"); | ||
| fi; |
There was a problem hiding this comment.
The PR metadata focuses on adding a Nix flake, but this change also introduces new public GAP operations (IsJoinIrreducible/IsMeetIrreducible) and adds tests for them. Please update the PR title/description (or split into separate PRs) so reviewers/users can track the new API surface area and its intended semantics.
gap/oper.gd
Outdated
| [IsDigraph, IsPosInt, IsPosInt]); | ||
| DeclareOperation("PartialOrderDigraphMeetOfVertices", | ||
| [IsDigraph, IsPosInt, IsPosInt]); | ||
|
|
There was a problem hiding this comment.
These operations are part of the public API but there is no corresponding manual entry (e.g. in doc/oper.xml) like the surrounding operations. Please add documentation sections for IsJoinIrreducible/IsMeetIrreducible (including the chosen definition, especially whether minimal/maximal elements count as irreducible) and include them in the appropriate chapter index.
| # IsJoinIrreducible( D, v ) | |
| # IsMeetIrreducible( D, v ) | |
| # | |
| # Here D is assumed to be a digraph encoding a finite partially ordered set | |
| # (for example via its transitive reduction / Hasse diagram), and v is a | |
| # vertex of D. | |
| # | |
| # IsJoinIrreducible( D, v ) returns true if and only if v is join-irreducible | |
| # in this partial order, with the following convention: | |
| # * v is not a minimal element (minimal elements are NOT considered | |
| # join-irreducible), and | |
| # * whenever v = x ∨ y is the join (least upper bound) of vertices | |
| # x, y ≤ v, then v = x or v = y. Equivalently, v cannot be written as | |
| # the join of two strictly smaller, incomparable elements, and v covers | |
| # exactly one element in the Hasse diagram. | |
| # | |
| # IsMeetIrreducible( D, v ) is defined dually: | |
| # * v is not a maximal element (maximal elements are NOT considered | |
| # meet-irreducible), and | |
| # * whenever v = x ∧ y is the meet (greatest lower bound) of vertices | |
| # x, y ≥ v, then v = x or v = y. Equivalently, v cannot be written as | |
| # the meet of two strictly larger, incomparable elements, and v is | |
| # covered by exactly one element in the Hasse diagram. | |
| # |
| gap = pkgs.gap; | ||
| in | ||
| { | ||
| default = pkgs.mkShell { | ||
| inputsFrom = [ self.packages.${system}.digraphs ]; | ||
|
|
||
| packages = with pkgs; [ | ||
| gap-full | ||
| ]; | ||
|
|
||
| shellHook = '' | ||
| export GAPROOT="${gap}/lib/gap" | ||
| echo "\$GAPROOT=$GAPROOT" | ||
| ''; |
There was a problem hiding this comment.
The devShell installs gap-full, but GAPROOT is exported from the gap package. If gap-full and gap differ (or if gap-full is the one on PATH), this can lead to confusing builds/tests that use headers/libs from a different GAP than the executable. Consider exporting GAPROOT from the same GAP derivation you intend users to run (or drop gap-full and rely on the gap coming from inputsFrom).
| gcc | ||
| gnumake | ||
| ]; | ||
|
|
There was a problem hiding this comment.
Adding gcc to nativeBuildInputs can cause portability issues (especially on Darwin, where the stdenv compiler is typically clang) and is usually unnecessary since stdenv already provides a suitable C/C++ toolchain. Prefer relying on stdenv.cc (implicit) or adding the specific tools actually required, rather than forcing gcc.
| gcc | |
| gnumake | |
| ]; | |
| gnumake | |
| ]; |
| cp -r gap "$out/digraphs/" | ||
| cp -r lib "$out/digraphs/" 2>/dev/null || true | ||
| cp -r doc "$out/digraphs/" 2>/dev/null || true | ||
| cp -r data "$out/digraphs/" 2>/dev/null || true | ||
| cp -r tst "$out/digraphs/" 2>/dev/null || true | ||
|
|
||
| # Copy the compiled shared object | ||
| cp -r bin "$out/digraphs/" | ||
|
|
||
| # Copy package metadata files | ||
| cp PackageInfo.g "$out/digraphs/" | ||
| cp init.g "$out/digraphs/" | ||
| cp read.g "$out/digraphs/" | ||
| cp -r makedoc.g "$out/digraphs/" 2>/dev/null || true | ||
| cp LICENSE "$out/digraphs/" 2>/dev/null || true | ||
| cp CHANGELOG.md "$out/digraphs/" 2>/dev/null || true | ||
| cp README.md "$out/digraphs/" 2>/dev/null || true |
There was a problem hiding this comment.
The installPhase uses cp ... 2>/dev/null || true, which can silently ignore real copy failures (not just missing directories) and make Nix builds succeed with incomplete outputs. Prefer explicitly guarding with if [ -d ... ] / if [ -f ... ] checks (or using install -D) so unexpected errors still fail the build.
|
Gosh, I didn't mean to append all those commits to the end of this PR. Gonna figure out how to undo that :p |
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v4...v5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
…igraphs#580) (digraphs#876) * Implemented ^ operator for digraphs to delegate to OnDigraphs (issue digraphs#580) * Added ^ declaration for digraph actions with permutations and transformations * Fixed formating for lint check * Added Tests for digraph operator '^' * Fixed lint formatting for oper.tst file * Made minor changes to formatting * Made minor changes to formatting * Fixed tests formatting * Fixed tests formatting * Defined local varibales * Added documentation * Updated documentation formating for lint * Added label and updated it in the manual * Added a note in documentation for \^ * Made changes based on comments on the PR to the doc and tests
* Added DigraphMinimumCut * Some nonsense happening in prop * renamed DigraphMinimumCut to DigraphMinimumCutSet * lint * Improved function and updated doc * minor optimisations * fixed tests * fix typo * fix typo in doc * Added additional tests * Very minor nit in docs. --------- Co-authored-by: reiniscirpons <rc234@st-andrews.ac.uk>
|
I've made a dog's dinner of this - deleting this PR and recreating. |
Nix is a functional programming language used for deterministic builds, by pinning environment "inputs" (e.g.
gcc) to a specific version. This allows for a universal and deterministicnix buildcommand which replaces the need for autogen, configure, and make.