You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just kicking the discussion about refactoring the apis to provide better flake support.
Right now we have a mix and match of nix files, and it can become cumbersome to track which one does what, what arguments are passed to which invocation, and what paths are used by bazel in your nix code.
A proper flake api would use the interface these provide to simplify the interactions between bazel and nix.
Each repo should come with it's own flake subfolder. That path should then be passed to nixpkgs_flake(name = "custom_flake", path = "./nix/flake")
nixpkgs_package, and all the rules_nixpkgs entrypoints would take a flake_attribute_path argument. That one would be extracted from the said flake.
Problems may arise around custom nix files that we maintain in this repo, like cc.nix for the cc toolchain. You cannot use these as easily with flakes. One solution is to wrap the flake_attribute_path into an expression that imports the flake and access the attribute to feed that into cc.nix. Another option, more involved but cleaner, would be to provide these wrappers as part of a standalone flake, that people could integrate into their own flake (like flake-utils). That would enable them to provide suitable bazel toolchains from their flake, and use them in bazel with just the attribute path.
I know this is a rough sketch, and it probably deserves a POC implementation to see where we are going, but I think it has lots of potential to make interactions cleaner. For users for example, it becomes really easy to build a nix package identical to the one used by bazel. just build the attribute path. Currently you have to ensure that you use the same set ope nix_args, and other environment stuff.
It could also make evaluation and caching faster, but that pertains to #341
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Just kicking the discussion about refactoring the apis to provide better flake support.
Right now we have a mix and match of nix files, and it can become cumbersome to track which one does what, what arguments are passed to which invocation, and what paths are used by bazel in your nix code.
A proper flake api would use the interface these provide to simplify the interactions between bazel and nix.
nixpkgs_flake(name = "custom_flake", path = "./nix/flake")
flake_attribute_path argument
. That one would be extracted from the said flake.Problems may arise around custom nix files that we maintain in this repo, like cc.nix for the cc toolchain. You cannot use these as easily with flakes. One solution is to wrap the flake_attribute_path into an expression that imports the flake and access the attribute to feed that into cc.nix. Another option, more involved but cleaner, would be to provide these wrappers as part of a standalone flake, that people could integrate into their own flake (like flake-utils). That would enable them to provide suitable bazel toolchains from their flake, and use them in bazel with just the attribute path.
I know this is a rough sketch, and it probably deserves a POC implementation to see where we are going, but I think it has lots of potential to make interactions cleaner. For users for example, it becomes really easy to build a nix package identical to the one used by bazel. just build the attribute path. Currently you have to ensure that you use the same set ope nix_args, and other environment stuff.
It could also make evaluation and caching faster, but that pertains to #341
Beta Was this translation helpful? Give feedback.
All reactions