Skip to content

feat: allow postInstall to be a function of { system, pkgs } - #184

Open
xAlisher wants to merge 1 commit into
logos-co:masterfrom
xAlisher:feat/postinstall-function
Open

feat: allow postInstall to be a function of { system, pkgs }#184
xAlisher wants to merge 1 commit into
logos-co:masterfrom
xAlisher:feat/postinstall-function

Conversation

@xAlisher

@xAlisher xAlisher commented Aug 5, 2026

Copy link
Copy Markdown

Problem

postInstall is a single string, baked once (outside the per-system loop). When a module's postInstall
needs to inject a per-system artifact into $out — e.g. a helper binary/bundle built for the current
system — 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 breaks
nix build in CI (the multi-variant release runners build each variant purely on its native runner).

Fix

Let postInstall be either a string or a function { system, pkgs }: string, evaluated per-system in
buildCppPlugin (where system + pkgs are already in scope). This mirrors the existing preConfigure
function-or-string handling right above it. Plain-string postInstall is unchanged — fully backward compatible.

# a module can now do, purely:
postInstall = { system, pkgs }: ''
  mkdir -p $out/lib/bin
  cp -a ${helperBundleFor system}/. $out/lib/bin/
'';

Verified

Built a real consumer (receiver-basecamp, which ships a per-system ffplay/tor/privoxy bundle) against this
branch with a function postInstall and nix build .#lgx-portable — no --impure — succeeds and
produces the correctly-bundled .lgx per variant. Without this change the same flake needs --impure
(currentSystem) and fails the pure CI build.

Context: xAlisher/receiver-basecamp#80.

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