Skip to content

Add Nix flake for deterministic Nix builds#906

Closed
ThatOtherAndrew wants to merge 6 commits intodigraphs:mainfrom
ThatOtherAndrew:main
Closed

Add Nix flake for deterministic Nix builds#906
ThatOtherAndrew wants to merge 6 commits intodigraphs:mainfrom
ThatOtherAndrew:main

Conversation

@ThatOtherAndrew
Copy link

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 deterministic nix build command which replaces the need for autogen, configure, and make.

Copilot AI review requested due to automatic review settings March 20, 2026 06:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.lock to enable nix build and a development shell.
  • Introduce new public GAP operations IsJoinIrreducible and IsMeetIrreducible.
  • Extend tst/standard/oper.tst with 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
Comment on lines +2723 to +2733
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;
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
gap/oper.gd Outdated
[IsDigraph, IsPosInt, IsPosInt]);
DeclareOperation("PartialOrderDigraphMeetOfVertices",
[IsDigraph, IsPosInt, IsPosInt]);

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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.
#

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +114
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"
'';
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +35
gcc
gnumake
];

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
gcc
gnumake
];
gnumake
];

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +83
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
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@ThatOtherAndrew
Copy link
Author

Gosh, I didn't mean to append all those commits to the end of this PR. Gonna figure out how to undo that :p

@ThatOtherAndrew ThatOtherAndrew marked this pull request as draft March 20, 2026 07:35
dependabot bot and others added 6 commits March 20, 2026 03:40
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>
@ThatOtherAndrew
Copy link
Author

I've made a dog's dinner of this - deleting this PR and recreating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants