Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs that explain Import From Derivation is missing some context #12670

Open
2 tasks done
itsfarseen opened this issue Mar 18, 2025 · 0 comments
Open
2 tasks done

Docs that explain Import From Derivation is missing some context #12670

itsfarseen opened this issue Mar 18, 2025 · 0 comments

Comments

@itsfarseen
Copy link

itsfarseen commented Mar 18, 2025

Problem

Here: https://nix.dev/manual/nix/2.24/language/import-from-derivation
It is mentioned that:

Passing an expression expr that evaluates to a store path,
to any built-in function which reads from the filesystem,
constitutes Import From Derivation (IFD):

import expr
 .. other builtin functions that reads from the file system ..

It also says:

When the store path needs to be accessed, evaluation will be paused,
the corresponding store object realised, and then evaluation resumed.

Counter example:

nix-repl> pkgs = import <nixpkgs> {}
nix-repl> builtins.toString pkgs.zxing-cpp                               
"/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0"

# Try to import the path
nix-repl> import "/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0"
error:
       … while calling the 'import' builtin
         at «string»:1:1:
            1| import "/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0"
             | ^

       error: path '/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0' does not exist

# Okay try to import the path passed in as path instead of string
nix-repl> import /nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0
error:
       … while calling the 'import' builtin
         at «string»:1:1:
            1| import /nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0
             | ^

       error: path '/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0' does not exist

But:

nix-repl> builtins.toString pkgs.zxing-cpp
"/nix/store/nvis47j5sxwibkwh0p94iwi4cx8rphgi-zxing-cpp-1.4.0"

nix-repl> import (builtins.toString pkgs.zxing-cpp)
.. starts downloading ..

How does this work?

Proposal

Checklist


Add 👍 to issues you find important.

@itsfarseen itsfarseen changed the title Docs that explain Import From Derivation is wrong Docs that explain Import From Derivation is missing some context Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant