I would like to build the following software for Nixos:
https://github.com/andreimarcu/linx-server
Therefore I have written the following derivation:
{ stdenv, buildGoPackage, fetchFromGitHub }:
buildGoPackage rec {
pname = "linx-server";
version = "v2.1.6";
goPackagePath = "github.com/andreimarcu/linx-server";
src = fetchFromGitHub {
owner = "andreimarcu";
repo = "linx-server";
rev = version;
sha256 = "1ykgb6f3si5a9ib0zmwh7n8higa52g63qcizmh7x19b1fsh8wanz";
};
goDeps = ./deps.nix;
meta = with stdenv.lib; {
homepage = "https://github.com/andreimarcu/linx-server";
description = "Self-hosted file/code/media sharing website";
maintainers = with maintainers; [ foxit64 ];
platforms = platforms.unix;
license = licenses.gpl3;
};
}
The compiling works and I also have a binary that works but unfortunately something is not ok. I cannot start the tool:
~/nix/linx: cp result-bin/bin/linx-server tmp/
~/nix/linx: tmp/linx-server
2020/01/31 08:44:40 Error: could not load templatescould not locate box "templates"
strace shows me this:
6218 newfstatat(AT_FDCWD, "files/", <unfinished ...>
6217 <... nanosleep resumed>NULL) = 0
6218 <... newfstatat resumed>{st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
6217 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], <unfinished ...>
6218 newfstatat(AT_FDCWD, "meta/", <unfinished ...>
6217 <... rt_sigprocmask resumed>[], 8) = 0
6218 <... newfstatat resumed>{st_mode=S_IFDIR|0700, st_size=4096, ...}, 0) = 0
6217 mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7faad9ffc000
6218 newfstatat(AT_FDCWD, "/build/go/src/github.com/andreimarcu/linx-server/templates", <unfinished ...>
6217 mprotect(0x7faad9ffd000, 8388608, PROT_READ|PROT_WRITE <unfinished ...>
6218 <... newfstatat resumed>0xc000378b98, 0) = -1 ENOENT (No such file or directory)
6217 <... mprotect resumed>) = 0
6218 write(2, "2020/01/31 08:04:33 Error: could not load templatescould not locate box \"templates\"\n", 84 <unfinished ...>
6217 clone(child_stack=0x7faada7fbfb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID <unfinished ...>
6218 <... write resumed>) = 84
6218 exit_group(1 <unfinished ...>
Interesting:
6218 newfstatat(AT_FDCWD, "/build/go/src/github.com/andreimarcu/linx-server/templates", <unfinished ...>
If I create the folder “/build” on the root-fs “/”, I get a different error message. This means that the paths were somehow not set correctly during compilation?
Unfortunately, I don’t have much experience with Nix and Go. Therefore I would be very grateful for help.
Another attempt, but it did not work either:
{ stdenv, buildGoPackage, fetchFromGitHub }:
buildGoPackage rec {
pname = "linx-server";
version = "v2.1.6";
goPackagePath = "github.com/andreimarcu/linx-server";
src = fetchFromGitHub {
owner = "andreimarcu";
repo = "linx-server";
rev = version;
sha256 = "1ykgb6f3si5a9ib0zmwh7n8higa52g63qcizmh7x19b1fsh8wanz";
};
goDeps = ./deps.nix;
buildPhase = ''
cd "go/src/$goPackagePath"
patchShebangs build.sh
GOOS=linux GOARCH=amd64 go build -o linx-server
'';
installPhase = ''
install -Dm755 linx-server $bin/bin/linx-server
'';
meta = with stdenv.lib; {
homepage = "https://github.com/andreimarcu/linx-server";
description = "Self-hosted file/code/media sharing website";
maintainers = with maintainers; [ foxit64 ];
platforms = platforms.unix;
license = licenses.gpl3;
};
}
Thanks a lot