flake-compat icon indicating copy to clipboard operation
flake-compat copied to clipboard

return result of all packages

Open teto opened this issue 2 years ago • 2 comments

in a flake I work on, I need to provide a compatibility layer for other packages than the default one, exposing result gives me the possibility. I dont mind if this gets closed, just wanted to share the possibility.

With this PR, one can use the following shell.nix to reference a specific package

{ system ? builtins.currentSystem or "unknown-system" }:

(import (
let
    lock = builtins.fromJSON (builtins.readFile ./flake.lock);
  in fetchTarball {
    url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
    sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
  src =  ./.;
}).result.packages.${system}.ci

teto avatar Sep 15 '21 12:09 teto

This change does not seem to be needed, because both defaultNix and shellNix are already based on result (only the value for the default key is changed, and default is not a standard name for a flake output, so a flake should not define it anyway; if you have a really nonstandard flake, you could still reach the original default value through .defaultNix.outputs.default or .shellNix.outputs.default).

So you already should be able to use .shellNix.packages.${system}.ci in your code instead of the suggested .result.packages.${system}.ci.

BTW, a more direct way to refer to the default devshell in shell.nix would be using .shellNix.default instead of just .shellNix; omitting the .default part results in Nix scanning the flake outputs and finding just a single default derivation there, which seems to work at the moment, but might break if another derivation appears in some top-level attribute of the flake output for some reason.

sigprof avatar Jun 29 '22 20:06 sigprof

BTW, a more direct way to refer to the default devshell in shell.nix would be using .shellNix.default instead of just .shellNix; omitting the .default part results in Nix scanning the flake outputs

I think that's the part that confused me. Now that I read the code with more flake experience, seems like you are spot on. Closing, thanks for the review.

teto avatar Jun 29 '22 22:06 teto