Skip to content

Add Nix flake#23

Open
subtleGradient wants to merge 7 commits intoansilove:masterfrom
effect-native:nix-flake
Open

Add Nix flake#23
subtleGradient wants to merge 7 commits intoansilove:masterfrom
effect-native:nix-flake

Conversation

@subtleGradient
Copy link

Add Nix flake and contributor automation.

Summary

  • document the automation guidelines in AGENTS.md so future helpers know the repository conventions up front
  • add .envrc to auto-load the Nix flake for contributors who opt into direnv
  • ship a flake.nix + flake.lock pairing that builds libansilove and exposes a dev shell with clang and the right debugger per platform
  • extend .gitignore so the flake's result* outputs and direnv state never pollute commits

Why keep the flake in-tree?

  • Streamlined onboarding: README already calls out cross-platform dependency setup (BSDs, Linux, macOS); the flake captures those packages once so new contributors land in a working shell instantly, with pkg-config, clang tools, and GD pre-wired.
  • Nix packaging parity: libansilove is in nixpkgs today. This flake lets us validate packaging updates locally without leaving the repo, which reduces churn for the maintainer shepherding upstream bumps.
  • Reproducible tooling: Maintainers like @fcambus who juggle multiple projects can rely on Nix to supply consistent compilers, lint tooling, and GD even on Apple Silicon—no conflicts with Homebrew or system packages.
  • Optional, zero-risk: Nothing in the CMake flow changes. Builders who do not use Nix continue with the documented mkdir build && cmake .. && make path; the flake is additive and kept tidy via .gitignore.

Testing

  • nix develop --command echo ok
  • nix build
  • nix flake check --all-systems

This commit adds the AGENTS.md file, which contains guidelines for contributing to the project. This includes information on project
structure, build and test commands, coding style, testing guidelines, and commit/pull request guidelines.
Introduces a flake.nix file to manage the development environment for libansilove using Nix Flakes. This includes defining packages and a
development shell with necessary build tools and libraries.
This commit introduces the `flake.lock` file, which pins the exact versions of the dependencies used by the Nix flake. This ensures
reproducible builds by locking down the revisions of `nixpkgs`, `flake-utils`, and `nix-systems`.
Updates the flake.nix to use the `gd` package instead of the deprecated `libgd`. Also conditionally adds `gdb` for non-Darwin systems and
`lldb` for Darwin systems.
Include commands for entering the dev shell, building, and checking the flake. Also add a note about updating the flake.lock file.
Copilot AI review requested due to automatic review settings September 18, 2025 23:23
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 development tooling to streamline contributor onboarding and provide reproducible build environments. The changes introduce a complete Nix flake configuration that packages libansilove and provides a development shell with all necessary dependencies.

Key changes:

  • Adds Nix flake configuration for building libansilove and providing development environment
  • Documents repository conventions and automation guidelines for contributors
  • Provides direnv integration for automatic environment loading

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

File Description
flake.nix Complete Nix flake with package definition and dev shell configuration
AGENTS.md Comprehensive repository guidelines covering build, test, coding style, and PR conventions
CLAUDE.md Single-line file containing "AGENTS.md"
.envrc Direnv configuration to auto-load the Nix flake

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
version = "1.4.2";
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The version is hardcoded in the flake. Consider extracting this from CMakeLists.txt or another authoritative source to avoid version drift between the build system and the Nix package.

Suggested change
version = "1.4.2";
# Extract version from CMakeLists.txt
version = let
cmakeContents = builtins.readFile ./CMakeLists.txt;
matches = builtins.match ''set *\( *PROJECT_VERSION +([0-9]+\.[0-9]+\.[0-9]+) *\)'' cmakeContents;
in if matches != null && matches != [] then builtins.elemAt matches 0 else throw "Could not extract version from CMakeLists.txt";

Copilot uses AI. Check for mistakes.
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.

2 participants