- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 NixOS 上运行一个 Haskell 项目(使用 stack
),它使用了 XDG_RUNTIME_DIR
(以防万一:它是一个使用 X11 运行的 wayland 合成器项目后端)。当我的程序启动时:
stack exec my-compositor-project-exe # nix is enabled by default
我得到一个错误:
error: XDG_RUNTIME_DIR not set in the environment
但是,如果我使用 --no-nix-pure
运行,我不会收到错误:
stack --no-nix-pure exec my-compositor-project-exe
# ... no error ...
但这真的是修复此错误的最佳方法吗?
请注意,当我在 NixOS 终端中运行 echo $XDG_RUNTIME_DIR
时,我得到了
echo $XDG_RUNTIME_DIR
/run/user/1000
当我在我的 Haskell 堆栈项目中运行 nix-shell
时,我也得到了
[nix-shell:~/my-project]$ echo $XDG_RUNTIME_DIR
/run/user/1000
所以我为什么会收到此错误完全是个谜。
问题:解决这个问题的正确方法是什么?
以防万一here是关于 $XDG_RUNTIME_DIR
含义的一些信息:
There is a single base directory relative to which user-specific runtime files and other file objects should be placed. This directory is defined by the environment variable $XDG_RUNTIME_DI.
...
$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, …) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.
...
If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.
在我的程序中产生错误的特定 FFI 调用是对 wl_display_add_socket
(wayland 函数)的调用,它在其主体的顶部:
WL_EXPORT int
wl_display_add_socket(struct wl_display *display, const char *name)
{
runtime_dir = getenv("XDG_RUNTIME_DIR");
if (!runtime_dir) {
wl_log("error: XDG_RUNTIME_DIR not set in the environment\n");
/* to prevent programs reporting
* "failed to add socket: Success" */
errno = ENOENT;
return -1;
}
//...
}
最佳答案
正如您所注意到的,Stack 中的 Nix 纯度功能并不适用于所有情况。某些程序只需要一些环境变量来与其环境交互,因此在纯模式下使用 Nix 集成没有意义。我的看法是,--nix-pure
通常只适用于编译,顺便说一句,它适用于一些简单的程序。
如果您喜欢冒险,您可以尝试通过您的 shell.nix
显式传递环境变量,方法是将此行添加到您的 shell 派生中:
XDG_RUNTIME_DIR = builtins.getEnv "XDG_RUNTIME_DIR"
但是,我不会打扰,只需使用 --no-nix-pure
调用 stack exec
。
关于haskell - 在 Haskell Stack+Nix 项目中设置 XDG_RUNTIME_DIR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54641025/
学习如何使用 Nix 包管理器时遇到的第一种 Nix 表达式是 default.nix;在精彩的 NixOS IRC channel 上,我还了解到 shell.nix 和 release.nix 的
一段时间后,我的开发机器中的磁盘空间开始用完(只有 128GB)。出于这个原因,我决定将本地缓存存储(.npm、.m2、.ivy2 等)移动到外部驱动器。 在经历了众所周知的“ cabal hell
我按照 http://lethalman.blogspot.com/2014/08/nix-pill-8-generic-builders.html 上的步骤操作构建 GNU Hello,这是我用来构
我过去注意到在 nix , 一个 ./myfile.txt路径类型似乎 有时评估为 /home/myuser/mydir/myfile.txt , 和 有时到 /nix/store/55j24v9qw
即使在阅读了 Nix 手册之后,仍然对 Nix 表达式的真正含义感到困惑。有时它们被称为派生,但存储派生也有其他含义。 最佳答案 在 Nix 中,Nix 表达式只是您可以用 Nix 语言编写的任何类型
我没有在 Nix 派生中找到任何关于处理临时文件的信息。 我找到了 $TMP 和 $TMPDIR 环境变量,但它们都指向 /tmp,这是系统全局的。 { pkgs ? import {} }:
我有一个 default.nix构建派生的文件(至少我对它的理解)。 { nixpkgs ? import {}, compiler ? "ghc864" } : nixpkgs.pkgs.hask
所以,终于开始获得一个稳定的 nix 环境,我基本上可以在其中进行所有的开发。万岁! 现在我想让它重现,如 yarn.lock (对于那些熟悉 javascript 领域中的 npm/yarn 的人)
运行时的某个时候nix-build和 nixos-rebuild我发现了易于修复的问题(例如不推荐使用的警告或多余的导入),我想“有趣,我可以在空闲时间解决这个问题”。 我知道我可以将构建日志重定向到
我刚刚开始了解 Nix,所以如果我错过了文档中问题的答案,我深表歉意。 我想使用 Nix 设置一台具有最少库和可执行文件集的安全生产机器。我不希望存在任何编译器或其他构建工具,因为这些可能存在安全风险
我只使用 Nix作为包管理器而不使用全部NixOS .我想要一个可重现的 nix-env -i可以共享和备份的软件包安装。 我知道使用 config.nix为 NixOS但我正在寻找与 Nix 类似的
我写了一个非常简单的 default.nix 文件,我应该可以用它来构建 gnu hello 包(类似于 nix-pills)。 但是现在我遇到了一个错误: [jane@nixos:~/graphvi
我正在编写一个 .nix 表达式,主要供 nix-shell 使用。 .我不知道该怎么做。请注意,这不在 NixOS 上,但我认为这不是很相关。 我正在查看的特定示例是我想获得 this versio
我知道 a similar question , 但它指的是 ? 在 function definitions with a set pattern 中使用(pinned)。 我查看了 lib.mak
我相信我跑了nix-env -if example.nix这改变了我的 nix 环境。 如何撤消此操作? 我正在尝试运行在我的 nixos 配置( /etc/nixos/* )中指定的应用程序,但它似
我想运行一个安装了以下软件包的 nix-shell: aspell aspellDicts.en 你好 我不能简单地做:nix-shell -p aspell aspellDicts.en hello
我是 nix 世界的新手,我使用 Mac OS X。我刚刚在我的 MacBook 上安装了 nix,并想使用 nix 来管理一些软件包,例如 Emacs 而不是 Homebrew。 我找到了这个仓库:
在 Nix 手册的 Inheriting attributes 中部分,我们有 graphviz = (import ../tools/graphics/graphviz) { inherit f
我想在相同架构的多台 openSUSE 机器(不同版本)上使用 nix-package manager 一致地安装软件。我不是任何系统的 root,但想说服我们的系统管理员在所有使用网络挂载的机器上以
我创建了自己的存储库来获取一些 git 源。 # packages.nix with (import {}); rec { rustcSource = fetchgit { url =
我是一名优秀的程序员,十分优秀!