Compare commits
30 Commits
dead-code-
...
2.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61e816217b | ||
|
|
21f48ff26a | ||
|
|
e3d44a3b83 | ||
|
|
0fb4744467 | ||
|
|
f66108f738 | ||
|
|
2070d55b0b | ||
|
|
fe51fbaf81 | ||
|
|
7c4589854b | ||
|
|
1c10f739eb | ||
|
|
2522757e83 | ||
|
|
923b6bd83c | ||
|
|
65953789bc | ||
|
|
910b0fcc11 | ||
|
|
e232bf2b69 | ||
|
|
7c9ad4d0d7 | ||
|
|
fa028194e9 | ||
|
|
ff7fcd3805 | ||
|
|
ceddbc921f | ||
|
|
62d1c60fb3 | ||
|
|
f4106e76ff | ||
|
|
f3ce4453a6 | ||
|
|
9f53bc33e7 | ||
|
|
4d83eb6206 | ||
|
|
3919093e9a | ||
|
|
b0ae8fe2db | ||
|
|
3c5788d094 | ||
|
|
9f698c4530 | ||
|
|
1b78bbb414 | ||
|
|
1d5cb6ad48 | ||
|
|
22d4ea7a98 |
@@ -433,7 +433,7 @@ builtins.fetchurl {
|
|||||||
<varlistentry xml:id="conf-keep-env-derivations"><term><literal>keep-env-derivations</literal></term>
|
<varlistentry xml:id="conf-keep-env-derivations"><term><literal>keep-env-derivations</literal></term>
|
||||||
|
|
||||||
<listitem><para>If <literal>false</literal> (default), derivations
|
<listitem><para>If <literal>false</literal> (default), derivations
|
||||||
are not stored in Nix user environments. That is, the derivation
|
are not stored in Nix user environments. That is, the derivations of
|
||||||
any build-time-only dependencies may be garbage-collected.</para>
|
any build-time-only dependencies may be garbage-collected.</para>
|
||||||
|
|
||||||
<para>If <literal>true</literal>, when you add a Nix derivation to
|
<para>If <literal>true</literal>, when you add a Nix derivation to
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ upgrading `mozilla-1.2' to `mozilla-1.4'</screen>
|
|||||||
<literal>gcc-3.3.1</literal> are split into two parts: the package
|
<literal>gcc-3.3.1</literal> are split into two parts: the package
|
||||||
name (<literal>gcc</literal>), and the version
|
name (<literal>gcc</literal>), and the version
|
||||||
(<literal>3.3.1</literal>). The version part starts after the first
|
(<literal>3.3.1</literal>). The version part starts after the first
|
||||||
dash not following by a letter. <varname>x</varname> is considered an
|
dash not followed by a letter. <varname>x</varname> is considered an
|
||||||
upgrade of <varname>y</varname> if their package names match, and the
|
upgrade of <varname>y</varname> if their package names match, and the
|
||||||
version of <varname>y</varname> is higher that that of
|
version of <varname>y</varname> is higher that that of
|
||||||
<varname>x</varname>.</para>
|
<varname>x</varname>.</para>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ avoided.</para>
|
|||||||
<para>If <replaceable>hash</replaceable> is specified, then a download
|
<para>If <replaceable>hash</replaceable> is specified, then a download
|
||||||
is not performed if the Nix store already contains a file with the
|
is not performed if the Nix store already contains a file with the
|
||||||
same hash and base name. Otherwise, the file is downloaded, and an
|
same hash and base name. Otherwise, the file is downloaded, and an
|
||||||
error if signaled if the actual hash of the file does not match the
|
error is signaled if the actual hash of the file does not match the
|
||||||
specified hash.</para>
|
specified hash.</para>
|
||||||
|
|
||||||
<para>This command prints the hash on standard output. Additionally,
|
<para>This command prints the hash on standard output. Additionally,
|
||||||
|
|||||||
@@ -170,18 +170,6 @@ if builtins ? getEnv then builtins.getEnv "PATH" else ""</programlisting>
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry xml:id='builtin-splitVersion'>
|
|
||||||
<term><function>builtins.splitVersion</function>
|
|
||||||
<replaceable>s</replaceable></term>
|
|
||||||
|
|
||||||
<listitem><para>Split a string representing a version into its
|
|
||||||
components, by the same version splitting logic underlying the
|
|
||||||
version comparison in <link linkend="ssec-version-comparisons">
|
|
||||||
<command>nix-env -u</command></link>.</para></listitem>
|
|
||||||
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry xml:id='builtin-concatLists'>
|
<varlistentry xml:id='builtin-concatLists'>
|
||||||
<term><function>builtins.concatLists</function>
|
<term><function>builtins.concatLists</function>
|
||||||
<replaceable>lists</replaceable></term>
|
<replaceable>lists</replaceable></term>
|
||||||
@@ -301,7 +289,7 @@ if builtins ? getEnv then builtins.getEnv "PATH" else ""</programlisting>
|
|||||||
|
|
||||||
<listitem><para>Return element <replaceable>n</replaceable> from
|
<listitem><para>Return element <replaceable>n</replaceable> from
|
||||||
the list <replaceable>xs</replaceable>. Elements are counted
|
the list <replaceable>xs</replaceable>. Elements are counted
|
||||||
starting from 0. A fatal error occurs in the index is out of
|
starting from 0. A fatal error occurs if the index is out of
|
||||||
bounds.</para></listitem>
|
bounds.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@@ -448,7 +436,7 @@ stdenv.mkDerivation { … }
|
|||||||
<example>
|
<example>
|
||||||
<title>Fetching an arbitrary ref</title>
|
<title>Fetching an arbitrary ref</title>
|
||||||
<programlisting>builtins.fetchGit {
|
<programlisting>builtins.fetchGit {
|
||||||
url = "https://gitub.com/NixOS/nix.git";
|
url = "https://github.com/NixOS/nix.git";
|
||||||
ref = "refs/heads/0.5-release";
|
ref = "refs/heads/0.5-release";
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -499,11 +487,8 @@ stdenv.mkDerivation { … }
|
|||||||
<title>Fetching a tag</title>
|
<title>Fetching a tag</title>
|
||||||
<programlisting>builtins.fetchGit {
|
<programlisting>builtins.fetchGit {
|
||||||
url = "https://github.com/nixos/nix.git";
|
url = "https://github.com/nixos/nix.git";
|
||||||
ref = "tags/1.9";
|
ref = "refs/tags/1.9";
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
<note><para>Due to a bug (<link
|
|
||||||
xlink:href="https://github.com/NixOS/nix/issues/2385">#2385</link>),
|
|
||||||
only non-annotated tags can be fetched.</para></note>
|
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
@@ -1275,6 +1260,19 @@ Evaluates to <literal>[ " " [ "FOO" ] " " ]</literal>.
|
|||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
<varlistentry xml:id='builtin-splitVersion'>
|
||||||
|
<term><function>builtins.splitVersion</function>
|
||||||
|
<replaceable>s</replaceable></term>
|
||||||
|
|
||||||
|
<listitem><para>Split a string representing a version into its
|
||||||
|
components, by the same version splitting logic underlying the
|
||||||
|
version comparison in <link linkend="ssec-version-comparisons">
|
||||||
|
<command>nix-env -u</command></link>.</para></listitem>
|
||||||
|
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry xml:id='builtin-stringLength'>
|
<varlistentry xml:id='builtin-stringLength'>
|
||||||
<term><function>builtins.stringLength</function>
|
<term><function>builtins.stringLength</function>
|
||||||
<replaceable>e</replaceable></term>
|
<replaceable>e</replaceable></term>
|
||||||
@@ -1468,7 +1466,7 @@ in foo</programlisting>
|
|||||||
<listitem><para>A set containing <literal>{ __toString = self: ...; }</literal>.</para></listitem>
|
<listitem><para>A set containing <literal>{ __toString = self: ...; }</literal>.</para></listitem>
|
||||||
<listitem><para>An integer.</para></listitem>
|
<listitem><para>An integer.</para></listitem>
|
||||||
<listitem><para>A list, in which case the string representations of its elements are joined with spaces.</para></listitem>
|
<listitem><para>A list, in which case the string representations of its elements are joined with spaces.</para></listitem>
|
||||||
<listitem><para>A Boolean (<literal>false</literal> yields <literal>""</literal>, <literal>true</literal> yields <literal>"1"</literal>.</para></listitem>
|
<listitem><para>A Boolean (<literal>false</literal> yields <literal>""</literal>, <literal>true</literal> yields <literal>"1"</literal>).</para></listitem>
|
||||||
<listitem><para><literal>null</literal>, which yields the empty string.</para></listitem>
|
<listitem><para><literal>null</literal>, which yields the empty string.</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -1607,12 +1605,18 @@ stdenv.mkDerivation (rec {
|
|||||||
<term><function>builtins.tryEval</function>
|
<term><function>builtins.tryEval</function>
|
||||||
<replaceable>e</replaceable></term>
|
<replaceable>e</replaceable></term>
|
||||||
|
|
||||||
<listitem><para>Try to evaluate <replaceable>e</replaceable>.
|
<listitem><para>Try to shallowly evaluate <replaceable>e</replaceable>.
|
||||||
Return a set containing the attributes <literal>success</literal>
|
Return a set containing the attributes <literal>success</literal>
|
||||||
(<literal>true</literal> if <replaceable>e</replaceable> evaluated
|
(<literal>true</literal> if <replaceable>e</replaceable> evaluated
|
||||||
successfully, <literal>false</literal> if an error was thrown) and
|
successfully, <literal>false</literal> if an error was thrown) and
|
||||||
<literal>value</literal>, equalling <replaceable>e</replaceable>
|
<literal>value</literal>, equalling <replaceable>e</replaceable>
|
||||||
if successful and <literal>false</literal> otherwise.
|
if successful and <literal>false</literal> otherwise. Note that this
|
||||||
|
doesn't evaluate <replaceable>e</replaceable> deeply, so
|
||||||
|
<literal>let e = { x = throw ""; }; in (builtins.tryEval e).success
|
||||||
|
</literal> will be <literal>true</literal>. Using <literal>builtins.deepSeq
|
||||||
|
</literal> one can get the expected result: <literal>let e = { x = throw "";
|
||||||
|
}; in (builtins.tryEval (builtins.deepSeq e e)).success</literal> will be
|
||||||
|
<literal>false</literal>.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ use <command>nix-build</command>’s <option
|
|||||||
linkend='opt-out-link'>-o</option> switch to give the symlink another
|
linkend='opt-out-link'>-o</option> switch to give the symlink another
|
||||||
name.</para>
|
name.</para>
|
||||||
|
|
||||||
<para>Nix has a transactional semantics. Once a build finishes
|
<para>Nix has transactional semantics. Once a build finishes
|
||||||
successfully, Nix makes a note of this in its database: it registers
|
successfully, Nix makes a note of this in its database: it registers
|
||||||
that the path denoted by <envar>out</envar> is now
|
that the path denoted by <envar>out</envar> is now
|
||||||
<quote>valid</quote>. If you try to build the derivation again, Nix
|
<quote>valid</quote>. If you try to build the derivation again, Nix
|
||||||
|
|||||||
@@ -52,12 +52,13 @@ garbage collector as follows:
|
|||||||
<screen>
|
<screen>
|
||||||
$ nix-store --gc</screen>
|
$ nix-store --gc</screen>
|
||||||
|
|
||||||
The behaviour of the gargage collector is affected by the <literal>keep-
|
The behaviour of the gargage collector is affected by the
|
||||||
derivations</literal> (default: true) and <literal>keep-outputs</literal>
|
<literal>keep-derivations</literal> (default: true) and <literal>keep-outputs</literal>
|
||||||
(default: false) options in the Nix configuration file. The defaults will ensure
|
(default: false) options in the Nix configuration file. The defaults will ensure
|
||||||
that all derivations that are not build-time dependencies of garbage collector roots
|
that all derivations that are build-time dependencies of garbage collector roots
|
||||||
will be collected but that all output paths that are not runtime dependencies
|
will be kept and that all output paths that are runtime dependencies
|
||||||
will be collected. (This is usually what you want, but while you are developing
|
will be kept as well. All other derivations or paths will be collected.
|
||||||
|
(This is usually what you want, but while you are developing
|
||||||
it may make sense to keep outputs to ensure that rebuild times are quick.)
|
it may make sense to keep outputs to ensure that rebuild times are quick.)
|
||||||
|
|
||||||
If you are feeling uncertain, you can also first view what files would
|
If you are feeling uncertain, you can also first view what files would
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ incompatible changes:</para>
|
|||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Nix now uses BSD file locks instead of POSIX file
|
<para>Nix now uses BSD file locks instead of POSIX file
|
||||||
locks. Since previous releases used POSIX file locks, you should
|
locks. Because of this, you should not use Nix 2.3 and previous
|
||||||
not use Nix 2.2 and previous releases at the same time on a Nix
|
releases at the same time on a Nix store.</para>
|
||||||
store.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@@ -47,9 +46,9 @@ incompatible changes:</para>
|
|||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para><command>nix</command>: Add
|
<para>The <command>nix</command> command has a new
|
||||||
<option>--print-build-logs</option> (<option>-L</option>) flag to
|
<option>--print-build-logs</option> (<option>-L</option>) flag to
|
||||||
print build log output to stderr rather than showing the last log
|
print build log output to stderr, rather than showing the last log
|
||||||
line in the progress bar. To distinguish between concurrent
|
line in the progress bar. To distinguish between concurrent
|
||||||
builds, log lines are prefixed by the name of the package.
|
builds, log lines are prefixed by the name of the package.
|
||||||
</para>
|
</para>
|
||||||
@@ -57,7 +56,7 @@ incompatible changes:</para>
|
|||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Builds are now executed in a pseudo-terminal, and the
|
<para>Builds are now executed in a pseudo-terminal, and the
|
||||||
<envar>TERM</envar> evnironment variable is set to
|
<envar>TERM</envar> environment variable is set to
|
||||||
<literal>xterm-256color</literal>. This allows many programs
|
<literal>xterm-256color</literal>. This allows many programs
|
||||||
(e.g. <command>gcc</command>, <command>clang</command>,
|
(e.g. <command>gcc</command>, <command>clang</command>,
|
||||||
<command>cmake</command>) to print colorized log output.</para>
|
<command>cmake</command>) to print colorized log output.</para>
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ chmod 1775 $RPM_BUILD_ROOT/nix/store
|
|||||||
for d in profiles gcroots;
|
for d in profiles gcroots;
|
||||||
do
|
do
|
||||||
mkdir -p $RPM_BUILD_ROOT/nix/var/nix/$d/per-user
|
mkdir -p $RPM_BUILD_ROOT/nix/var/nix/$d/per-user
|
||||||
chmod 1777 $RPM_BUILD_ROOT/nix/var/nix/$d/per-user
|
chmod 755 $RPM_BUILD_ROOT/nix/var/nix/$d/per-user
|
||||||
done
|
done
|
||||||
|
|
||||||
# fix permission of nix profile
|
# fix permission of nix profile
|
||||||
|
|||||||
@@ -529,24 +529,17 @@ create_build_users() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_directories() {
|
create_directories() {
|
||||||
|
# FIXME: remove all of this because it duplicates LocalStore::LocalStore().
|
||||||
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 1)" \
|
_sudo "to make the basic directory structure of Nix (part 1)" \
|
||||||
mkdir -pv -m 0755 /nix /nix/var /nix/var/log /nix/var/log/nix /nix/var/log/nix/drvs /nix/var/nix{,/db,/gcroots,/profiles,/temproots,/userpool}
|
mkdir -pv -m 0755 /nix /nix/var /nix/var/log /nix/var/log/nix /nix/var/log/nix/drvs /nix/var/nix{,/db,/gcroots,/profiles,/temproots,/userpool} /nix/var/nix/{gcroots,profiles}/per-user
|
||||||
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 2)" \
|
_sudo "to make the basic directory structure of Nix (part 2)" \
|
||||||
mkdir -pv -m 1777 /nix/var/nix/{gcroots,profiles}/per-user
|
|
||||||
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 3)" \
|
|
||||||
mkdir -pv -m 1775 /nix/store
|
mkdir -pv -m 1775 /nix/store
|
||||||
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 4)" \
|
_sudo "to make the basic directory structure of Nix (part 3)" \
|
||||||
chgrp "$NIX_BUILD_GROUP_NAME" /nix/store
|
chgrp "$NIX_BUILD_GROUP_NAME" /nix/store
|
||||||
|
|
||||||
_sudo "to set up the root user's profile (part 1)" \
|
|
||||||
mkdir -pv -m 0755 /nix/var/nix/profiles/per-user/root
|
|
||||||
|
|
||||||
_sudo "to set up the root user's profile (part 2)" \
|
|
||||||
mkdir -pv -m 0700 "$ROOT_HOME/.nix-defexpr"
|
|
||||||
|
|
||||||
_sudo "to place the default nix daemon configuration (part 1)" \
|
_sudo "to place the default nix daemon configuration (part 1)" \
|
||||||
mkdir -pv -m 0555 /etc/nix
|
mkdir -pv -m 0555 /etc/nix
|
||||||
}
|
}
|
||||||
@@ -589,7 +582,7 @@ EOF
|
|||||||
We will:
|
We will:
|
||||||
|
|
||||||
- make sure your computer doesn't already have Nix files
|
- make sure your computer doesn't already have Nix files
|
||||||
(if it does, I will tell you how to clean them up.)
|
(if it does, I will tell you how to clean them up.)
|
||||||
- create local users (see the list above for the users we'll make)
|
- create local users (see the list above for the users we'll make)
|
||||||
- create a local group ($NIX_BUILD_GROUP_NAME)
|
- create a local group ($NIX_BUILD_GROUP_NAME)
|
||||||
- install Nix in to $NIX_ROOT
|
- install Nix in to $NIX_ROOT
|
||||||
|
|||||||
@@ -5,45 +5,6 @@ __ETC_PROFILE_NIX_SOURCED=1
|
|||||||
export NIX_USER_PROFILE_DIR="@localstatedir@/nix/profiles/per-user/$USER"
|
export NIX_USER_PROFILE_DIR="@localstatedir@/nix/profiles/per-user/$USER"
|
||||||
export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile"
|
export NIX_PROFILES="@localstatedir@/nix/profiles/default $HOME/.nix-profile"
|
||||||
|
|
||||||
# Set up the per-user profile.
|
|
||||||
mkdir -m 0755 -p $NIX_USER_PROFILE_DIR
|
|
||||||
if ! test -O "$NIX_USER_PROFILE_DIR"; then
|
|
||||||
echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -w $HOME; then
|
|
||||||
if ! test -L $HOME/.nix-profile; then
|
|
||||||
if test "$USER" != root; then
|
|
||||||
ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile
|
|
||||||
else
|
|
||||||
# Root installs in the system-wide profile by default.
|
|
||||||
ln -s @localstatedir@/nix/profiles/default $HOME/.nix-profile
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Subscribe the root user to the NixOS channel by default.
|
|
||||||
if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then
|
|
||||||
echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > $HOME/.nix-channels
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the per-user garbage collector roots directory.
|
|
||||||
NIX_USER_GCROOTS_DIR=@localstatedir@/nix/gcroots/per-user/$USER
|
|
||||||
mkdir -m 0755 -p $NIX_USER_GCROOTS_DIR
|
|
||||||
if ! test -O "$NIX_USER_GCROOTS_DIR"; then
|
|
||||||
echo "WARNING: bad ownership on $NIX_USER_GCROOTS_DIR" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up a default Nix expression from which to install stuff.
|
|
||||||
if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then
|
|
||||||
rm -f $HOME/.nix-defexpr
|
|
||||||
mkdir -p $HOME/.nix-defexpr
|
|
||||||
if [ "$USER" != root ]; then
|
|
||||||
ln -s @localstatedir@/nix/profiles/per-user/root/channels $HOME/.nix-defexpr/channels_root
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
||||||
if [ ! -z "${NIX_SSL_CERT_FILE:-}" ]; then
|
if [ ! -z "${NIX_SSL_CERT_FILE:-}" ]; then
|
||||||
: # Allow users to override the NIX_SSL_CERT_FILE
|
: # Allow users to override the NIX_SSL_CERT_FILE
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
if [ -n "$HOME" ] && [ -n "$USER" ]; then
|
if [ -n "$HOME" ] && [ -n "$USER" ]; then
|
||||||
__savedpath="$PATH"
|
|
||||||
export PATH=@coreutils@
|
|
||||||
|
|
||||||
# Set up the per-user profile.
|
# Set up the per-user profile.
|
||||||
# This part should be kept in sync with nixpkgs:nixos/modules/programs/shell.nix
|
# This part should be kept in sync with nixpkgs:nixos/modules/programs/shell.nix
|
||||||
@@ -9,48 +7,6 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
|
|||||||
|
|
||||||
NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER
|
NIX_USER_PROFILE_DIR=@localstatedir@/nix/profiles/per-user/$USER
|
||||||
|
|
||||||
mkdir -m 0755 -p "$NIX_USER_PROFILE_DIR"
|
|
||||||
|
|
||||||
if [ "$(stat --printf '%u' "$NIX_USER_PROFILE_DIR")" != "$(id -u)" ]; then
|
|
||||||
echo "Nix: WARNING: bad ownership on "$NIX_USER_PROFILE_DIR", should be $(id -u)" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -w "$HOME" ]; then
|
|
||||||
if ! [ -L "$NIX_LINK" ]; then
|
|
||||||
echo "Nix: creating $NIX_LINK" >&2
|
|
||||||
if [ "$USER" != root ]; then
|
|
||||||
if ! ln -s "$NIX_USER_PROFILE_DIR"/profile "$NIX_LINK"; then
|
|
||||||
echo "Nix: WARNING: could not create $NIX_LINK -> $NIX_USER_PROFILE_DIR/profile" >&2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Root installs in the system-wide profile by default.
|
|
||||||
ln -s @localstatedir@/nix/profiles/default "$NIX_LINK"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Subscribe the user to the unstable Nixpkgs channel by default.
|
|
||||||
if [ ! -e "$HOME/.nix-channels" ]; then
|
|
||||||
echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > "$HOME/.nix-channels"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the per-user garbage collector roots directory.
|
|
||||||
__user_gcroots=@localstatedir@/nix/gcroots/per-user/"$USER"
|
|
||||||
mkdir -m 0755 -p "$__user_gcroots"
|
|
||||||
if [ "$(stat --printf '%u' "$__user_gcroots")" != "$(id -u)" ]; then
|
|
||||||
echo "Nix: WARNING: bad ownership on $__user_gcroots, should be $(id -u)" >&2
|
|
||||||
fi
|
|
||||||
unset __user_gcroots
|
|
||||||
|
|
||||||
# Set up a default Nix expression from which to install stuff.
|
|
||||||
__nix_defexpr="$HOME"/.nix-defexpr
|
|
||||||
[ -L "$__nix_defexpr" ] && rm -f "$__nix_defexpr"
|
|
||||||
mkdir -m 0755 -p "$__nix_defexpr"
|
|
||||||
if [ "$USER" != root ] && [ ! -L "$__nix_defexpr"/channels_root ]; then
|
|
||||||
ln -s @localstatedir@/nix/profiles/per-user/root/channels "$__nix_defexpr"/channels_root
|
|
||||||
fi
|
|
||||||
unset __nix_defexpr
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Append ~/.nix-defexpr/channels to $NIX_PATH so that <nixpkgs>
|
# Append ~/.nix-defexpr/channels to $NIX_PATH so that <nixpkgs>
|
||||||
# paths work when the user has fetched the Nixpkgs channel.
|
# paths work when the user has fetched the Nixpkgs channel.
|
||||||
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels
|
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels
|
||||||
@@ -78,6 +34,6 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
|
|||||||
export MANPATH="$NIX_LINK/share/man:$MANPATH"
|
export MANPATH="$NIX_LINK/share/man:$MANPATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH="$NIX_LINK/bin:$__savedpath"
|
export PATH="$NIX_LINK/bin:$PATH"
|
||||||
unset __savedpath NIX_LINK NIX_USER_PROFILE_DIR
|
unset NIX_LINK NIX_USER_PROFILE_DIR
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ static void parseJSON(EvalState & state, const char * & s, Value & v)
|
|||||||
mkFloat(v, stod(tmp_number));
|
mkFloat(v, stod(tmp_number));
|
||||||
else
|
else
|
||||||
mkInt(v, stol(tmp_number));
|
mkInt(v, stol(tmp_number));
|
||||||
} catch (std::invalid_argument e) {
|
} catch (std::invalid_argument & e) {
|
||||||
throw JSONParseError("invalid JSON number");
|
throw JSONParseError("invalid JSON number");
|
||||||
} catch (std::out_of_range e) {
|
} catch (std::out_of_range & e) {
|
||||||
throw JSONParseError("out-of-range JSON number");
|
throw JSONParseError("out-of-range JSON number");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2089,12 +2089,12 @@ void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
|
|||||||
if (evalSettings.pureEval && !request.expectedHash)
|
if (evalSettings.pureEval && !request.expectedHash)
|
||||||
throw Error("in pure evaluation mode, '%s' requires a 'sha256' argument", who);
|
throw Error("in pure evaluation mode, '%s' requires a 'sha256' argument", who);
|
||||||
|
|
||||||
Path res = getDownloader()->downloadCached(state.store, request).path;
|
auto res = getDownloader()->downloadCached(state.store, request);
|
||||||
|
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths)
|
||||||
state.allowedPaths->insert(res);
|
state.allowedPaths->insert(res.path);
|
||||||
|
|
||||||
mkString(v, res, PathSet({res}));
|
mkString(v, res.storePath, PathSet({res.storePath}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
runProgram("git", true, { "-C", uri, "diff-index", "--quiet", "HEAD", "--" });
|
runProgram("git", true, { "-C", uri, "diff-index", "--quiet", "HEAD", "--" });
|
||||||
} catch (ExecError e) {
|
} catch (ExecError & e) {
|
||||||
if (!WIFEXITED(e.status) || WEXITSTATUS(e.status) != 1) throw;
|
if (!WIFEXITED(e.status) || WEXITSTATUS(e.status) != 1) throw;
|
||||||
clean = false;
|
clean = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ string getArg(const string & opt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10101000L
|
||||||
/* OpenSSL is not thread-safe by default - it will randomly crash
|
/* OpenSSL is not thread-safe by default - it will randomly crash
|
||||||
unless the user supplies a mutex locking function. So let's do
|
unless the user supplies a mutex locking function. So let's do
|
||||||
that. */
|
that. */
|
||||||
@@ -92,6 +93,7 @@ static void opensslLockCallback(int mode, int type, const char * file, int line)
|
|||||||
else
|
else
|
||||||
opensslLocks[type].unlock();
|
opensslLocks[type].unlock();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void sigHandler(int signo) { }
|
static void sigHandler(int signo) { }
|
||||||
@@ -105,9 +107,11 @@ void initNix()
|
|||||||
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
|
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10101000L
|
||||||
/* Initialise OpenSSL locking. */
|
/* Initialise OpenSSL locking. */
|
||||||
opensslLocks = std::vector<std::mutex>(CRYPTO_num_locks());
|
opensslLocks = std::vector<std::mutex>(CRYPTO_num_locks());
|
||||||
CRYPTO_set_locking_callback(opensslLockCallback);
|
CRYPTO_set_locking_callback(opensslLockCallback);
|
||||||
|
#endif
|
||||||
|
|
||||||
loadConfFile();
|
loadConfFile();
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ class Store;
|
|||||||
|
|
||||||
struct Downloader
|
struct Downloader
|
||||||
{
|
{
|
||||||
|
virtual ~Downloader() { }
|
||||||
|
|
||||||
/* Enqueue a download request, returning a future to the result of
|
/* Enqueue a download request, returning a future to the result of
|
||||||
the download. The future may throw a DownloadError
|
the download. The future may throw a DownloadError
|
||||||
exception. */
|
exception. */
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public:
|
|||||||
uint64_t narOffset = 0; // regular files only
|
uint64_t narOffset = 0; // regular files only
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual ~FSAccessor() { }
|
||||||
|
|
||||||
virtual Stat stat(const Path & path) = 0;
|
virtual Stat stat(const Path & path) = 0;
|
||||||
|
|
||||||
virtual StringSet readDirectory(const Path & path) = 0;
|
virtual StringSet readDirectory(const Path & path) = 0;
|
||||||
|
|||||||
@@ -70,15 +70,17 @@ LocalStore::LocalStore(const Params & params)
|
|||||||
createSymlink(profilesDir, gcRootsDir + "/profiles");
|
createSymlink(profilesDir, gcRootsDir + "/profiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto & perUserDir : {profilesDir + "/per-user", gcRootsDir + "/per-user"}) {
|
||||||
|
createDirs(perUserDir);
|
||||||
|
if (chmod(perUserDir.c_str(), 0755) == -1)
|
||||||
|
throw SysError("could not set permissions on '%s' to 755", perUserDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
createUser(getUserName(), getuid());
|
||||||
|
|
||||||
/* Optionally, create directories and set permissions for a
|
/* Optionally, create directories and set permissions for a
|
||||||
multi-user install. */
|
multi-user install. */
|
||||||
if (getuid() == 0 && settings.buildUsersGroup != "") {
|
if (getuid() == 0 && settings.buildUsersGroup != "") {
|
||||||
|
|
||||||
Path perUserDir = profilesDir + "/per-user";
|
|
||||||
createDirs(perUserDir);
|
|
||||||
if (chmod(perUserDir.c_str(), 01777) == -1)
|
|
||||||
throw SysError(format("could not set permissions on '%1%' to 1777") % perUserDir);
|
|
||||||
|
|
||||||
mode_t perm = 01775;
|
mode_t perm = 01775;
|
||||||
|
|
||||||
struct group * gr = getgrnam(settings.buildUsersGroup.get().c_str());
|
struct group * gr = getgrnam(settings.buildUsersGroup.get().c_str());
|
||||||
@@ -879,8 +881,8 @@ void LocalStore::querySubstitutablePathInfos(const PathSet & paths,
|
|||||||
info->references,
|
info->references,
|
||||||
narInfo ? narInfo->fileSize : 0,
|
narInfo ? narInfo->fileSize : 0,
|
||||||
info->narSize};
|
info->narSize};
|
||||||
} catch (InvalidPath) {
|
} catch (InvalidPath &) {
|
||||||
} catch (SubstituterDisabled) {
|
} catch (SubstituterDisabled &) {
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
if (settings.tryFallback)
|
if (settings.tryFallback)
|
||||||
printError(e.what());
|
printError(e.what());
|
||||||
@@ -1433,4 +1435,19 @@ void LocalStore::signPathInfo(ValidPathInfo & info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LocalStore::createUser(const std::string & userName, uid_t userId)
|
||||||
|
{
|
||||||
|
for (auto & dir : {
|
||||||
|
fmt("%s/profiles/per-user/%s", stateDir, userName),
|
||||||
|
fmt("%s/gcroots/per-user/%s", stateDir, userName)
|
||||||
|
}) {
|
||||||
|
createDirs(dir);
|
||||||
|
if (chmod(dir.c_str(), 0755) == -1)
|
||||||
|
throw SysError("changing permissions of directory '%s'", dir);
|
||||||
|
if (chown(dir.c_str(), userId, getgid()) == -1)
|
||||||
|
throw SysError("changing owner of directory '%s'", dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,6 +293,8 @@ private:
|
|||||||
|
|
||||||
Path getRealStoreDir() override { return realStoreDir; }
|
Path getRealStoreDir() override { return realStoreDir; }
|
||||||
|
|
||||||
|
void createUser(const std::string & userName, uid_t userId) override;
|
||||||
|
|
||||||
friend class DerivationGoal;
|
friend class DerivationGoal;
|
||||||
friend class SubstitutionGoal;
|
friend class SubstitutionGoal;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,9 +39,12 @@ libstore_CXXFLAGS = \
|
|||||||
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
||||||
-DNIX_BIN_DIR=\"$(bindir)\" \
|
-DNIX_BIN_DIR=\"$(bindir)\" \
|
||||||
-DNIX_MAN_DIR=\"$(mandir)\" \
|
-DNIX_MAN_DIR=\"$(mandir)\" \
|
||||||
-DSANDBOX_SHELL="\"$(sandbox_shell)\"" \
|
|
||||||
-DLSOF=\"$(lsof)\"
|
-DLSOF=\"$(lsof)\"
|
||||||
|
|
||||||
|
ifneq ($(sandbox_shell),)
|
||||||
|
libstore_CXXFLAGS += -DSANDBOX_SHELL="\"$(sandbox_shell)\""
|
||||||
|
endif
|
||||||
|
|
||||||
$(d)/local-store.cc: $(d)/schema.sql.gen.hh
|
$(d)/local-store.cc: $(d)/schema.sql.gen.hh
|
||||||
|
|
||||||
$(d)/build.cc:
|
$(d)/build.cc:
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ void RemoteStore::setOptions(Connection & conn)
|
|||||||
overrides.erase(settings.maxSilentTime.name);
|
overrides.erase(settings.maxSilentTime.name);
|
||||||
overrides.erase(settings.buildCores.name);
|
overrides.erase(settings.buildCores.name);
|
||||||
overrides.erase(settings.useSubstitutes.name);
|
overrides.erase(settings.useSubstitutes.name);
|
||||||
|
overrides.erase(settings.showTrace.name);
|
||||||
conn.to << overrides.size();
|
conn.to << overrides.size();
|
||||||
for (auto & i : overrides)
|
for (auto & i : overrides)
|
||||||
conn.to << i.first << i.second.value;
|
conn.to << i.first << i.second.value;
|
||||||
|
|||||||
@@ -628,6 +628,9 @@ public:
|
|||||||
return storePath;
|
return storePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void createUser(const std::string & userName, uid_t userId)
|
||||||
|
{ }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Stats stats;
|
Stats stats;
|
||||||
|
|||||||
@@ -475,6 +475,16 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string getUserName()
|
||||||
|
{
|
||||||
|
auto pw = getpwuid(geteuid());
|
||||||
|
std::string name = pw ? pw->pw_name : getEnv("USER", "");
|
||||||
|
if (name.empty())
|
||||||
|
throw Error("cannot figure out user name");
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Lazy<Path> getHome2([]() {
|
static Lazy<Path> getHome2([]() {
|
||||||
Path homeDir = getEnv("HOME");
|
Path homeDir = getEnv("HOME");
|
||||||
if (homeDir.empty()) {
|
if (homeDir.empty()) {
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ void deletePath(const Path & path, unsigned long long & bytesFreed);
|
|||||||
Path createTempDir(const Path & tmpRoot = "", const Path & prefix = "nix",
|
Path createTempDir(const Path & tmpRoot = "", const Path & prefix = "nix",
|
||||||
bool includePid = true, bool useGlobalCounter = true, mode_t mode = 0755);
|
bool includePid = true, bool useGlobalCounter = true, mode_t mode = 0755);
|
||||||
|
|
||||||
|
std::string getUserName();
|
||||||
|
|
||||||
/* Return $HOME or the user's home directory from /etc/passwd. */
|
/* Return $HOME or the user's home directory from /etc/passwd. */
|
||||||
Path getHome();
|
Path getHome();
|
||||||
|
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ static void _main(int argc, char * * argv)
|
|||||||
auto absolute = i;
|
auto absolute = i;
|
||||||
try {
|
try {
|
||||||
absolute = canonPath(absPath(i), true);
|
absolute = canonPath(absPath(i), true);
|
||||||
} catch (Error e) {};
|
} catch (Error & e) {};
|
||||||
if (store->isStorePath(absolute) && std::regex_match(absolute, std::regex(".*\\.drv(!.*)?")))
|
if (store->isStorePath(absolute) && std::regex_match(absolute, std::regex(".*\\.drv(!.*)?")))
|
||||||
drvs.push_back(DrvInfo(*state, store, absolute));
|
drvs.push_back(DrvInfo(*state, store, absolute));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -159,13 +159,7 @@ static int _main(int argc, char ** argv)
|
|||||||
nixDefExpr = home + "/.nix-defexpr";
|
nixDefExpr = home + "/.nix-defexpr";
|
||||||
|
|
||||||
// Figure out the name of the channels profile.
|
// Figure out the name of the channels profile.
|
||||||
;
|
profile = fmt("%s/profiles/per-user/%s/channels", settings.nixStateDir, getUserName());
|
||||||
auto pw = getpwuid(geteuid());
|
|
||||||
std::string name = pw ? pw->pw_name : getEnv("USER", "");
|
|
||||||
if (name.empty())
|
|
||||||
throw Error("cannot figure out user name");
|
|
||||||
profile = settings.nixStateDir + "/profiles/per-user/" + name + "/channels";
|
|
||||||
createDirs(dirOf(profile));
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
cNone,
|
cNone,
|
||||||
|
|||||||
@@ -742,7 +742,8 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void processConnection(bool trusted)
|
static void processConnection(bool trusted,
|
||||||
|
const std::string & userName, uid_t userId)
|
||||||
{
|
{
|
||||||
MonitorFdHup monitor(from.fd);
|
MonitorFdHup monitor(from.fd);
|
||||||
|
|
||||||
@@ -793,6 +794,8 @@ static void processConnection(bool trusted)
|
|||||||
params["path-info-cache-size"] = "0";
|
params["path-info-cache-size"] = "0";
|
||||||
auto store = openStore(settings.storeUri, params);
|
auto store = openStore(settings.storeUri, params);
|
||||||
|
|
||||||
|
store->createUser(userName, userId);
|
||||||
|
|
||||||
tunnelLogger->stopWork();
|
tunnelLogger->stopWork();
|
||||||
to.flush();
|
to.flush();
|
||||||
|
|
||||||
@@ -1053,7 +1056,7 @@ static void daemonLoop(char * * argv)
|
|||||||
/* Handle the connection. */
|
/* Handle the connection. */
|
||||||
from.fd = remote.get();
|
from.fd = remote.get();
|
||||||
to.fd = remote.get();
|
to.fd = remote.get();
|
||||||
processConnection(trusted);
|
processConnection(trusted, user, peer.uid);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}, options);
|
}, options);
|
||||||
@@ -1133,7 +1136,7 @@ static int _main(int argc, char * * argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
processConnection(true);
|
processConnection(true, "root", 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
daemonLoop(argv);
|
daemonLoop(argv);
|
||||||
|
|||||||
@@ -193,12 +193,6 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Path getDefNixExprPath()
|
|
||||||
{
|
|
||||||
return getHome() + "/.nix-defexpr";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static long getPriority(EvalState & state, DrvInfo & drv)
|
static long getPriority(EvalState & state, DrvInfo & drv)
|
||||||
{
|
{
|
||||||
return drv.queryMetaInt("priority", 0);
|
return drv.queryMetaInt("priority", 0);
|
||||||
@@ -1330,9 +1324,22 @@ static int _main(int argc, char * * argv)
|
|||||||
Globals globals;
|
Globals globals;
|
||||||
|
|
||||||
globals.instSource.type = srcUnknown;
|
globals.instSource.type = srcUnknown;
|
||||||
globals.instSource.nixExprPath = getDefNixExprPath();
|
globals.instSource.nixExprPath = getHome() + "/.nix-defexpr";
|
||||||
globals.instSource.systemFilter = "*";
|
globals.instSource.systemFilter = "*";
|
||||||
|
|
||||||
|
if (!pathExists(globals.instSource.nixExprPath)) {
|
||||||
|
try {
|
||||||
|
createDirs(globals.instSource.nixExprPath);
|
||||||
|
replaceSymlink(
|
||||||
|
fmt("%s/profiles/per-user/%s/channels", settings.nixStateDir, getUserName()),
|
||||||
|
globals.instSource.nixExprPath + "/channels");
|
||||||
|
if (getuid() != 0)
|
||||||
|
replaceSymlink(
|
||||||
|
fmt("%s/profiles/per-user/root/channels", settings.nixStateDir),
|
||||||
|
globals.instSource.nixExprPath + "/channels_root");
|
||||||
|
} catch (Error &) { }
|
||||||
|
}
|
||||||
|
|
||||||
globals.dryRun = false;
|
globals.dryRun = false;
|
||||||
globals.preserveInstalled = false;
|
globals.preserveInstalled = false;
|
||||||
globals.removeAll = false;
|
globals.removeAll = false;
|
||||||
@@ -1425,9 +1432,18 @@ static int _main(int argc, char * * argv)
|
|||||||
|
|
||||||
if (globals.profile == "") {
|
if (globals.profile == "") {
|
||||||
Path profileLink = getHome() + "/.nix-profile";
|
Path profileLink = getHome() + "/.nix-profile";
|
||||||
globals.profile = pathExists(profileLink)
|
try {
|
||||||
? absPath(readLink(profileLink), dirOf(profileLink))
|
if (!pathExists(profileLink)) {
|
||||||
: canonPath(settings.nixStateDir + "/profiles/default");
|
replaceSymlink(
|
||||||
|
getuid() == 0
|
||||||
|
? settings.nixStateDir + "/profiles/default"
|
||||||
|
: fmt("%s/profiles/per-user/%s/profile", settings.nixStateDir, getUserName()),
|
||||||
|
profileLink);
|
||||||
|
}
|
||||||
|
globals.profile = absPath(readLink(profileLink), dirOf(profileLink));
|
||||||
|
} catch (Error &) {
|
||||||
|
globals.profile = profileLink;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
op(globals, opFlags, opArgs);
|
op(globals, opFlags, opArgs);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ struct CmdEdit : InstallableCommand
|
|||||||
int lineno;
|
int lineno;
|
||||||
try {
|
try {
|
||||||
lineno = std::stoi(std::string(pos, colon + 1));
|
lineno = std::stoi(std::string(pos, colon + 1));
|
||||||
} catch (std::invalid_argument e) {
|
} catch (std::invalid_argument & e) {
|
||||||
throw Error("cannot parse line number '%s'", pos);
|
throw Error("cannot parse line number '%s'", pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,25 +45,26 @@ Value * SourceExprCommand::getSourceExpr(EvalState & state)
|
|||||||
|
|
||||||
std::unordered_set<std::string> seen;
|
std::unordered_set<std::string> seen;
|
||||||
|
|
||||||
for (auto & i : searchPath) {
|
auto addEntry = [&](const std::string & name) {
|
||||||
if (i.first == "") continue;
|
if (name == "") return;
|
||||||
if (seen.count(i.first)) continue;
|
if (!seen.insert(name).second) return;
|
||||||
seen.insert(i.first);
|
|
||||||
#if 0
|
|
||||||
auto res = state.resolveSearchPathElem(i);
|
|
||||||
if (!res.first) continue;
|
|
||||||
if (!pathExists(res.second)) continue;
|
|
||||||
mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(i.first)),
|
|
||||||
state.getBuiltin("import"),
|
|
||||||
mkString(*state.allocValue(), res.second));
|
|
||||||
#endif
|
|
||||||
Value * v1 = state.allocValue();
|
Value * v1 = state.allocValue();
|
||||||
mkPrimOpApp(*v1, state.getBuiltin("findFile"), state.getBuiltin("nixPath"));
|
mkPrimOpApp(*v1, state.getBuiltin("findFile"), state.getBuiltin("nixPath"));
|
||||||
Value * v2 = state.allocValue();
|
Value * v2 = state.allocValue();
|
||||||
mkApp(*v2, *v1, mkString(*state.allocValue(), i.first));
|
mkApp(*v2, *v1, mkString(*state.allocValue(), name));
|
||||||
mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(i.first)),
|
mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(name)),
|
||||||
state.getBuiltin("import"), *v2);
|
state.getBuiltin("import"), *v2);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
for (auto & i : searchPath)
|
||||||
|
/* Hack to handle channels. */
|
||||||
|
if (i.first.empty() && pathExists(i.second + "/manifest.nix")) {
|
||||||
|
for (auto & j : readDirectory(i.second))
|
||||||
|
if (j.name != "manifest.nix"
|
||||||
|
&& pathExists(fmt("%s/%s/default.nix", i.second, j.name)))
|
||||||
|
addEntry(j.name);
|
||||||
|
} else
|
||||||
|
addEntry(i.first);
|
||||||
|
|
||||||
vSourceExpr->attrs->sort();
|
vSourceExpr->attrs->sort();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public:
|
|||||||
void log(State & state, Verbosity lvl, const std::string & s)
|
void log(State & state, Verbosity lvl, const std::string & s)
|
||||||
{
|
{
|
||||||
if (state.active) {
|
if (state.active) {
|
||||||
writeToStderr("\r\e[K" + s + ANSI_NORMAL "\n");
|
writeToStderr("\r\e[K" + filterANSIEscapes(s, !isTTY) + ANSI_NORMAL "\n");
|
||||||
draw(state);
|
draw(state);
|
||||||
} else {
|
} else {
|
||||||
auto s2 = s + ANSI_NORMAL "\n";
|
auto s2 = s + ANSI_NORMAL "\n";
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ struct CmdSearch : SourceExprCommand, MixJSON
|
|||||||
Example{
|
Example{
|
||||||
"To search for git and frontend or gui:",
|
"To search for git and frontend or gui:",
|
||||||
"nix search git 'frontend|gui'"
|
"nix search git 'frontend|gui'"
|
||||||
},
|
|
||||||
Example{
|
|
||||||
"To display the description of the found packages:",
|
|
||||||
"nix search git --verbose"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -265,6 +261,7 @@ struct CmdSearch : SourceExprCommand, MixJSON
|
|||||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145 */
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145 */
|
||||||
if (!jsonCacheFile)
|
if (!jsonCacheFile)
|
||||||
throw Error("error writing to %s", tmpFile);
|
throw Error("error writing to %s", tmpFile);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeCache && rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1)
|
if (writeCache && rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct CmdVerify : StorePathsCommand
|
|||||||
bool noContents = false;
|
bool noContents = false;
|
||||||
bool noTrust = false;
|
bool noTrust = false;
|
||||||
Strings substituterUris;
|
Strings substituterUris;
|
||||||
size_t sigsNeeded;
|
size_t sigsNeeded = 0;
|
||||||
|
|
||||||
CmdVerify()
|
CmdVerify()
|
||||||
{
|
{
|
||||||
@@ -113,7 +113,7 @@ struct CmdVerify : StorePathsCommand
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
StringSet sigsSeen;
|
StringSet sigsSeen;
|
||||||
size_t actualSigsNeeded = sigsNeeded ? sigsNeeded : 1;
|
size_t actualSigsNeeded = std::max(sigsNeeded, (size_t) 1);
|
||||||
size_t validSigs = 0;
|
size_t validSigs = 0;
|
||||||
|
|
||||||
auto doSigs = [&](StringSet sigs) {
|
auto doSigs = [&](StringSet sigs) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ grep -q 'item.*attrPath="foo".*name="dependencies"' $TEST_ROOT/meta.xml
|
|||||||
|
|
||||||
# Do an install.
|
# Do an install.
|
||||||
nix-env -i dependencies
|
nix-env -i dependencies
|
||||||
[ -e $TEST_ROOT/var/nix/profiles/default/foobar ]
|
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||||
|
|
||||||
clearProfiles
|
clearProfiles
|
||||||
rm -f $TEST_HOME/.nix-channels
|
rm -f $TEST_HOME/.nix-channels
|
||||||
@@ -55,5 +55,5 @@ grep -q 'item.*attrPath="foo".*name="dependencies"' $TEST_ROOT/meta.xml
|
|||||||
|
|
||||||
# Do an install.
|
# Do an install.
|
||||||
nix-env -i dependencies
|
nix-env -i dependencies
|
||||||
[ -e $TEST_ROOT/var/nix/profiles/default/foobar ]
|
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,3 @@ rm -rf $TEST_HOME $TEST_ROOT/profile-var
|
|||||||
mkdir -p $TEST_HOME
|
mkdir -p $TEST_HOME
|
||||||
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set"
|
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set"
|
||||||
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh" # test idempotency
|
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh" # test idempotency
|
||||||
|
|
||||||
[ -L $TEST_HOME/.nix-profile ]
|
|
||||||
[ -e $TEST_HOME/.nix-channels ]
|
|
||||||
[ -e $TEST_ROOT/profile-var/nix/gcroots/per-user/$user ]
|
|
||||||
[ -e $TEST_ROOT/profile-var/nix/profiles/per-user/$user ]
|
|
||||||
|
|||||||
@@ -13,3 +13,7 @@ cmp $TEST_ROOT/d1 $TEST_ROOT/d2
|
|||||||
nix-store --gc --max-freed 1K
|
nix-store --gc --max-freed 1K
|
||||||
|
|
||||||
killDaemon
|
killDaemon
|
||||||
|
|
||||||
|
user=$(whoami)
|
||||||
|
[ -e $NIX_STATE_DIR/gcroots/per-user/$user ]
|
||||||
|
[ -e $NIX_STATE_DIR/profiles/per-user/$user ]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ drvPath10=$(nix-env -f ./user-envs.nix -qa --drv-path --no-name '*' | grep foo-1
|
|||||||
|
|
||||||
# Query descriptions.
|
# Query descriptions.
|
||||||
nix-env -f ./user-envs.nix -qa '*' --description | grep -q silly
|
nix-env -f ./user-envs.nix -qa '*' --description | grep -q silly
|
||||||
rm -f $HOME/.nix-defexpr
|
rm -rf $HOME/.nix-defexpr
|
||||||
ln -s $(pwd)/user-envs.nix $HOME/.nix-defexpr
|
ln -s $(pwd)/user-envs.nix $HOME/.nix-defexpr
|
||||||
nix-env -qa '*' --description | grep -q silly
|
nix-env -qa '*' --description | grep -q silly
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user