目前我开始使用NixOS,它的工作效果很好,只是因为我想安装一些不在存储库中的软件包。
我遇到的第一个问题是Cryptomator(https://cryptomator.org)
我尝试做的是遵循本教程:http://anderspapitto.com/posts/2015-02-28-deb-installation-nixos.html
但我无法让它发挥作用......这就是我的尝试:
全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";
};
}
哑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
当最后一次构建完成后,我的目录中没有完整的加密器安装(至少/ opt / Cryptomator应该在那里):
[peter@peter-laptop:~/Downloads/cryptomator]$ ls /nix/store/6prdbjgidgqaqfnvmkrhnj8xp28z8dxw-full-cryptomator
bin
是否有人在制作第三方软件包方面有更多经验?谢谢!
答案 0 :(得分:2)
至少你应该改变
runScript = "Cryptomator";
至
runScript = "${dumb-cryptomator}/Cryptomator/Cryptomator";
调试此类问题很容易。当您运行nix-build -A full-cryptomator full-cryptomator.nix
时,会创建一个符号链接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