I'd like to add functionality relating to the awscli command completion.

In my particular case I need to source the script from /nix/store/hvx7xqvjz7r08nsb9kssh1d9s302v3sp-awscli-1.16.106/share/zsh/site-functions/aws_zsh_completer.sh.

How can I get the store path (/nix/store/hvx7xqvjz7r08nsb9kssh1d9s302v3sp-awscli-1.16.106) for a package (awscli)? As I don't think hardcoding this reference is ideal.

3 Answers 3


You can use configuration.nix to create a symlink in /etc that points to the file you want to source. Then you simply source said symlink. For example, something like this...


environment.etc."zsh/zshrc".source = "${pkgs.awscli}/share/zsh/site-functions/aws_zsh_completer.sh";

...would create the symbolic link /etc/zsh/zshrc which would point to /nix/store/hvx7xqvjz7r08nsb9kssh1d9s302v3sp-awscli-1.16.106/share/zsh/site-functions/aws_zsh_completer.sh

Since this is done through configuration.nix, the symbolic link will get updated to the correct path each time you build the system.

Then, you can source /etc/zsh/zshrc in your ~.zshrc.


Through nix-locate , install it then update the database with nix-index:

nix-locate "PATTERN"

You could use nix eval --raw to print the store path of a package. For your example:

ls $(nix eval --raw nixpkgs.awscli)/share/zsh/site-functions/aws_zsh_completer.sh

This file will only exist if the package is already in your local nix store.

  • I'm not sure if this has changed since this answer was posted, but for me I need to use eg nix eval --raw nixpkgs#awscli - note the hash instead of a period. Mar 17 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.