Flake dependency synchronization between input and nixpkgs


I am working on a project (let’s call it WRAPPER) which consists entirely of APIs and utilites which help with writing code in a specific scientific simulation framework (let’s call it FRAMEWORK).

There is a derivation for FRAMEWORK in nixpkgs.

I use a flake to develop, manage and distribute WRAPPER.

In the flake I want to provide a template for starting a project that uses WRAPPER to write a FRAMEWORK application.

This template should contain a flake for managing the project it bootstraps.

The template’s flake has WRAPPER’s flake as an input, but it has to get FRAMEWORK from nixpkgs.

So, inside the template’s flake, FRAMEWORK is a direct dependency (via nixpkgs) as well as an indirect one (via WRAPPER’s flake).


How should I ensure that both of these use the same version of FRAMEWORK?

If FRAMEWORK were a flake, I might use something roughly like WRAPPER.inputs.FRAMEWORK.follows = "FRAMEWORK", but given that FRAMEWORK is only available as a legacy package, what is the most sensible way forward?

Sorry if I’m completely misinterpreting this, it’s a bit tricky to follow without code. I think effectively you just want to ensure that both projects use the same version of nixpkgs right? And you meant wrapper, not framework here:

If so, why would this not work:

# template flake.nix
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    wrapper = {
      url = "somewhere";
      inputs.nixpkgs.follows = "nixpkgs";

Legacy packages will still come from a specific commit of the repository, there’s nothing special about how legacy packages are handled except that they are permitted to be nested. Maybe the attr should be renamed to nestedPackagesDontUse to be clearer…

Or alternatively, if you’re worried about the template not using the right version of nixpkgs for your code:

# template flake.nix
  inputs = {
    wrapper.url = "somewhere";
    nixpkgs.follows = "wrapper/nixpkgs";

Thanks. Edited.

Exactly, I wasn’t sure about this.

On the one hand, I don’t want to impose a version of FRAMEWORK on the user; on the other, if the user picks a version that is incompatible with WRAPPER, I suspect that the error messages are not going to be very nice.

OK, so

inputs.THIS.follows = "THAT/THIS";

works as a way of adding inputs.THIS. Makes sense.

Yeah, sadly that’s not possible if you don’t actively support all versions of FRAMEWORK. The user can always change what nixpkgs version they use through the template output if they’re adventurous, I believe a template should focus on getting something that is more or less guaranteed to work.

1 Like