motivation/background
I’ve got some documentation that includes some examples from nixpkgs. I’d like to keep the examples up-to-date.
I’ve been doing this by just keeping an adjacent nixpkgs checkout, and letting the documentation-updating code pull from it (i.e., …/nixpkgs/path-to-example.nix).
I’m updating the repo to use a flake, and I’d like to update this procedure to pull the examples out of the nixpkgs rev pinned in the flake. I’d like to keep this relative to the source so that I don’t need to change the doc generator.
I want to symlink the store path corresponding to the source of the flake’s nixpkgs
input in the working directory.
It feels clunky, but I’ve found at least one solution that involves adding an output with nixpkgs outPath
and then using an eval/build pair to link it:
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# ...
};
outputs = { self, nixpkgs }:
{
#...
nixpkgs_source = nixpkgs.outPath;
#...
};
$ nix build --out-link this-feels-dumb-is-there-a-better-way "$(nix eval .#nixpkgs_source --raw)"
$ readlink this-feels-dumb-is-there-a-better-way
/nix/store/2ayipj5kgy67231fvbl8agsl591kanw8-source
Anyone know of a cleaner way?