When I install the Aspell package with the Aspell dictionary for English into my global env using Nix on Mac OSX:
$ nix-env -iA nixpkgs.aspell nixpkgs.aspellDicts.en
Then Aspell behaves as I would expect:
$ aspell dump dicts
en
en-variant_0
...
However if I install the packages into a nix-shell then the Dictionary does not appear to be correctly installed:
$ nix-shell -p aspell aspellDicts.en --pure
$ aspell dump dicts
# nothing printed
$ echo 'word lister to check' | aspell --list
Error: No word lists can be found for the language "en_US".
Each of the following variations produce the same problem behaviour:
Installing into a nix-shell that is not pure,
Putting the nix expression into a default.nix file and just running nix-shell.
Installing other Aspell dictionaries
Can anyone advise how to get this working?
The aspell binary is wrapped by NixPkgs, to provide the installation paths through ASPELL_CONF environment variable, if not already specified. (For details, cat -v result/bin/aspell)
You can either specify ASPELL_CONF manually, or use the NIX_PROFILES environment variable. For example:
$ nix-build -E 'with import <nixpkgs> {};
buildEnv { name = "aspell-env"; paths = [aspell aspellDicts.en]; }'
$ NIX_PROFILES=./result ./result/bin/aspell dump dicts
en
en-variant_0
[...]
en_US-wo_accents
However, if you want to build a self-contained aspell install with dictionaries, you can use aspellWithDicts:
nix-build -E 'with import <nixpkgs> {}; aspellWithDicts (d: [d.en])'
This will hardcode the ASPELL_CONF, so you don't need to think of those environment variables again.
Related
I can start nix-shell with a package from a particular revision, e.g.
nix-shell -p ktlint -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/141439f6f11537ee349a58aaf97a5a5fc072365c.tar.gz
nix-shell -p jq -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/7d7622909a38a46415dd146ec046fdc0f3309f44.tar.gz
Can I start nix-shell with two packages, but from different revisions, in one command? For example, if I wanted both ktlint and jq from the specific revisions above?
Setting NIX_PATH=nixpkgs=... is just syntactic sugar enabling references like <nixpkgs> to work; but one doesn't need to use import <nixpkgs> exclusively -- one can also import directly from an explicit path.
nix-shell -E '
let
pkgsA = (import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/141439f6f11537ee349a58aaf97a5a5fc072365c.tar.gz) {});
pkgsB = (import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/7d7622909a38a46415dd146ec046fdc0f3309f44.tar.gz) {});
in
pkgsA.mkShell {
buildInputs = [
pkgsA.ktlint
pkgsB.jq
];
}'
I deleted /nix and started a fresh install of nix, however after installing nix install nix (MACBook Pro M1 arm64 BigSur) with sh <(curl -L https://nixos.org/nix/install) I run $ nix but I get the output zsh: command not found: nix , same for nix-shellalso the /nix volume is not created, I also tried the instruction at https://docs.plutus-community.com/docs/setup/MacOS.html still same issue
Open /etc/zshrc and look for the following lines (probably at the end of the file):
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
Copy these lines and delete them from this file.
Open ~/.zshrc and add the above copied lines to the end of this file
Reboot terminal and nix should work now.
I'm running nixos 19.09 and trying to follow along with the instructions for creating a ruby package. But in one of the first steps I'm getting an error that the withPackages attribute can't be found.
Command:
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --show-trace
Result:
while evaluating the attribute 'buildInputs' of the derivation 'shell' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'getOutput' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:141:17, called from undefined position:
attribute 'withPackages' missing, at (string):1:94
I'm guessing that I messed up my nix store somehow, but I don't know how to debug it.
Additional Info:
$ echo $NIX_PATH
$HOME/.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
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixos-19.03
unstable https://nixos.org/channels/nixos-unstable
$ sudo nix-channel --list
<blank>
After #RobertHensing pointed out that it looked like I was on 19.03, and asked me to print out my channels, I tried just updating the channel list to point to 19.09 instead of 19.03 (with nix-channel --add) and that fixed it.
I've got a default.nix file that builds a derivation (at least my understanding of it).
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc864" } :
nixpkgs.pkgs.haskell.packages.${compiler}.callCabal2nix "bhoogle" (./.) {}
I can successfully nix-build this. Is there a way I can install this into my user profile with nix-env directly? For example something like nix-env -i -f default.nix.
Otherwise I need to define a package in my system profile with something like:
example = pkgs.callPackage /home/chris/example/default.nix {};
Quite literally my initial guess (thanks #Robert):
nix-env -i -f default.nix
Documented in nix --help:
--file / -f path
Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query
--available operations to obtain
derivations. The default is ~/.nix-defexpr.
If the argument starts with http:// or https://, it is interpreted as the URL of a tarball that will be downloaded and
unpacked to a temporary location. The tarball
must include a single top-level directory containing at least a file named default.nix.
I want to run nixpkgs test locally, I have found this manual, but it doesn't work
$ cd my/nixpkgs
$ nix-build --show-trace nixos/tests/login.nix
error: while evaluating the attribute ‘buildCommand’ of the derivation ‘vm-test-run-login’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-test-driver-login’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-vm’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘text’ of the derivation ‘run-nixos-vm’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating anonymous function at /home/bjorn/projects/nixpkgs/pkgs/build-support/closure-info.nix:9:1, called from /home/bjorn/projects/nixpkgs/nixos/modules/virtualisation/qemu-vm.nix:105:13:
assertion failed at /home/bjorn/projects/nixpkgs/pkgs/build-support/closure-info.nix:11:1
because of this assert
assert builtins.langVersion >= 5;
How to update langVersion?
$ nix-repl
Welcome to Nix version 1.11.16. Type :? for help.
nix-repl> builtins.langVersion
3
nix-repl>
If you want to stay on 17.09 for a while longer, you can upgrade just Nix using this NixOS configuration:
{ pkgs, ... }: {
nix.package = pkgs.nixUnstable;
}
Otherwise you may prefer to switch to 18.03 instead of unstable. If you're going to use unstable, make sure you're using nixos-unstable, not nixpkgs-unstable. See https://nixos.wiki/wiki/Nixpkgs#Channels
Thx to David Grayson
I had to update nixos to unstable (sudo nix-channel is important)
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
sudo nixos-rebuild switch --upgrade
nix-instantiate --eval -E '(import <nixos> {}).lib.nixpkgsVersion'
nix-instantiate --eval -E 'builtins.langVersion'