Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-build phase isn't working? #2048

Open
kamek-pf opened this issue Sep 7, 2023 · 5 comments
Open

pre-build phase isn't working? #2048

kamek-pf opened this issue Sep 7, 2023 · 5 comments
Labels
bug Something isn't working wontfix

Comments

@kamek-pf
Copy link

kamek-pf commented Sep 7, 2023

Hi there,

I'm using postgresql-typed to check my queries against a live database instance at compile time through TH.
I need to pass some environment variables to the build, but I can't get it to work. This is what I have so far:

overlays = [
  haskell-nix.overlay
  (final: prev: {
    my-test-project =
      final.haskell-nix.project' {
        src = ./.;
        compiler-nix-name = "ghc945";
        modules = [{ dontStrip = false; }];
      };
    packages.my-test-project.preBuild = final.lib.mkForce ''
      export TPG_HOST=...
      export TPG_DB=...
      export TPG_USER=...
      export TPG_PASS=...
    '';
  })
];

Which I then build with nix build --no-sandbox.
It appears the build hook is never executed so I assume I'm using it wrong. Any pointers ?

@kamek-pf kamek-pf added the enhancement New feature or request label Sep 7, 2023
Copy link

stale bot commented Jan 5, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 5, 2024
@stale stale bot closed this as completed Mar 6, 2024
@michaelpj
Copy link
Collaborator

Not sure if this is stale but it's pretty bad if the pre-build hook doesn't work.

@michaelpj michaelpj reopened this Mar 6, 2024
@stale stale bot removed the wontfix label Mar 6, 2024
@michaelpj michaelpj added bug Something isn't working and removed enhancement New feature or request labels Mar 6, 2024
@michaelpj michaelpj changed the title Set environment variables before building ? pre-build phase isn't working? Mar 6, 2024
Copy link

stale bot commented Jul 5, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 5, 2024
@hamishmack
Copy link
Collaborator

I just noticed you are setting packages.my-test-project.preBuild in the wrong place. It needs to be set in the modules argument something like this instead:

overlays = [
  haskell-nix.overlay
  (final: prev: {
    my-test-project =
      final.haskell-nix.project' {
        src = ./.;
        compiler-nix-name = "ghc945";
        modules = [{
          dontStrip = false;
          packages.my-test-project.preBuild = final.lib.mkForce ''
            export TPG_HOST=...
            export TPG_DB=...
            export TPG_USER=...
            export TPG_PASS=...
          '';
        }];
      };
  })
];

@stale stale bot removed the wontfix label Jul 8, 2024
Copy link

stale bot commented Nov 6, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix
Projects
None yet
Development

No branches or pull requests

3 participants