目前,我开始使用NixOS,它的运行非常好,除了有些我要安装的软件包不在存储库中。
我遇到的第一个软件包是Cryptomator(https://cryptomator.org)
我试图做的是遵循本教程:http://anderspapitto.com/posts/2015-02-28-deb-installation-nixos.html
但我无法使其正常工作...这是我尝试的方法:
full-cryptomator.nix
let nixpkgs = import <nixpkgs> {};
stdenv = nixpkgs.stdenv;
in rec {
dumb-cryptomator = stdenv.mkDerivation {
name = "dumb-cryptomator";
builder = ./builder.sh;
dpkg = nixpkgs.dpkg;
src = nixpkgs.fetchurl {
url = "https://bintray.com/cryptomator/cryptomator-deb/download_file?file_path=cryptomator-1.2.3-amd64.deb";
sha256 = "f611dfd77f68ddd4b7322b1668829add987c5f8e0fcd639211b46969f1eb8ef3";
};
};
full-cryptomator = nixpkgs.buildFHSUserEnv {
name = "full-cryptomator";
targetPkgs = pkgs: [ dumb-cryptomator ];
multiPkgs = pkgs: [ pkgs.dpkg ];
runScript = "Cryptomator";
};
}
dumb-cryptomator.nix
let nixpkgs = import <nixpkgs> {};
stdenv = nixpkgs.stdenv;
in rec {
dumb-cryptomator = stdenv.mkDerivation {
name = "dumb-cryptomator";
builder = ./builder.sh;
dpkg = nixpkgs.dpkg;
src = nixpkgs.fetchurl {
url = "https://bintray.com/cryptomator/cryptomator-deb/download_file?file_path=cryptomator-1.2.3-amd64.deb";
sha256 = "f611dfd77f68ddd4b7322b1668829add987c5f8e0fcd639211b46969f1eb8ef3";
};
};
}
然后,我运行:
nix-build -A fhsEnv fhs-env.nix
nix-build -A dumb-cryptomator dumb-cryptomator.nix
nix-build -A full-cryptomator full-cryptomator.nix
最后一次构建完成后,我的目录中没有完整的cryptomator安装程序(至少应该有/opt/Cryptomator):
[peter@peter-laptop:~/Downloads/cryptomator]$ ls /nix/store/6prdbjgidgqaqfnvmkrhnj8xp28z8dxw-full-cryptomator
bin
是否有人在使第三方程序包正常工作方面有更多经验?谢谢!
最佳答案
至少你应该改变 runScript = "Cryptomator";
至 runScript = "${dumb-cryptomator}/Cryptomator/Cryptomator";
调试这类问题很容易。运行nix-build -A full-cryptomator full-cryptomator.nix
时,将创建一个符号链接(symbolic link)result
,因此您可以通过以下方式访问应用程序: $ ./result/bin/full-cryptomator /nix/store/7nc1j85m67kjd1y1fnk6xg5b7w7a1jjd-full-cryptomator-init: line 11: exec: Cryptomator: not found
哎呀!为什么?让我们看一下提到的文件:
$ cat /nix/store/7nc1j85m67kjd1y1fnk6xg5b7w7a1jjd-full-cryptomator-init
#! /nix/store/wsz11sx18n85if6gp50m870rypgavwpd-bash-4.4-p12/bin/bash
for i in /nix/store/ss4j5rr2ilh878m1g5c76njcmvmrszja-full-cryptomator-fhs/* /host/*; do
path="/${i##*/}"
[ -e "$path" ] || /nix/store/sxzm5kva1gb0hxm60xvr45m3c5l84xlz-coreutils-8.27/bin/ln -s "$i" "$path"
done
[ -d "$1" ] && [ -r "$1" ] && cd "$1"
shift
source /etc/profile
exec Cryptomator "$@"
看起来无法在当前PATH中归档
Cryptomator
可执行文件。当我们检查实际的dumb-cryptomator
时,我们看到$ tree /nix/store/m31pyd1hgpa9v8gnxrjijd1v3n8vxggj-dumb-cryptomator | grep -i crypto
/nix/store/m31pyd1hgpa9v8gnxrjijd1v3n8vxggj-dumb-cryptomator
└── Cryptomator
│ ├── cryptolib-1.0.7.jar
│ ├── Cryptomator-1.2.3.jar
│ ├── Cryptomator.cfg
│ ├── filesystem-crypto-1.2.3.jar
├── Cryptomator
├── Cryptomator.desktop
├── cryptomator.org-Cryptomator-MimeInfo.xml
├── Cryptomator.png
因此,它不属于标准
bin
文件夹。由于我们不想弄乱很多软件包,因此我们使用${dumb-cryptomator}
字符串插值提供了完整的路径。(这是Nix中最常用的功能之一,在构建过程中
${dumb-cryptomator}
扩展为/nix/store/m31pyd1hgpa9v8gnxrjijd1v3n8vxggj-dumb-cryptomator
)关于linux - NixOS:安装非Nix软件包吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43887868/