What does the string / value mean in Nix?What is nix-instantiate good for ? What is a store-derivation?nix-shell with R interpretter and submodulesWhen and how should default.nix, shell.nix and release.nix be used?How to get the name from a nixpkgs derivation in a nix expression to be used by nix-shell?Aspell dictionaries missing when installed into nix-shellWhat nix channel is subscribed to by defaultpretty print of nix attrsetsnix-env and nix-shell have different versions of snapCan I replicate what nix-build does with nix-shell and cabal build?Godot Nix Expression Fails
Is it possible writing coservation of relativistic energy in this naive way?
Why do textbooks often include the solutions to odd or even numbered problems but not both?
Hot coffee brewing solutions for deep woods camping
Hand soldering SMD 1206 components
STM Microcontroller burns every time
How to make clear to people I don't want to answer their "Where are you from?" question?
What is the legal status of travelling with methadone in your carry-on?
Should I prioritize my 401(k) over my student loans?
Can humans ever directly see a few photons at a time? Can a human see a single photon?
A STL-like vector implementation in C++
Why cruise at 7000' in an A319?
Does Marvel have an equivalent of the Green Lantern?
If I wouldn't want to read the story, is writing it still a good idea?
Sci fi short story, robot city that nags people about health
Has there been any indication at all that further negotiation between the UK and EU is possible?
Is a single radon-daughter atom in air a solid?
Underbar nabla symbol doesn't work
What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?
How is hair tissue mineral analysis performed?
Fedora boot screen shows both Fedora logo and Lenovo logo. Why and How?
What was the Shuttle Carrier Aircraft escape tunnel?
Can ADFS connect to other SSO services?
Interaction between Leyline of Anticipation and Teferi, Time Raveler
Does this Wild Magic result affect the sorcerer or just other creatures?
What does the string / value mean in Nix?
What is nix-instantiate good for ? What is a store-derivation?nix-shell with R interpretter and submodulesWhen and how should default.nix, shell.nix and release.nix be used?How to get the name from a nixpkgs derivation in a nix expression to be used by nix-shell?Aspell dictionaries missing when installed into nix-shellWhat nix channel is subscribed to by defaultpretty print of nix attrsetsnix-env and nix-shell have different versions of snapCan I replicate what nix-build does with nix-shell and cabal build?Godot Nix Expression Fails
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
For example in the following (which I assume is a nix expression):
(import <nixpkgs> ).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
lens
aeson
turtle
])
What does <nixpkgs>
reference? I also see it used in other contexts for example:
nix-shell '<nixpkgs>' -A linuxPackages.kernel
nix nixos
add a comment |
For example in the following (which I assume is a nix expression):
(import <nixpkgs> ).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
lens
aeson
turtle
])
What does <nixpkgs>
reference? I also see it used in other contexts for example:
nix-shell '<nixpkgs>' -A linuxPackages.kernel
nix nixos
add a comment |
For example in the following (which I assume is a nix expression):
(import <nixpkgs> ).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
lens
aeson
turtle
])
What does <nixpkgs>
reference? I also see it used in other contexts for example:
nix-shell '<nixpkgs>' -A linuxPackages.kernel
nix nixos
For example in the following (which I assume is a nix expression):
(import <nixpkgs> ).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
lens
aeson
turtle
])
What does <nixpkgs>
reference? I also see it used in other contexts for example:
nix-shell '<nixpkgs>' -A linuxPackages.kernel
nix nixos
nix nixos
asked Nov 19 '17 at 17:15
Chris StryczynskiChris Stryczynski
5,3326 gold badges40 silver badges95 bronze badges
5,3326 gold badges40 silver badges95 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
<nixpkgs>
is a Nix expression that is evaluated by looking at the Nix search path in the NIX_PATH
environment variable and/or -I
option.
It is described in more detail in the Nix manual.
Note that the Nix search path is impractical in many situations. You can only pass it from the outside, and it easily creates impurity. In my experience, problems are better solved with explicit argument passing or the functions relating to fix-points like callPackage
and the overlay system.
As an example, NixOS has only one extra search path parameter, and it is only read once in nixos/default.nix
if no explicit configuration is given. This way, you have the flexibility to provide your own configuration, which is why you (nix-build
) and hydra can confidently build the NixOS VM tests, bootable images, docker images, etc.
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined byNIX_PATH
(and optionally-I
). Tryecho $NIX_PATH
in your shell to see how yours is configured. For me<nixpkgs>
resolves to/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.
– Robert Hensing
Nov 20 '17 at 21:13
add a comment |
One can evaluate the value using nix repl
:
nix repl
Welcome to Nix version 2.1.3. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
add a comment |
From the Nix manual, 15.1. Values, section "Simple Values":
Paths can also be specified between angle brackets, e.g. .
This means that the directories listed in the environment variable
NIX_PATH
will be searched for the given file or directory name.
From the NixOS manual, Chapter 18. Common Environment Variables, section NIX_PATH
:
A colon-separated list of directories used to look up Nix expressions
enclosed in angle brackets (i.e., ). For instance, the value/home/eelco/Dev:/etc/nixos
will cause Nix to look for paths relative to
/home/eelco/Dev
and
/etc/nixos
, in that order. It is also possible to match paths
against a prefix. For example, the valuenixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
will cause Nix to search for
<nixpkgs/
path>
in
/home/eelco/Dev/nixpkgs-branch/path
and/etc/nixos/nixpkgs/path
.
If a path in the Nix search path starts with
http://
orhttps://
,
it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball must consist of a single
top-level directory. For example, settingNIX_PATH
tonixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
channel.
A following shorthand can be used to refer to the official channels:
nixpkgs=channel:nixos-15.09
The search path can be extended using the -I option, which takes
precedence overNIX_PATH
.
Examples
1. with import <nixpkgs> ; /* rest of the expression */
In my case, <nixpkgs>
is /nix/var/nix/profiles/per-user/root/channels/nixos
:
$ echo $NIX_PATH
# VVVVVVV
/home/a_user/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# ^^^^^^^
Because <nixpkgs>
evaluates to "a directory, the file default.nix
in that directory is loaded" by import
. (Nix manual, 15.4.1. Advanced Attributes, section import path, builtins.import path)
$ ll /nix/var/nix/profiles/per-user/root/channels/nixos
lrwxrwxrwx 1 root root 80 Dec 31 1969 /nix/var/nix/profiles/per-user/root/channels/nixos -> /nix/store/ywlfq2ns4
a3fzb2ap74lvahmrg1p0lmk-nixos-19.03.172231.7b36963e7a7/nixos/
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos)
total 3308
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ../
# (...)
dr-xr-xr-x 7 root root 4096 Dec 31 1969 nixos/
dr-xr-xr-x 17 root root 4096 Dec 31 1969 pkgs/
-r--r--r-- 1 root root 1097 Dec 31 1969 COPYING
-r--r--r-- 1 root root 968 Dec 31 ---> default.nix <---
# (...)
If my understanding is correct, after the import
the provided Nix expression is evaluated with an empty attribute set (). The result is an attribute list, and the
with
expression will include all its containing attributes in the local lexical scope.
2. nix repl '<nixpkgs/nixos>'
Example taken from the NixOS manual, 5.3. Modularity, showing the active NixOS configuration settings in the repl.
Because of the <nixpkgs/
path>
convention, where path equals nixos
, the angle expression will evaluate to /nix/var/nix/profiles/per-user/root/channels/nixos/nixos
. The above ll
output also shows a nixos
folder above default.nix
, and inside there is indeed another default.nix
that will get evaluated by nix repl
:
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos/nixos)
total 72
dr-xr-xr-x 7 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ../
-r--r--r-- 1 root root 886 Dec 31 ---> default.nix <---
-r--r--r-- 1 root root 197 Dec 31 1969 README
-r--r--r-- 1 root root 6074 Dec 31 1969 release-combined.nix
-r--r--r-- 1 root root 9251 Dec 31 1969 release.nix
-r--r--r-- 1 root root 2038 Dec 31 1969 release-small.nix
Miscellaneous
Issue #338 is still open to improve the Nix manual, documenting the angle syntax in their own section.
Nix Pills sections (e.g., 15.5. Conclusion and Chapter 16. Nixpkgs Parameters) consistently call the angle syntax "angular brackets" syntax.
In his answer, Robert Hensing warns against using<nixpkgs>
everywhere, and an issue #1161 is still open on just that topic. (Excerpt: "We have an unofficial guideline that nobody should use angle brackets in nixpkgs, but why not make it into a hard requirement?")
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47379654%2fwhat-does-the-nixpkgs-string-value-mean-in-nix%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
<nixpkgs>
is a Nix expression that is evaluated by looking at the Nix search path in the NIX_PATH
environment variable and/or -I
option.
It is described in more detail in the Nix manual.
Note that the Nix search path is impractical in many situations. You can only pass it from the outside, and it easily creates impurity. In my experience, problems are better solved with explicit argument passing or the functions relating to fix-points like callPackage
and the overlay system.
As an example, NixOS has only one extra search path parameter, and it is only read once in nixos/default.nix
if no explicit configuration is given. This way, you have the flexibility to provide your own configuration, which is why you (nix-build
) and hydra can confidently build the NixOS VM tests, bootable images, docker images, etc.
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined byNIX_PATH
(and optionally-I
). Tryecho $NIX_PATH
in your shell to see how yours is configured. For me<nixpkgs>
resolves to/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.
– Robert Hensing
Nov 20 '17 at 21:13
add a comment |
<nixpkgs>
is a Nix expression that is evaluated by looking at the Nix search path in the NIX_PATH
environment variable and/or -I
option.
It is described in more detail in the Nix manual.
Note that the Nix search path is impractical in many situations. You can only pass it from the outside, and it easily creates impurity. In my experience, problems are better solved with explicit argument passing or the functions relating to fix-points like callPackage
and the overlay system.
As an example, NixOS has only one extra search path parameter, and it is only read once in nixos/default.nix
if no explicit configuration is given. This way, you have the flexibility to provide your own configuration, which is why you (nix-build
) and hydra can confidently build the NixOS VM tests, bootable images, docker images, etc.
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined byNIX_PATH
(and optionally-I
). Tryecho $NIX_PATH
in your shell to see how yours is configured. For me<nixpkgs>
resolves to/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.
– Robert Hensing
Nov 20 '17 at 21:13
add a comment |
<nixpkgs>
is a Nix expression that is evaluated by looking at the Nix search path in the NIX_PATH
environment variable and/or -I
option.
It is described in more detail in the Nix manual.
Note that the Nix search path is impractical in many situations. You can only pass it from the outside, and it easily creates impurity. In my experience, problems are better solved with explicit argument passing or the functions relating to fix-points like callPackage
and the overlay system.
As an example, NixOS has only one extra search path parameter, and it is only read once in nixos/default.nix
if no explicit configuration is given. This way, you have the flexibility to provide your own configuration, which is why you (nix-build
) and hydra can confidently build the NixOS VM tests, bootable images, docker images, etc.
<nixpkgs>
is a Nix expression that is evaluated by looking at the Nix search path in the NIX_PATH
environment variable and/or -I
option.
It is described in more detail in the Nix manual.
Note that the Nix search path is impractical in many situations. You can only pass it from the outside, and it easily creates impurity. In my experience, problems are better solved with explicit argument passing or the functions relating to fix-points like callPackage
and the overlay system.
As an example, NixOS has only one extra search path parameter, and it is only read once in nixos/default.nix
if no explicit configuration is given. This way, you have the flexibility to provide your own configuration, which is why you (nix-build
) and hydra can confidently build the NixOS VM tests, bootable images, docker images, etc.
answered Nov 20 '17 at 9:22
Robert HensingRobert Hensing
2,33910 silver badges13 bronze badges
2,33910 silver badges13 bronze badges
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined byNIX_PATH
(and optionally-I
). Tryecho $NIX_PATH
in your shell to see how yours is configured. For me<nixpkgs>
resolves to/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.
– Robert Hensing
Nov 20 '17 at 21:13
add a comment |
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined byNIX_PATH
(and optionally-I
). Tryecho $NIX_PATH
in your shell to see how yours is configured. For me<nixpkgs>
resolves to/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.
– Robert Hensing
Nov 20 '17 at 21:13
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
What does it evaluate to? A collection of packages? Would this be the official nixpkgs repository, or the system 'nix' configuration or something else?
– Chris Stryczynski
Nov 20 '17 at 10:19
It resolves to a path. The value is determined by
NIX_PATH
(and optionally -I
). Try echo $NIX_PATH
in your shell to see how yours is configured. For me <nixpkgs>
resolves to /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.– Robert Hensing
Nov 20 '17 at 21:13
It resolves to a path. The value is determined by
NIX_PATH
(and optionally -I
). Try echo $NIX_PATH
in your shell to see how yours is configured. For me <nixpkgs>
resolves to /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
. I'm on NixOS, so that's the system nixpkgs.– Robert Hensing
Nov 20 '17 at 21:13
add a comment |
One can evaluate the value using nix repl
:
nix repl
Welcome to Nix version 2.1.3. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
add a comment |
One can evaluate the value using nix repl
:
nix repl
Welcome to Nix version 2.1.3. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
add a comment |
One can evaluate the value using nix repl
:
nix repl
Welcome to Nix version 2.1.3. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
One can evaluate the value using nix repl
:
nix repl
Welcome to Nix version 2.1.3. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
answered Mar 25 at 9:42
Chris StryczynskiChris Stryczynski
5,3326 gold badges40 silver badges95 bronze badges
5,3326 gold badges40 silver badges95 bronze badges
add a comment |
add a comment |
From the Nix manual, 15.1. Values, section "Simple Values":
Paths can also be specified between angle brackets, e.g. .
This means that the directories listed in the environment variable
NIX_PATH
will be searched for the given file or directory name.
From the NixOS manual, Chapter 18. Common Environment Variables, section NIX_PATH
:
A colon-separated list of directories used to look up Nix expressions
enclosed in angle brackets (i.e., ). For instance, the value/home/eelco/Dev:/etc/nixos
will cause Nix to look for paths relative to
/home/eelco/Dev
and
/etc/nixos
, in that order. It is also possible to match paths
against a prefix. For example, the valuenixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
will cause Nix to search for
<nixpkgs/
path>
in
/home/eelco/Dev/nixpkgs-branch/path
and/etc/nixos/nixpkgs/path
.
If a path in the Nix search path starts with
http://
orhttps://
,
it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball must consist of a single
top-level directory. For example, settingNIX_PATH
tonixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
channel.
A following shorthand can be used to refer to the official channels:
nixpkgs=channel:nixos-15.09
The search path can be extended using the -I option, which takes
precedence overNIX_PATH
.
Examples
1. with import <nixpkgs> ; /* rest of the expression */
In my case, <nixpkgs>
is /nix/var/nix/profiles/per-user/root/channels/nixos
:
$ echo $NIX_PATH
# VVVVVVV
/home/a_user/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# ^^^^^^^
Because <nixpkgs>
evaluates to "a directory, the file default.nix
in that directory is loaded" by import
. (Nix manual, 15.4.1. Advanced Attributes, section import path, builtins.import path)
$ ll /nix/var/nix/profiles/per-user/root/channels/nixos
lrwxrwxrwx 1 root root 80 Dec 31 1969 /nix/var/nix/profiles/per-user/root/channels/nixos -> /nix/store/ywlfq2ns4
a3fzb2ap74lvahmrg1p0lmk-nixos-19.03.172231.7b36963e7a7/nixos/
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos)
total 3308
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ../
# (...)
dr-xr-xr-x 7 root root 4096 Dec 31 1969 nixos/
dr-xr-xr-x 17 root root 4096 Dec 31 1969 pkgs/
-r--r--r-- 1 root root 1097 Dec 31 1969 COPYING
-r--r--r-- 1 root root 968 Dec 31 ---> default.nix <---
# (...)
If my understanding is correct, after the import
the provided Nix expression is evaluated with an empty attribute set (). The result is an attribute list, and the
with
expression will include all its containing attributes in the local lexical scope.
2. nix repl '<nixpkgs/nixos>'
Example taken from the NixOS manual, 5.3. Modularity, showing the active NixOS configuration settings in the repl.
Because of the <nixpkgs/
path>
convention, where path equals nixos
, the angle expression will evaluate to /nix/var/nix/profiles/per-user/root/channels/nixos/nixos
. The above ll
output also shows a nixos
folder above default.nix
, and inside there is indeed another default.nix
that will get evaluated by nix repl
:
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos/nixos)
total 72
dr-xr-xr-x 7 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ../
-r--r--r-- 1 root root 886 Dec 31 ---> default.nix <---
-r--r--r-- 1 root root 197 Dec 31 1969 README
-r--r--r-- 1 root root 6074 Dec 31 1969 release-combined.nix
-r--r--r-- 1 root root 9251 Dec 31 1969 release.nix
-r--r--r-- 1 root root 2038 Dec 31 1969 release-small.nix
Miscellaneous
Issue #338 is still open to improve the Nix manual, documenting the angle syntax in their own section.
Nix Pills sections (e.g., 15.5. Conclusion and Chapter 16. Nixpkgs Parameters) consistently call the angle syntax "angular brackets" syntax.
In his answer, Robert Hensing warns against using<nixpkgs>
everywhere, and an issue #1161 is still open on just that topic. (Excerpt: "We have an unofficial guideline that nobody should use angle brackets in nixpkgs, but why not make it into a hard requirement?")
add a comment |
From the Nix manual, 15.1. Values, section "Simple Values":
Paths can also be specified between angle brackets, e.g. .
This means that the directories listed in the environment variable
NIX_PATH
will be searched for the given file or directory name.
From the NixOS manual, Chapter 18. Common Environment Variables, section NIX_PATH
:
A colon-separated list of directories used to look up Nix expressions
enclosed in angle brackets (i.e., ). For instance, the value/home/eelco/Dev:/etc/nixos
will cause Nix to look for paths relative to
/home/eelco/Dev
and
/etc/nixos
, in that order. It is also possible to match paths
against a prefix. For example, the valuenixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
will cause Nix to search for
<nixpkgs/
path>
in
/home/eelco/Dev/nixpkgs-branch/path
and/etc/nixos/nixpkgs/path
.
If a path in the Nix search path starts with
http://
orhttps://
,
it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball must consist of a single
top-level directory. For example, settingNIX_PATH
tonixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
channel.
A following shorthand can be used to refer to the official channels:
nixpkgs=channel:nixos-15.09
The search path can be extended using the -I option, which takes
precedence overNIX_PATH
.
Examples
1. with import <nixpkgs> ; /* rest of the expression */
In my case, <nixpkgs>
is /nix/var/nix/profiles/per-user/root/channels/nixos
:
$ echo $NIX_PATH
# VVVVVVV
/home/a_user/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# ^^^^^^^
Because <nixpkgs>
evaluates to "a directory, the file default.nix
in that directory is loaded" by import
. (Nix manual, 15.4.1. Advanced Attributes, section import path, builtins.import path)
$ ll /nix/var/nix/profiles/per-user/root/channels/nixos
lrwxrwxrwx 1 root root 80 Dec 31 1969 /nix/var/nix/profiles/per-user/root/channels/nixos -> /nix/store/ywlfq2ns4
a3fzb2ap74lvahmrg1p0lmk-nixos-19.03.172231.7b36963e7a7/nixos/
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos)
total 3308
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ../
# (...)
dr-xr-xr-x 7 root root 4096 Dec 31 1969 nixos/
dr-xr-xr-x 17 root root 4096 Dec 31 1969 pkgs/
-r--r--r-- 1 root root 1097 Dec 31 1969 COPYING
-r--r--r-- 1 root root 968 Dec 31 ---> default.nix <---
# (...)
If my understanding is correct, after the import
the provided Nix expression is evaluated with an empty attribute set (). The result is an attribute list, and the
with
expression will include all its containing attributes in the local lexical scope.
2. nix repl '<nixpkgs/nixos>'
Example taken from the NixOS manual, 5.3. Modularity, showing the active NixOS configuration settings in the repl.
Because of the <nixpkgs/
path>
convention, where path equals nixos
, the angle expression will evaluate to /nix/var/nix/profiles/per-user/root/channels/nixos/nixos
. The above ll
output also shows a nixos
folder above default.nix
, and inside there is indeed another default.nix
that will get evaluated by nix repl
:
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos/nixos)
total 72
dr-xr-xr-x 7 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ../
-r--r--r-- 1 root root 886 Dec 31 ---> default.nix <---
-r--r--r-- 1 root root 197 Dec 31 1969 README
-r--r--r-- 1 root root 6074 Dec 31 1969 release-combined.nix
-r--r--r-- 1 root root 9251 Dec 31 1969 release.nix
-r--r--r-- 1 root root 2038 Dec 31 1969 release-small.nix
Miscellaneous
Issue #338 is still open to improve the Nix manual, documenting the angle syntax in their own section.
Nix Pills sections (e.g., 15.5. Conclusion and Chapter 16. Nixpkgs Parameters) consistently call the angle syntax "angular brackets" syntax.
In his answer, Robert Hensing warns against using<nixpkgs>
everywhere, and an issue #1161 is still open on just that topic. (Excerpt: "We have an unofficial guideline that nobody should use angle brackets in nixpkgs, but why not make it into a hard requirement?")
add a comment |
From the Nix manual, 15.1. Values, section "Simple Values":
Paths can also be specified between angle brackets, e.g. .
This means that the directories listed in the environment variable
NIX_PATH
will be searched for the given file or directory name.
From the NixOS manual, Chapter 18. Common Environment Variables, section NIX_PATH
:
A colon-separated list of directories used to look up Nix expressions
enclosed in angle brackets (i.e., ). For instance, the value/home/eelco/Dev:/etc/nixos
will cause Nix to look for paths relative to
/home/eelco/Dev
and
/etc/nixos
, in that order. It is also possible to match paths
against a prefix. For example, the valuenixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
will cause Nix to search for
<nixpkgs/
path>
in
/home/eelco/Dev/nixpkgs-branch/path
and/etc/nixos/nixpkgs/path
.
If a path in the Nix search path starts with
http://
orhttps://
,
it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball must consist of a single
top-level directory. For example, settingNIX_PATH
tonixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
channel.
A following shorthand can be used to refer to the official channels:
nixpkgs=channel:nixos-15.09
The search path can be extended using the -I option, which takes
precedence overNIX_PATH
.
Examples
1. with import <nixpkgs> ; /* rest of the expression */
In my case, <nixpkgs>
is /nix/var/nix/profiles/per-user/root/channels/nixos
:
$ echo $NIX_PATH
# VVVVVVV
/home/a_user/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# ^^^^^^^
Because <nixpkgs>
evaluates to "a directory, the file default.nix
in that directory is loaded" by import
. (Nix manual, 15.4.1. Advanced Attributes, section import path, builtins.import path)
$ ll /nix/var/nix/profiles/per-user/root/channels/nixos
lrwxrwxrwx 1 root root 80 Dec 31 1969 /nix/var/nix/profiles/per-user/root/channels/nixos -> /nix/store/ywlfq2ns4
a3fzb2ap74lvahmrg1p0lmk-nixos-19.03.172231.7b36963e7a7/nixos/
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos)
total 3308
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ../
# (...)
dr-xr-xr-x 7 root root 4096 Dec 31 1969 nixos/
dr-xr-xr-x 17 root root 4096 Dec 31 1969 pkgs/
-r--r--r-- 1 root root 1097 Dec 31 1969 COPYING
-r--r--r-- 1 root root 968 Dec 31 ---> default.nix <---
# (...)
If my understanding is correct, after the import
the provided Nix expression is evaluated with an empty attribute set (). The result is an attribute list, and the
with
expression will include all its containing attributes in the local lexical scope.
2. nix repl '<nixpkgs/nixos>'
Example taken from the NixOS manual, 5.3. Modularity, showing the active NixOS configuration settings in the repl.
Because of the <nixpkgs/
path>
convention, where path equals nixos
, the angle expression will evaluate to /nix/var/nix/profiles/per-user/root/channels/nixos/nixos
. The above ll
output also shows a nixos
folder above default.nix
, and inside there is indeed another default.nix
that will get evaluated by nix repl
:
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos/nixos)
total 72
dr-xr-xr-x 7 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ../
-r--r--r-- 1 root root 886 Dec 31 ---> default.nix <---
-r--r--r-- 1 root root 197 Dec 31 1969 README
-r--r--r-- 1 root root 6074 Dec 31 1969 release-combined.nix
-r--r--r-- 1 root root 9251 Dec 31 1969 release.nix
-r--r--r-- 1 root root 2038 Dec 31 1969 release-small.nix
Miscellaneous
Issue #338 is still open to improve the Nix manual, documenting the angle syntax in their own section.
Nix Pills sections (e.g., 15.5. Conclusion and Chapter 16. Nixpkgs Parameters) consistently call the angle syntax "angular brackets" syntax.
In his answer, Robert Hensing warns against using<nixpkgs>
everywhere, and an issue #1161 is still open on just that topic. (Excerpt: "We have an unofficial guideline that nobody should use angle brackets in nixpkgs, but why not make it into a hard requirement?")
From the Nix manual, 15.1. Values, section "Simple Values":
Paths can also be specified between angle brackets, e.g. .
This means that the directories listed in the environment variable
NIX_PATH
will be searched for the given file or directory name.
From the NixOS manual, Chapter 18. Common Environment Variables, section NIX_PATH
:
A colon-separated list of directories used to look up Nix expressions
enclosed in angle brackets (i.e., ). For instance, the value/home/eelco/Dev:/etc/nixos
will cause Nix to look for paths relative to
/home/eelco/Dev
and
/etc/nixos
, in that order. It is also possible to match paths
against a prefix. For example, the valuenixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
will cause Nix to search for
<nixpkgs/
path>
in
/home/eelco/Dev/nixpkgs-branch/path
and/etc/nixos/nixpkgs/path
.
If a path in the Nix search path starts with
http://
orhttps://
,
it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball must consist of a single
top-level directory. For example, settingNIX_PATH
tonixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-15.09.tar.gz
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
channel.
A following shorthand can be used to refer to the official channels:
nixpkgs=channel:nixos-15.09
The search path can be extended using the -I option, which takes
precedence overNIX_PATH
.
Examples
1. with import <nixpkgs> ; /* rest of the expression */
In my case, <nixpkgs>
is /nix/var/nix/profiles/per-user/root/channels/nixos
:
$ echo $NIX_PATH
# VVVVVVV
/home/a_user/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# ^^^^^^^
Because <nixpkgs>
evaluates to "a directory, the file default.nix
in that directory is loaded" by import
. (Nix manual, 15.4.1. Advanced Attributes, section import path, builtins.import path)
$ ll /nix/var/nix/profiles/per-user/root/channels/nixos
lrwxrwxrwx 1 root root 80 Dec 31 1969 /nix/var/nix/profiles/per-user/root/channels/nixos -> /nix/store/ywlfq2ns4
a3fzb2ap74lvahmrg1p0lmk-nixos-19.03.172231.7b36963e7a7/nixos/
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos)
total 3308
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 4 root root 4096 Dec 31 1969 ../
# (...)
dr-xr-xr-x 7 root root 4096 Dec 31 1969 nixos/
dr-xr-xr-x 17 root root 4096 Dec 31 1969 pkgs/
-r--r--r-- 1 root root 1097 Dec 31 1969 COPYING
-r--r--r-- 1 root root 968 Dec 31 ---> default.nix <---
# (...)
If my understanding is correct, after the import
the provided Nix expression is evaluated with an empty attribute set (). The result is an attribute list, and the
with
expression will include all its containing attributes in the local lexical scope.
2. nix repl '<nixpkgs/nixos>'
Example taken from the NixOS manual, 5.3. Modularity, showing the active NixOS configuration settings in the repl.
Because of the <nixpkgs/
path>
convention, where path equals nixos
, the angle expression will evaluate to /nix/var/nix/profiles/per-user/root/channels/nixos/nixos
. The above ll
output also shows a nixos
folder above default.nix
, and inside there is indeed another default.nix
that will get evaluated by nix repl
:
$ ll $(readlink -f /nix/var/nix/profiles/per-user/root/channels/nixos/nixos)
total 72
dr-xr-xr-x 7 root root 4096 Dec 31 1969 ./
dr-xr-xr-x 8 root root 4096 Dec 31 1969 ../
-r--r--r-- 1 root root 886 Dec 31 ---> default.nix <---
-r--r--r-- 1 root root 197 Dec 31 1969 README
-r--r--r-- 1 root root 6074 Dec 31 1969 release-combined.nix
-r--r--r-- 1 root root 9251 Dec 31 1969 release.nix
-r--r--r-- 1 root root 2038 Dec 31 1969 release-small.nix
Miscellaneous
Issue #338 is still open to improve the Nix manual, documenting the angle syntax in their own section.
Nix Pills sections (e.g., 15.5. Conclusion and Chapter 16. Nixpkgs Parameters) consistently call the angle syntax "angular brackets" syntax.
In his answer, Robert Hensing warns against using<nixpkgs>
everywhere, and an issue #1161 is still open on just that topic. (Excerpt: "We have an unofficial guideline that nobody should use angle brackets in nixpkgs, but why not make it into a hard requirement?")
edited May 15 at 0:49
answered May 14 at 19:12
torarittetoraritte
1,4701 gold badge15 silver badges27 bronze badges
1,4701 gold badge15 silver badges27 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47379654%2fwhat-does-the-nixpkgs-string-value-mean-in-nix%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown