Importing from inputs.<flake>.sourceInfo.outPath/...?

I’m doing some work with a single board computer that requires some configuration changes for how the kernel is compiled, and some of the tools I need are not exposed as outputs in nixpkgs. Rather than copying files from nixpkgs and having to do that evert time I update, I wanted to import files from the nixpkgs source, you could do that pre-flakes with:

import <nixpkgs/path/to/the/file.nix>

The closes equivalent I was able to find with flakes is:

import "${inputs.nixpkgs.sourceInfo.outPath}/path/to/the/file/nix"

It seems like this might not be an intended usage, is this alright or is there some better alternative?

Inputs can cleanly be coerced into strings. You can just do this: import "${input.nixpkgs}/file

Also for more context, any attribute set that has the outPath attr can be coerced into a string like this.

1 Like