Path to Installed Package: Clarifying Flake Concepts

When I execute nix eval --raw nixpkgs#antidote the command does not return the desired/expected value (i.e., it returns /nix/store/...-antidote-1.9.10 rather than /nix/store/...-antidote-1.9.8). I’ve also tried nix eval --raw nixpkgs-stable#antidote but that outright fails.

Note: The nix-darwin installation sets nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; and nixpkgs-stable.url = "github:nixos/nixpkgs?ref=nixpkgs-25.05-darwin"; respectively. Antidote is installed via nixpkgs-stable.

I’ve installed antidote along with other packages via the following flake. How can/should I get the path to the antidote package? Thanks!

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";
    nixpkgs-stable.url = "github:nixos/nixpkgs?ref=nixpkgs-25.05-darwin";
    nix-darwin.url = "github:nix-darwin/nix-darwin/master";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs =
    inputs@{
      self,
      nixpkgs,
      nixpkgs-stable,
      nix-darwin,
    }:
    let
      system = "aarch64-darwin";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      pkgs-stable = import nixpkgs-stable {
        inherit system;
        config.allowUnfree = true;
      };
      configuration =
        { pkgs, pkgs-stable, ... }:
        {
          environment.systemPackages = with pkgs; [
            bat
            ...
            pkgs-stable.antidote
          ];
          # The platform the configuration will be used on.
          nixpkgs.hostPlatform = "aarch64-darwin";
        };
    in
    {
      darwinConfigurations."hostname" = nix-darwin.lib.darwinSystem {
        modules = [ configuration ];
        specialArgs = { inherit inputs pkgs pkgs-stable; };
      };
    };
}

Yes that’s the difference. antidote is on a different version on unstable vs stable.

@waffle8946: To clarify, when I execute nix eval --raw nixpkgs#antidote on the nix-darwin system the result is /nix/store/...-antidote-1.9.10 rather than the desired value of /nix/store/...-antidote-1.9.8.

To simplify and avoid further confusion, I’ll remove the mention of the nixos installation (which is on a separate and distinct host) from my post.

To clarify further, the version installed from the flake is the version you want, right? The only issue is that cli commands referencing nixpkgs get something different? (Though I’m not sure why you’re getting it from nixpkgs on the cli if it’s installed…)

@tejing: I’m using nix eval --raw nixpkgs#antidote in my .zshrc so antidote may be “sourced” as follows:

antidote_path=$(nix eval --raw nixpkgs#antidote)
source ${antidote_path}/share/antidote/antidote.zsh

Also, turns out it’s not quite installed.

eza -alo $(nix eval --raw nixpkgs#antidote)
“/nix/store/q3sznmv7v2xa2sy74sip8w7anpryqfsw-antidote-1.9.8”: No such file or directory (os error 2)

For context, in my flake I use both stable (25.05) and unstable dependencies. Earlier, I set the nixpkgs.url in my flake to unstable. I was under the impression that nix eval --raw nixpkgs#antidote would return the path to the installed package irrespective of whether it was installed via nixpkgs or nixpkgs-stable (see flake in original post). Any ideas/suggestions on how I may query the installed package if it is not from nixpkgs but rather e.g., nixpkgs-stable?

Lastly, I switched the dependency URLs and reinstalled. At this time, nixpkgs does give the expected version - but it does not seem to be installed (see above quote block). I’ve removed, rebuilt, and (re)added the package to systemPackages but antidote won’t install. Any thoughts?

Invoking nix in your .zshrc like that is a pretty bad idea. Among other things, it’s extremely slow. If you’re not going to declaratively set up your .zshrc itself, I’d recommend you declaratively place a symlink somewhere (on nixos I’d do it in /etc through environment.etc, but I’m not sure what would be a good idea on nix-darwin) and have your .zshrc source the file from the symlink. (Or get it directly from /run/current-system/sw, if the file gets properly merged into that… which it should, if it’s in share)

This is the normal behavior of nix eval. If you wanted the store path to actually be realized, use nix build --no-link --print-out-paths.

What you seem to be expecting to happen here doesn’t actually happen. The nix registry entry nixpkgs has nothing to do with the flake inputs of the flake you used to build the system, unless you explicitly configure the registry that way in your system configuration (which nixos now does by default, but only for nixpkgs, not other flake inputs).

If you don’t want nixpkgs to refer to the nixpkgs rev your system was built with, set

{ inputs, ... }:
{
  nix.registry.nixpkgs.flake = inputs.nixpkgs-stable;
}
1 Like

To be clear, the registry’s nixpkgs by default points to github:NixOS/nixpkgs?ref=nixpkgs-unstable, which is whatever the current master of nixpkgs head of the nixpkgs-unstable branch is. It’s also not reproducible and changes with the cache TTL (~2 hours by default).

There are a number of ways to point nix eval (or any other nix command) at a fixed rev, or simply another branch, instead. You could use a different URL that doesn’t fall back to the registry, use --inputs-from or simply change the registry entry for nixpkgs to something more sensible.

nix-darwin is actually supposed to do this by default, just like NixOS (so you shouldn’t need what @waffle8946 suggests). My guess is that you don’t have nix.enable set, perhaps because you’re using dix and not nix or lix?

Whoops, my bad, it’s because you literally set nixpkgs to unstable. Yeah, either follow @waffle8946 's suggestion and make nixpkgs point to stable, or create a new entry for nixpkgs-stable. Your system registry isn’t linked to your flake inputs, unless you explicitly set nix-darwin up to make them match.

1 Like

It’s not that bad but it’s not ideal.

1 Like

Would you happen to have an example of declaratively generating a symlink via environment.etc available to share?

Also, interestingly enough, when I added a new package dependency and rebuilt the system, nix eval yielded my originally expected results (see below). Could you help me understand based on your previous post, quoted above, why that is? Lastly, for context, antidote is not available in /run/current-system/sw

❯ eza -alo $(nix eval --raw nixpkgs#antidote)
0555 dr-xr-xr-x - root 31 Dec 1969 share

This was the root issue. I mistakenly believed the flake inputs were registered and available in nix operations like nix eval.

Thanks @waffle8946 and @TLATER for your clarifications and suggestions. I now understand I can use --input-from like so nix eval --inputs-from . --raw 'nixpkgs-unstable#jq.version' to use flake inputs or alternatively reassign the registry value. Further, as suggested, I repointed my flake inputs as follows.

  inputs = {               
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-25.05-darwin";
    nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";
    nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-25.05";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; 
  };

It’s not complicated. To make /etc/my/antidote-link a symlink to the antidote package, you’d do:

environment.etc."my/antidote-link".source = "${pkgs.antidote}";

However this shouldn’t be necessary, as the contents of the antidote package should be available in /run/current-system/sw if you’ve added it to environment.systemPackages

I’m not sure I completely follow what you say happened. I’m going to assume you mean that nix eval give you a realized path after the rebuild? If so, it’s quite simple: the path simply happened to already be realized. nix eval returns the store path the build result would have, but does not cause it to be built and cached. If it’s already cached, though, it’s not like it deletes it.

I’m not sure what that cli paste is supposed to be demonstrating. It seems unrelated to the issue in question. If pkgs.antidote is in environment.systemPackages, then the contents of the package should be merged into the symlink structure in /run/current-system/sw.

Expand for console example

I have gzip installed, so:

$ find $(nix build pkgs\#gzip --no-link --print-out-paths) -not -type d | sed -re 's:^/nix/store/[a-z0-9]+-[^/]+/:/run/current-system/sw/:' | xargs ls -ld
ls: cannot access '/run/current-system/sw/bin/.gzip-wrapped': No such file or directory
lrwxrwxrwx 14 root root 64 Dec 31  1969 /run/current-system/sw/bin/gunzip -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/gunzip
lrwxrwxrwx 14 root root 63 Dec 31  1969 /run/current-system/sw/bin/gzexe -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/gzexe
lrwxrwxrwx 14 root root 62 Dec 31  1969 /run/current-system/sw/bin/gzip -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/gzip
lrwxrwxrwx 14 root root 68 Dec 31  1969 /run/current-system/sw/bin/uncompress -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/uncompress
lrwxrwxrwx 14 root root 62 Dec 31  1969 /run/current-system/sw/bin/zcat -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zcat
lrwxrwxrwx 14 root root 62 Dec 31  1969 /run/current-system/sw/bin/zcmp -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zcmp
lrwxrwxrwx 14 root root 63 Dec 31  1969 /run/current-system/sw/bin/zdiff -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zdiff
lrwxrwxrwx 14 root root 64 Dec 31  1969 /run/current-system/sw/bin/zegrep -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zegrep
lrwxrwxrwx 14 root root 64 Dec 31  1969 /run/current-system/sw/bin/zfgrep -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zfgrep
lrwxrwxrwx 14 root root 64 Dec 31  1969 /run/current-system/sw/bin/zforce -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zforce
lrwxrwxrwx 14 root root 63 Dec 31  1969 /run/current-system/sw/bin/zgrep -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zgrep
lrwxrwxrwx 14 root root 63 Dec 31  1969 /run/current-system/sw/bin/zless -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zless
lrwxrwxrwx 14 root root 63 Dec 31  1969 /run/current-system/sw/bin/zmore -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/zmore
lrwxrwxrwx 14 root root 62 Dec 31  1969 /run/current-system/sw/bin/znew -> /nix/store/afhkqb5a94zlwjxigsnwsfwkf38h21dk-gzip-1.14/bin/znew
lrwxrwxrwx 14 root root 84 Dec 31  1969 /run/current-system/sw/share/man/man1/gunzip.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/gunzip.1.gz
lrwxrwxrwx 14 root root 83 Dec 31  1969 /run/current-system/sw/share/man/man1/gzexe.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/gzexe.1.gz
lrwxrwxrwx 14 root root 82 Dec 31  1969 /run/current-system/sw/share/man/man1/gzip.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/gzip.1.gz
lrwxrwxrwx 14 root root 82 Dec 31  1969 /run/current-system/sw/share/man/man1/zcat.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zcat.1.gz
lrwxrwxrwx 14 root root 82 Dec 31  1969 /run/current-system/sw/share/man/man1/zcmp.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zcmp.1.gz
lrwxrwxrwx 14 root root 83 Dec 31  1969 /run/current-system/sw/share/man/man1/zdiff.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zdiff.1.gz
lrwxrwxrwx 14 root root 84 Dec 31  1969 /run/current-system/sw/share/man/man1/zforce.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zforce.1.gz
lrwxrwxrwx 14 root root 83 Dec 31  1969 /run/current-system/sw/share/man/man1/zgrep.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zgrep.1.gz
lrwxrwxrwx 14 root root 83 Dec 31  1969 /run/current-system/sw/share/man/man1/zless.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zless.1.gz
lrwxrwxrwx 14 root root 83 Dec 31  1969 /run/current-system/sw/share/man/man1/zmore.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/zmore.1.gz
lrwxrwxrwx 14 root root 82 Dec 31  1969 /run/current-system/sw/share/man/man1/znew.1.gz -> /nix/store/0i7mzq93m8p7253bxnh7ydahmjsjrabk-gzip-1.14-man/share/man/man1/znew.1.gz