Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ main.xml
Makefile
manual.lab
missing
result
src/pkgconfig.h.in
tags
tst/out/
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
description = "The GAP package Digraphs";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
gap = pkgs.gap;
gaproot = "${gap}/lib/gap";
in
{
default = self.packages.${system}.digraphs;

digraphs = pkgs.stdenv.mkDerivation {
pname = "gap-digraphs";
version = "1.14.0";

src = ./.;

nativeBuildInputs = with pkgs; [
autoconf
automake
gcc
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.

nativeBuildInputs includes gcc, but this flake advertises Darwin support as well; forcing gcc can cause toolchain mismatches or failures on macOS where the default stdenv compiler is clang. Consider relying on stdenv.cc (already provided by mkDerivation) and drop gcc, or select an appropriate stdenv/toolchain per-system.

Suggested change
gcc

Copilot uses AI. Check for mistakes.
gnumake
];

buildInputs = [
gap
];

configurePhase = ''
runHook preConfigure

# Generate the configure script
mkdir -p gen
aclocal -Wall --force
autoconf -Wall -f
autoheader -Wall -f

# Run configure, pointing at the GAP root
./configure --with-gaproot=${gaproot}

runHook postConfigure
'';
Comment on lines +40 to +53
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 custom configurePhase calls ./configure without passing the standard Nix configure flags (e.g., --prefix=$out, build/host flags, and any configureFlags), which can lead to incorrect paths and reduced portability (especially for cross builds). Prefer using the default configurePhase with configureFlags = [ "--with-gaproot=..." ]; or, if keeping a custom phase, invoke ./configure with the standard flags included.

Copilot uses AI. Check for mistakes.

Comment on lines +40 to +54
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.

This flake reimplements the repo's existing ./autogen.sh logic inline. Using the script directly (or autoreconfHook) would reduce drift if the autogen steps change in the future and keeps the build definition simpler.

Suggested change
configurePhase = ''
runHook preConfigure
# Generate the configure script
mkdir -p gen
aclocal -Wall --force
autoconf -Wall -f
autoheader -Wall -f
# Run configure, pointing at the GAP root
./configure --with-gaproot=${gaproot}
runHook postConfigure
'';
preConfigure = ''
./autogen.sh
'';
configureFlags = [
"--with-gaproot=${gaproot}"
];

Copilot uses AI. Check for mistakes.
buildPhase = ''
runHook preBuild
make
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 overridden buildPhase runs plain make, which bypasses the standard stdenv make flags (including parallelism and any makeFlags). To keep builds consistent and faster under Nix, either use the default buildPhase or call make with the stdenv-provided flags.

Suggested change
make
make $makeFlags

Copilot uses AI. Check for mistakes.
runHook postBuild
'';

installPhase = ''
runHook preInstall

mkdir -p "$out/digraphs"

# Copy GAP source files
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

Comment on lines +66 to +84
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 to ignore missing paths, which can silently produce incomplete outputs if a directory unexpectedly disappears or is renamed. Prefer explicit if [ -d ... ]; then ...; fi (or a single copy of an explicit file list) so packaging failures are surfaced when the layout changes.

Suggested change
# Copy GAP source files
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 GAP source files (required)
cp -r gap "$out/digraphs/"
# Copy optional GAP directories if they exist
if [ -d lib ]; then
cp -r lib "$out/digraphs/"
fi
if [ -d doc ]; then
cp -r doc "$out/digraphs/"
fi
if [ -d data ]; then
cp -r data "$out/digraphs/"
fi
if [ -d tst ]; then
cp -r tst "$out/digraphs/"
fi
# Copy the compiled shared object (required)
cp -r bin "$out/digraphs/"
# Copy required package metadata files
cp PackageInfo.g "$out/digraphs/"
cp init.g "$out/digraphs/"
cp read.g "$out/digraphs/"
# Copy optional metadata / documentation files if they exist
if [ -f makedoc.g ]; then
cp makedoc.g "$out/digraphs/"
fi
if [ -f LICENSE ]; then
cp LICENSE "$out/digraphs/"
fi
if [ -f CHANGELOG.md ]; then
cp CHANGELOG.md "$out/digraphs/"
fi
if [ -f README.md ]; then
cp README.md "$out/digraphs/"
fi

Copilot uses AI. Check for mistakes.
runHook postInstall
'';

meta = with pkgs.lib; {
description = "GAP methods for graphs, digraphs, and multidigraphs";
homepage = "https://digraphs.github.io/Digraphs";
license = licenses.gpl3Plus;
platforms = platforms.unix;
};
};
}
);

devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
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"
'';
};
}
);
};
}
Loading