Skip to content

nix: add flake + packaging#228

Open
Mag1cByt3s wants to merge 1 commit intoambionics:masterfrom
Mag1cByt3s:nix-support
Open

nix: add flake + packaging#228
Mag1cByt3s wants to merge 1 commit intoambionics:masterfrom
Mag1cByt3s:nix-support

Conversation

@Mag1cByt3s
Copy link

What this PR does:

Adds Nix support for PHPGGC so it can be built/run fully reproducible using Nix without Docker.

  • Adds flake.nix with:
    • packages.phpggc / packages.default (nix build .#phpggc)
    • apps.default (nix run .#phpggc -- …)
    • devShells.default (nix develop)
  • Adds package.nix that packages the repository as a Nix derivation:
    • Installs the upstream sources (gadgetchains/, lib/, templates/, etc.) into $out/share/phpggc
    • Provides a phpggc wrapper in $out/bin/phpggc that runs via Nix’s PHP with phar.readonly=0 and changes the cwd into the installed share/ dir so relative includes work
  • Adds shell.nix dev environment roughly mirroring the Dockerfile tooling:
    • php, composer, curl, python3, python3Packages.rich, plus the packaged phpggc

Why:

  • Makes it trivial to run PHPGGC on Nix/NixOS and provides a reproducible workflow for development/testing.
  • Avoids reliance on container images for day-to-day usage.

How to use / test:
From the repo root:

  • Build:
    • nix build .#phpggc
  • Run:
    • nix run .#phpggc -- -l
    • nix run .#phpggc -- <chain> [args…]
  • Dev shell:
    • nix develop
    • (non-flake alternative): nix-shell

Notes:

  • The wrapper enforces -d phar.readonly=0 to match the Dockerfile behavior and support PHAR payload generation when requested.
  • The packaged phpggc script is stored under $out/share/phpggc (invoked via the wrapper), so it doesn't rely on the source checkout layout at runtime.

Files added:

  • flake.nix
  • shell.nix
  • package.nix
  • flake.lock

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.

1 participant