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

[Feature Request] Some way to copy files from src to the nix code folder #237

Open
lucasew opened this issue Mar 21, 2024 · 6 comments
Open

Comments

@lucasew
Copy link

lucasew commented Mar 21, 2024

The problem:

Packages built with buildFlutterApplication need to vendor the pubspec.lock as a JSON file to be used in the builder. The issue is that there is no simple way to setup this in a r-ryantm friendly way.

What I suggest is something like a function that gets defined in passthru that receives the src and returns the stuff that should be copied in the Nix code folder.

Example:

...

passthru = {
    updateScript = nix-update-script { };
    updateReducer = src: stdenv.mkDerivation {
       name = "source-reducer";
       dontUnpack = true;
       installPhase = ''
           mkdir $out
           cp $src/pubspec.lock $out/pubspec.lock
      '';
    };
};
...

That pubspec.lock will be copied to the location where the nix file defining the derivation is located in a cp $src/* $out fashion. It seems the primitives are already there but I need to study more the code to find out where should I put it and write a prototype.

@Mic92
Copy link
Owner

Mic92 commented Mar 21, 2024

Would be great if you also have other examples where this might be needed to find a good abstraction that can be re-used.

@Mic92
Copy link
Owner

Mic92 commented Mar 21, 2024

Does the normal nix build itself also need the pubspec.lock?

@lucasew
Copy link
Author

lucasew commented Mar 21, 2024

Would be great if you also have other examples where this might be needed to find a good abstraction that can be re-used.

Any case that would otherwise be a IFD to get a file from src is a exemple.

  • pubspec
  • package.lock

@lucasew
Copy link
Author

lucasew commented Mar 22, 2024

Does the normal nix build itself also need the pubspec.lock?

buildFlutterApplication needs the pubspec.lock converted to JSON, having a API based on derivations instead of "copy this file there" would give more autonomy to the user without the risk of compromising the machine with unsandboxed noise such as cache files.

@Mic92
Copy link
Owner

Mic92 commented Mar 22, 2024

Ok. So what file does it produce after having the pubspec? I assume it generate some nix code?

@lucasew
Copy link
Author

lucasew commented Mar 22, 2024

Ok. So what file does it produce after having the pubspec? I assume it generate some nix code?

In the flutter case it consumes the pubspec.lock converted to JSON. Kind of Nix code with extra steps.

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

No branches or pull requests

2 participants