feat: allow postInstall to be a function of { system, pkgs } - #184
Open
xAlisher wants to merge 1 commit into
Open
feat: allow postInstall to be a function of { system, pkgs }#184xAlisher wants to merge 1 commit into
xAlisher wants to merge 1 commit into
Conversation
Mirrors the existing preConfigure function-or-string handling. A module's postInstall snippet often needs
per-system context — e.g. injecting a helper binary/bundle built for the CURRENT system into $out. Today
the only way to pick the right per-system derivation from the single postInstall string is
builtins.currentSystem, which throws in pure eval and breaks 'nix build' in CI (multi-variant runners).
With this, a module can write:
postInstall = { system, pkgs }: ''cp -a ${bundleFor system}/. $out/lib/bin/'';
evaluated per-system in buildCppPlugin (system + pkgs already in scope there). Plain-string postInstall
is unchanged (backward compatible).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
postInstallis a single string, baked once (outside the per-system loop). When a module's postInstallneeds to inject a per-system artifact into
$out— e.g. a helper binary/bundle built for the currentsystem — the only way to select the right per-system derivation from that one string is
builtins.currentSystem, which throws in pure eval (attribute 'currentSystem' missing) and breaksnix buildin CI (the multi-variant release runners build each variant purely on its native runner).Fix
Let
postInstallbe either a string or a function{ system, pkgs }: string, evaluated per-system inbuildCppPlugin(wheresystem+pkgsare already in scope). This mirrors the existingpreConfigurefunction-or-string handling right above it. Plain-string
postInstallis unchanged — fully backward compatible.Verified
Built a real consumer (receiver-basecamp, which ships a per-system ffplay/tor/privoxy bundle) against this
branch with a function
postInstallandnix build .#lgx-portable— no--impure— succeeds andproduces the correctly-bundled
.lgxper variant. Without this change the same flake needs--impure(
currentSystem) and fails the pure CI build.Context: xAlisher/receiver-basecamp#80.