Resolved store paths
Nix resolves all valid derivations to a store path. Here’s an example:
nix path-info "https://flakehub.com/f/NixOS/nixpkgs/*#coreutils"
That command evaluates a specific flake reference from Nixpkgs and returns a store path of this form (it will differ on your system):
/nix/store/1. Nix store prefixsglc12hc6pc68w5ppn2k56n6jcpaci162. Hash part-coreutils-9.53. Package name
Evaluating store paths is an expensive operation in Nix, and one that’s preferably avoided on resource-constrained devices or when Nix is not available on the host system.
For situations like this, FlakeHub can resolve store paths for you, persist them, and make them available via the fh resolve
and fh apply
commands.
Resolved store paths are generally useful only if you’re using FlakeHub Cache, because if flake outputs are cached, you can use the resolved store path or operations like nix copy
and applying system configurations.
To unlock this feature, sign up for a paid plan.
Resolving paths using fh
You can use the fh resolve
command to fetch resolved store paths from FlakeHub.
Here’s an example:
fh resolve "https://flakehub.com/f/my-org/my-flake/0.1#nixosConfigurations.auth-server"
That would return a store path like this:
/nix/store/5yg2v0iz3dl27rwaw3brzadwfj702b89-auth-server-0.1.4
What’s noteworthy here, though, is that Nix isn’t resolving the store path; instead, fh is making an HTTP request to the FlakeHub API to fetch the store path (and that request is automatically authenticated if the flake is private). The store path is available this way because flakehub-push already generated it during the flake’s publishing process (see How to pre-resolve store paths below to see how to enable this).
Applying system configurations using fh
You can apply full system configurations for NixOS, Home Manager, and nix-darwin from resolved store paths using the fh apply
.
Here are some examples:
fh apply nixos "my-org/my-nixos-config-flake/*"
fh apply home-manager "my-org/my-home-manager-config-flake/*"
fh apply nix-darwin "my-org/my-nix-darwin-config-flake/*"
In all these cases, Nix doesn’t need to evaluate the flake reference to determinate the store path; the store path is already available and Nix can copy the closure at that path directly from FlakeHub Cache.
This can make some deployment scenarios far less resource intensive than those involving standard nix build
commands.
How to pre-resolve store paths
You can make FlakeHub resolve and persist store paths when publishing your flakes by adding a single line to your flakehub-push configuration:
- name: Publish to FlakeHub
uses: DeterminateSystems/flakehub-push@main
with:
include-output-paths: true
Once you’ve added this configuration, subsequent releases of your flake will have resolved store paths available to fh resolve
.
If you’re using FlakeHub Cache, then you can use fh apply
to apply NixOS, Home Manager, and nix-darwin system configurations.
Alternatively, you can use the DeterminateSystems/ci Action, which provides an opinionated path to Nix CI by setting include-output-paths
to true
and automatically caching all of your flake’s derivation outputs.