Skip to content

Support Template Haskell in consumer code (mkAndroidLib) #141

@jappeace-sloth

Description

@jappeace-sloth

Problem

mkAndroidLib compiles consumer source files without -fexternal-interpreter, which means Template Haskell splices in the consumer's own code fail with:

<no location info>: error:
    Couldn't find a target code interpreter. Try with -fexternal-interpreter

TH works fine in dependency packages (built via cross-deps.nix) because those go through the full iserv-proxy setup. But the final GHC invocation in mkAndroidLib (lib.nix line ~311) doesn't include the TH flags.

Context

Discovered while migrating prrrrrrrrr from sqlite-simple to persistent + persistent-sqlite. Persistent uses TH (mkPersist, mkMigrate, persistLowerCase) to generate entity types and migrations.

Current workaround

Split TH code into a separate sub-package (prrrrrrrrr-schema) that gets built as a cross-dep, where TH works. The main consumer code then imports the TH-generated types without needing TH itself. This works but adds structural complexity.

Suggested fix

Pass -fexternal-interpreter -pgmi <iserv-wrapper-path> to the GHC invocation in mkAndroidLib, reusing the same iserv-proxy infrastructure from cross-deps.nix. Alternatively, expose an extraGhcFlags parameter so consumers can opt in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions