Currently I started using NixOS, and it's working great except for that there are some packages I want to install that are not in the repository.
The first package I had issues with is Cryptomator (https://cryptomator.org)
What I tried to do is follow this tutorial: http://anderspapitto.com/posts/2015-02-28-deb-installation-nixos.html
But I couldn't get it to work... Here is what I tried:
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";
};
};
}
I then run:
nix-build -A fhsEnv fhs-env.nix
nix-build -A dumb-cryptomator dumb-cryptomator.nix
nix-build -A full-cryptomator full-cryptomator.nix
When the last build is completed, I don't have a full cryptomator install in my directory (at least /opt/Cryptomator should be there):
[peter@peter-laptop:~/Downloads/cryptomator]$ ls /nix/store/6prdbjgidgqaqfnvmkrhnj8xp28z8dxw-full-cryptomator
bin
Is there anyone having more experience with making third-party packages work? Thanks!
At least you should change
runScript = "Cryptomator";
to
runScript = "${dumb-cryptomator}/Cryptomator/Cryptomator";
Debugging such kinds of problems is easy. When you run nix-build -A full-cryptomator full-cryptomator.nix
, a symlink result
is created, so you can access application by
$ ./result/bin/full-cryptomator
/nix/store/7nc1j85m67kjd1y1fnk6xg5b7w7a1jjd-full-cryptomator-init: line 11: exec: Cryptomator: not found
Whoops! Why's that? let's look into mentioned file:
$ 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 "$@"
Looks like it can't file Cryptomator
executable in current PATH. When we inspect actual dumb-cryptomator
, we see
$ 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
So, it doesn't belong to standard bin
folder. As we don't want to mess with package alot, we provide a full path, by using ${dumb-cryptomator}
string interpolation.
(that's one of the most used features in Nix, ${dumb-cryptomator}
gets expanded to /nix/store/m31pyd1hgpa9v8gnxrjijd1v3n8vxggj-dumb-cryptomator
during builds)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With