有没有办法在 NixOS 上安装 NPM 命令行工具?
[root@ip-xxx-xxx-0-27:~/teros/ntrs-cli]# sudo npm i -g typescript
npm WARN checkPermissions Missing write access to /nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1/lib/node_modules
npm ERR! path /nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1/lib/node_modules
npm ERR! code EROFS
npm ERR! errno -30
npm ERR! syscall access
npm ERR! rofs EROFS: read-only file system, access '/nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1/lib/node_modules'
npm ERR! rofs Often virtualized file systems, or other file systems
npm ERR! rofs that don't support symlinks, give this error.
Run Code Online (Sandbox Code Playgroud)
我假设因为它是只读的,因为我确实运行了:
chown -R `whoami` nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1
Run Code Online (Sandbox Code Playgroud)
顺便说一句,如果有人知道如何在 nixos 上安装 Node.js 版本 11 或 12,那就太好了。
我正在试验emacs中的ghc-mod插件和NixOS 14.04之间的交互问题.基本上,一旦通过安装包nix-env -i,它们可以从ghc和ghci中看到,由haskell-mode识别,但ghc-mod找不到.
为避免信息重复,您可以在错误故障单https://github.com/kazu-yamamoto/ghc-mod/issues/269中找到所有详细信息以及VM中问题的确切复制.
我在NixOS 16.09上,我想使用目前仅在nixpkgs-unstable/nixos-unstable中的软件包.
使用nix-channel --add,我能够将nixpkgs-unstable添加到我的(用户)频道,并使用它来安装最新版本的某些软件包nix-env.
但是,据我所知,虽然nix-env依赖于用户定义的通道,但nix-shell取决于NIX_PATH环境变量,在我的情况下:
$ echo $NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
Run Code Online (Sandbox Code Playgroud)
所以这清楚地表明了问题:nix-shell将使用系统范围的NixOS 16.09通道而不是用户定义的nixpkgs-unstable通道.
现在,我正在使用此解决方法:
nix-shell -I nixpkgs=~/.nix-defexpr/channels/nixpkgs
Run Code Online (Sandbox Code Playgroud)
它看起来不是很漂亮.这样做的推荐方法是什么?
它是否添加如下内容:
export NIX_PATH="nixpkgs=~/.nix-defexpr/channels/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels"
Run Code Online (Sandbox Code Playgroud)
对我.profile?它看起来也不是很漂亮.
[披露:我早些时候在 NixOS 频道上问过这个问题,但 30 分钟后没有得到答复,这是一个繁忙的频道。如果我在那里得到一个,我会在这里复制它]
我正在尝试向 NixOS 中的配置文件添加一些行(例如/etc/pam.d/sudo)。pam.nix 中可用的配置选项不包括我要添加的行(在本例中为account requisite pam_time.so),也不包括extraConfig选项。
我知道我可以使用它来创建新的配置文件,environement.etc.filename.text所以我继续使用它,但sudo nixos-rebuild switch后来抱怨它有两个配置文件的来源,官方的和我的 ( mismatched duplicate entry /nix/… <-> /nix/…):
environment.etc."pam.d/sudo".text = ''blah'';
Run Code Online (Sandbox Code Playgroud)
在 NixOS 中是否有附加到 /etc/ 配置文件(或修补它)的通用方法?
或者是修改系统 .nix 文件的唯一方法(例如修改pam.nix,我不愿意这样做,因为它会与未来的更新发生冲突)?
我已经成功安装了ghc nix-env -i ghc.
我现在想安装一个Haskell库,应该怎么做?例如turtle(https://hackage.haskell.org/package/turtle)库.
我已经运行nix-env -f "<nixpkgs>" -iA haskellPackages.turtle,但运行ghci和import Turtle失败:
Prelude> import Turtle
<no location info>: error:
Could not find module ‘Turtle’
It is not a module in the current program, or in any known package.
Run Code Online (Sandbox Code Playgroud)
产量ghc-pkg list:
/nix/store/fvf278s3lqsjv488ahhdi8jx6i0qzsr9-ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
Cabal-1.24.2.0
array-0.5.1.1
base-4.9.1.0
binary-0.8.3.0
bytestring-0.10.8.1
containers-0.5.7.1
deepseq-1.4.2.0
directory-1.3.0.0
filepath-1.4.1.1
ghc-8.0.2
ghc-boot-8.0.2
ghc-boot-th-8.0.2
ghc-prim-0.5.0.0
ghci-8.0.2
haskeline-0.7.3.0
hoopl-3.10.2.1
hpc-0.6.0.3
integer-gmp-1.0.0.1
pretty-1.1.3.3
process-1.4.3.0
rts-1.0
template-haskell-2.11.1.0
terminfo-0.4.0.2
time-1.6.0.1
transformers-0.5.2.0
unix-2.7.2.1
xhtml-3000.2.1
Run Code Online (Sandbox Code Playgroud) 几周前我在我的机器上安装了nix软件包管理器(macOS 10.12.6 Sierra).
我想更新mylocal nixpkgs集合,使其与频道中的任何上游更新同步.我的理解是,这可以通过运行:nix-channel --update.但是当我运行它时,我得到以下输出:
unpacking channels...
created 0 symlinks in user environment
建议我的系统订阅的频道中没有更新任何表达式.如果我跑,nix-channel --list我没有看到列出的任何频道.默认情况下我的系统订阅了哪个频道?我应该期望它被列出吗?
nix-channel --update如果我修改了我订阅的频道或者我订阅了不稳定的频道,通常只会产生局部变化吗?
我正在尝试在NixOS上进行cython调试.我可以在nix-shell中轻松安装cython(为简单起见而选择),如下所示:
$ nix-shell -p 'python27.withPackages( p: [ p.cython ])'
$ cat /nix/store/s0w3phb2saixi0a9bzk8pjbczjaz8d7r-python-2.7.14-env/bin/python
#! /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash -e
export PYTHONHOME="/nix/store/s0w3phb2saixi0a9bzk8pjbczjaz8d7r-python-2.7.14-env"
export PYTHONNOUSERSITE="true"
exec "/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python" "${extraFlagsArray[@]}" "$@"
Run Code Online (Sandbox Code Playgroud)
然后我们做一个普通的nix-shell只是python,看看我们得到了什么版本的python.
[henry@bollum:~/Projects/eyeserver/nixshell]$ nix-shell -p 'python27'
$ which python
/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python
# ^^^^^^^
# non-debug
Run Code Online (Sandbox Code Playgroud)
一切都很好 - 我们在两种情况下都获得了非调试python.如果我们gdb它,我们得到(没有找到调试符号).见最后一行.
$ gdb
/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the …Run Code Online (Sandbox Code Playgroud) 我无法理解Nix Pill 14。作者提供了makeOverridable,然后挑战用户将其集成callPackage。makeOverridable和default.nix提供如下,其中makeOverridable位于 文件 中lib.nix,callPackage位于 文件 中default.nix:
# file: lib.nix
rec {
makeOverridable = f: origArgs:
let
origRes = f origArgs;
in
origRes // { override = newArgs: makeOverridable f (origArgs // newArgs); };
}
Run Code Online (Sandbox Code Playgroud)
# file: default.nix
let
nixpkgs = import <nixpkgs> {};
allPkgs = nixpkgs // pkgs;
callPackage = path: overrides:
let f = import path;
in f ((builtins.intersectAttrs (builtins.functionArgs …Run Code Online (Sandbox Code Playgroud) 我想使用stdenv.cc覆盖(即不更改 nixpkgs)全局覆盖特定的 GCC 版本(不一定在 nixpkgs 中)。有没有办法做到这一点?
像这样的覆盖会导致无限递归(因为包gcc49作为stdenv输入):
self: super:
{
stdenv = super.overrideCC super.stdenv super.gcc49;
}
Run Code Online (Sandbox Code Playgroud)
改变stdenv.cc全局的正确方法是什么?
手动设置stdenv = ...是不可行的,因为我不仅import nixpkgs想在构建/使用 nix 表达式时替换,而且还想在例如中替换。ccnix-shell -p package
有人可以帮我弄这个吗?
当尝试恢复旧项目时,有时我必须四处寻找较旧的 Nixpkgs 承诺才能开始工作。
例如,我的大多数shell.nix文件都是这样开始的,
{pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# ...
}
Run Code Online (Sandbox Code Playgroud)
这将从当前通道指向的提交中导入所有表达式,但一段时间后,发生了太多更改,我的项目将不再构建;然后我必须找到一个仍然有效的提交,然后从那里开始。
$ nix-shell --arg pkgs \
> 'import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/0c0fe6d85b92c4e992e314bd6f9943413af9a309.tar.gz") {}'
Run Code Online (Sandbox Code Playgroud)
如果我当时能够从通道中保存工作提交,并在以后需要时有一些可靠的东西可以回退,那可能是最好的。