let
pkgs = import <nixpkgs> {};
mkDerivation = import ./autotools.nix pkgs;
in mkDerivation rec {
name = "ds9.7.6";
buildInputs = with pkgs; [xorg.libX11 xorg.libX11.dev openssl gnutar binutils-unwrapped busybox gnumake gcc];
src = ./ds9.7.6.tar.gz;
}
along with the autotools.nex copied from nix-pills and the builder.sh:
set -e
unset PATH
for p in $buildInputs; do
export PATH=$p/bin${PATH:+:}$PATH
done
tar xvzf $src
cd SAOImageDS9
unix/configure
CC=gcc make
```,
(in this file I only stoped after make, for the make install is not available and need more operations).
though I have included xorg.libX11.dev in the buildInput set, the make still complained that:
fatal error: X11/Xlib.h: No such file or directory
So could anyone tell me how to tell the gcc where to find extra headers?
Thanks.
Thank you for your reply and I found it seems to be my fault. I updated my nix file and this error disappeared. However, it still cannot be compiled, because in the configure it assumed the openssl file to exist in some hardcoded position, i.e., /usr/…
Anyway I downloaded the binary and solved the shared lib problem, and it can run now.
“hints” are a lot more complicated if you don’t use the common tools
By setting the option builder, you’re throwing away all of the nice goodies that nixpkgs gives you.
I suggest you have a look at the nixpkgs manual: Nixpkgs 23.11 manual | Nix & NixOS
Here’s a partial work in progress, where I’ve managed to compile a lot, but it’s not completed yet:
{ stdenv, fetchurl,
xorg, openssl, fontconfig, libxml2, libxslt, perl,
gnumake, pkgconfig, autoconf,
} :
stdenv.mkDerivation rec {
version = "9.7.6";
name = "ds9-${version}";
src = ./ds9.7.6.tar.gz;
buildInputs = [ autoconf pkgconfig gnumake xorg.libX11 xorg.libX11.dev xorg.libX11.dev.out openssl openssl.dev fontconfig xorg.libXft libxml2.dev libxml2 xorg.libXScrnSaver libxslt perl ];
preConfigurePhases = [ "preconfigure" ];
preconfigure = ''
patchShebangs .
'';
configureScript = "unix/configure";
hardeningDisable = [ "all" ];
# Work around broken configure scripts by setting some environment variables to the exact paths...
with_ssldir = openssl.dev;
# especially tclxml should be ashamed...
with_xml2_config = "${libxml2.dev}/bin/xml2-config";
with_xslt_config = "${libxslt.dev}/bin/xslt-config";
}
Options are transformed into environment variables. I’m using that to set some variables that various broken configure scripts use to find things in fixed paths.
Yes, I tested. It can compile, but when running the ds9 command, it complains
application-specific initialization failed: Can't find a usable init.tcl in the following directories:
./zvfsmntpt/tcl8.6 /build/SAOImageDS9/lib/tcl8.6 /home/astrojhgu/ds91/result/lib/tcl8.6 /home/astrojhgu/ds91/lib/tcl8.6 /home/astrojhgu/ds91/result/library /home/astrojhgu/ds91/library /home/astrojhgu/ds91/tcl8.6.8/library /home/astrojhgu/tcl8.6.8/library
This probably means that Tcl wasn't installed properly.
Error in startup script: couldn't read file "./zvfsmntpt/library/ds9.tcl": no such file or directory
I tried to findout the reason, but no progress yet.
However, I find that if I run the building in a nix-shell:
That sounds like the application needs some wrappers to change it’s path or other dirty tricks to work around issues in the build process.
I’m only using the following two commands as “make install” complains that there is no rule to make install.
There are several problems with this program. It needs some bundled files installed in a relative nonstandard location. The following expression installs the program. Due to the hardcoded nonstandard relative path, the program works only when called from the package prefix. So I wrote a simple wrapper that changes to the store prefix and passes the arguments to the program there. If you need NixOS for astronomy, this works.
with import <nixpkgs> {};
stdenv.mkDerivation rec {
version = "8.0.1";
name = "ds9-${version}";
src = ./ds9.8.0.1.tar.gz;
buildInputs = [ zip tcl gnused autoconf pkgconfig gnumake xorg.libX11 xorg.libX11.dev xorg.libX11.dev.out openssl_1_0_2 openssl_1_0_2.dev fontconfig xorg.libXft libxml2.dev libxml2 xorg.libXScrnSaver libxslt perl ];
preConfigurePhases = [ "preconfigure" ];
preconfigure = ''
patchShebangs .
sed -i -e 's_I/usr/include/libxml2_I${libxml2.dev}/include/libxml2_g' tksao/configure
'';
# Right now we use the bundled libraries. DS9 is not security critical and is reliable as is, so it 's ok
# However, it does clutter your profile with that last dir.
# Install wrapper script:
ds9 =
''
#!/usr/bin/env bash
declare -a ARGS
COUNT=$#
for ((INDEX=0; INDEX<COUNT; ++INDEX))
do
ARG="$(realpath $(printf "%q" "$1"))"
ARGS[INDEX]="$(printf "%q" "$ARG")"
shift
done
$(cd @out@; ds9_bin $ARGS)
'';
passAsFile = [ "ds9" ];
installPhase = ''
mkdir -p $out/bin
cp -r bin/ $out/
mv $out/bin/ds9 $out/bin/ds9_bin
mkdir -p $out/lib
cp -r lib/ $out/
cp -r ds9/unix/zvfsmntpt $out/
cp "$ds9Path" $out/bin/ds9
chmod +x $out/bin/ds9
substituteAll $ds9Path $out/bin/ds9
'';
configureScript = "unix/configure";
hardeningDisable = [ "all" ];
# Work around broken configure scripts by setting some environment variables to the exact paths...
with_ssldir = openssl_1_0_2.dev;
# especially tclxml should be ashamed...
with_xml2_config = "${libxml2.dev}/bin/xml2-config";
with_xslt_config = "${libxslt.dev}/bin/xslt-config";
}