Mic92 / nix-update

Swiss-knife for updating nix packages.
MIT License
504 stars 47 forks source link

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

Open lucasew opened 7 months ago

lucasew commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

lucasew commented 7 months ago

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.

lucasew commented 7 months ago

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 commented 7 months ago

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

lucasew commented 7 months ago

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.