I use since recently a great feature to compile and debug a project quickly: nix-shell
. My goal was to run:
$ nix-shell
[nix-shell]$ genericBuild
... the build runs until errors
[nix-shell]$ # fix the errors, and run only the missing phases with `phases="buildPhase" genericBuild`
Unfortunately, on the project I’m currently working on, the process fails and exit (in the nix-shell) during the unpackPhase
, because it tries to unpack a folder… which is already unpacked. Since nix-build
do not have any problem during the unpack phase, I guess that the function that I should run is maybe not genericBuild
. To check, I tried to find the actual builder, which is bash
, but I can’t find any argument:
[nix-shell]$ echo $builder
/nix/store/cwnwyy82wrq53820z6yg7869z8dl5s7g-bash-4.4-p23/bin/bash
[nix-shell]$ echo $args
So how can I know and reproduce the exact commands that nix-build
is going to run? Also, any idea why in my case the unpack phase fails in nix-shell but not in nix-build (I’m using fetchSubmodules, don’t know if it’s the reason…)? (and if you understand why my nix-build fails, I’d also be interested, but it’s another question I guess)
Thanks!
derivation.nix:
{ lib, clangStdenv, fetchFromGitHub, nodejs }:
clangStdenv.mkDerivation rec {
pname = "armorpaint";
version = "20.01";
src = fetchFromGitHub {
owner = "armory3d";
repo = "armorpaint";
rev = "95453348b2";
sha256 = "sha256-wmgEXcPZw5JWnIPzw18lKCu7xMVQ+rFYH0Z93/n8qrU=";
fetchSubmodules = true;
};
buildInputs = [ nodejs ];
buildPhase = ''
node armorcore/make -g opengl
cd armorcore
node Kinc/make -g opengl --compiler clang --compile
cd Deployment
strip Krom
./Krom ../../build/krom
'';
# meta = with stdenv.lib; {
# description = "";
# homepage = "https://github.com/armory3d/armorpaint";
# license = licenses.;
# maintainers = with maintainers; [ ];
# platforms = platforms.;
# };
}
default.nix:
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./derivation.nix {}
Console:
# Console output:
$ nix-shell
[nix-shell]$ genericBuild
unpacking sources
unpacking source archive /nix/store/68v9kl0824hvwzjl9l8azmdsjjqf6khp-source
unpacker appears to have produced no directories
exit
$ ls /nix/store/68v9kl0824hvwzjl9l8azmdsjjqf6khp-source
armorcore Assets changes.md checkstyle.json khafile.js Libraries LICENSE.md README.md Shaders Sources
nix-build works (at least it unpacks correctly):
$ nix-build
this derivation will be built:
/nix/store/6gvb0ysbk1ljwsqxxrrlgvrwbdl13v0w-armorpaint-20.01.drv
building '/nix/store/6gvb0ysbk1ljwsqxxrrlgvrwbdl13v0w-armorpaint-20.01.drv'...
unpacking sources
unpacking source archive /nix/store/68v9kl0824hvwzjl9l8azmdsjjqf6khp-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 1617402671 of file source/khafile.js
patching sources
configuring
no configure script, doing nothing
building
Using Kha from /build/source/armorcore
Creating Kha project.
Exporting asset 1 of 28 (Scene.arm).
Exporting asset 2 of 28 (World_irradiance.arm).
Exporting asset 3 of 28 (World_radiance.hdr).
Exporting asset 4 of 28 (World_radiance_0.hdr).
[...]
Compiling shader 6 of 50 (armdefault_mesh.frag.glsl).
Compiling shader 7 of 50 (armdefault_mesh.vert.glsl).
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn /build/source/armorcore/Kinc/Tools/krafix/krafix-linux64 ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /build/source/armorcore/Kinc/Tools/krafix/krafix-linux64',
path: '/build/source/armorcore/Kinc/Tools/krafix/krafix-linux64',
spawnargs: [
'glsl',
'/build/source/Shaders/common/Gizmo_overlay.frag.glsl',
'/build/source/build/krom/data/Gizmo_overlay.frag.glsl.temp',
'/build/source/build/temp',
'krom'
]
}
error: --- Error --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-build
builder for '/nix/store/6gvb0ysbk1ljwsqxxrrlgvrwbdl13v0w-armorpaint-20.01.drv' failed with exit code 1; last 10 log lines:
syscall: 'spawn /build/source/armorcore/Kinc/Tools/krafix/krafix-linux64',
path: '/build/source/armorcore/Kinc/Tools/krafix/krafix-linux64',
spawnargs: [
'glsl',
'/build/source/Shaders/common/Gizmo_overlay.frag.glsl',
'/build/source/build/krom/data/Gizmo_overlay.frag.glsl.temp',
'/build/source/build/temp',
'krom'
]
}