indi-full: refactor 3rdparty drivers

This splits the 3rdparty drivers into seperate
packages as recommended by upstream. This also
allows to build a indi-full equivalent with only
the needed drivers. Also add indi-full-nonfree
with all the nonfree drivers. And remove them
from indi-full.
This commit is contained in:
Linus Karl 2023-10-29 22:01:59 +01:00
parent 8aaa39a2f2
commit d2367c3f7e
10 changed files with 1134 additions and 226 deletions

View File

@ -288,6 +288,10 @@
- `programs.vim.defaultEditor` now only works if `programs.vim.enable` is enabled.
- The `indi-full` package no longer contains non-free drivers.
To get the old collection of drivers use `indi-full-nonfree` or create your own collection of drivers by overriding indi-with-drivers.
E.g.: `pkgs.indi-with-drivers.override {extraDrivers = with pkgs.indi-3rdparty; [indi-gphoto];}`
- `/share/vim-plugins` now only gets linked if `programs.vim.enable` is enabled
- The `tracy` package no longer works on X11, since it's moved to Wayland

View File

@ -0,0 +1,15 @@
{
lib,
stdenv,
indi-3rdparty,
indilib,
indi-with-drivers,
}:
indi-with-drivers.override {
pname = "indi-full-nonfree";
inherit (indilib) version;
extraDrivers = builtins.filter (attrs: lib.meta.availableOn stdenv.hostPlatform attrs) (
builtins.attrValues indi-3rdparty
);
}

View File

@ -0,0 +1,23 @@
{
lib,
stdenv,
indi-3rdparty,
indi-with-drivers,
indilib,
}:
let
licenseFree = p: p.meta.license.free or false;
isFree =
p:
(builtins.all licenseFree ((p.buildInputs or [ ]) ++ (p.propagatedBuildInputs or [ ])))
&& licenseFree p;
drivers = builtins.filter (
attrs: isFree attrs && (lib.meta.availableOn stdenv.hostPlatform attrs)
) (builtins.attrValues indi-3rdparty);
in
indi-with-drivers.override {
pname = "indi-full";
inherit (indilib) version;
extraDrivers = drivers;
}

View File

@ -0,0 +1,24 @@
{
lib,
buildEnv,
makeBinaryWrapper,
indilib ? indilib,
pname ? "indi-with-drivers",
version ? indilib.version,
extraDrivers ? [ ],
}:
buildEnv {
name = "${pname}-${version}";
paths = [ indilib ] ++ extraDrivers;
nativeBuildInputs = [ makeBinaryWrapper ];
postBuild = lib.optionalString (extraDrivers != [ ]) ''
rm $out/bin/indiserver
makeBinaryWrapper ${indilib}/bin/indiserver $out/bin/indiserver --set-default INDIPREFIX $out
'';
inherit (indilib) meta;
}

View File

@ -81,7 +81,7 @@ stdenv.mkDerivation (finalAttrs: {
description = "Implementation of the INDI protocol for POSIX operating systems";
changelog = "https://github.com/indilib/indi/releases/tag/v${finalAttrs.version}";
license = licenses.lgpl2Plus;
maintainers = with maintainers; [ hjones2199 sheepforce ];
maintainers = with maintainers; [ hjones2199 sheepforce returntoreality ];
platforms = platforms.unix;
};
})

View File

@ -1,82 +0,0 @@
{ stdenv
, lib
, bash
, cmake
, cfitsio
, coreutils
, libusb1
, zlib
, boost
, libnova
, curl
, libjpeg
, gsl
, fftw
, indilib
, libgphoto2
, libraw
, libftdi1
, libdc1394
, gpsd
, ffmpeg
, version
, src
, autoPatchelfHook
}:
let
libusb-with-fxload = libusb1.override { withExamples = true;};
in
stdenv.mkDerivation rec {
pname = "indi-firmware";
inherit version src;
nativeBuildInputs = [ cmake autoPatchelfHook ];
buildInputs = [
indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd
libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw
];
cmakeFlags = [
"-DINDI_DATA_DIR=\${CMAKE_INSTALL_PREFIX}/share/indi"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
"-DRULES_INSTALL_DIR=lib/udev/rules.d"
"-DFIRMWARE_INSTALL_DIR=lib/firmware"
"-DQHY_FIRMWARE_INSTALL_DIR=\${CMAKE_INSTALL_PREFIX}/lib/firmware/qhy"
"-DCONF_DIR=etc"
"-DBUILD_LIBS=1"
"-DWITH_PENTAX=off"
"-DWITH_AHP_XC=off"
];
postPatch = ''
for f in {libfishcamp,libsbig,libqhy}/CMakeLists.txt
do
substituteInPlace $f --replace "/lib/firmware" "lib/firmware"
done
'';
postFixup = lib.optionalString stdenv.isLinux ''
for f in $out/lib/udev/rules.d/*.rules
do
substituteInPlace "$f" --replace "/sbin/fxload" "${libusb-with-fxload}/sbin/fxload" \
--replace "/bin/sleep" "${coreutils}/bin/sleep" \
--replace "/bin/cat" "${coreutils}/bin/cat" \
--replace "/bin/echo" "${coreutils}/bin/echo" \
--replace "/bin/sh" "${bash}/bin/sh" \
--replace "/lib/firmware/" "$out/lib/firmware/"
sed -e 's|-D $env{DEVNAME}|-p $env{BUSNUM},$env{DEVNUM}|' -i "$f"
done
'';
meta = with lib; {
homepage = "https://www.indilib.org/";
description = "Third party firmware for the INDI astronomical software suite";
changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}";
license = licenses.lgpl2Plus;
maintainers = with maintainers; [ hjones2199 sheepforce ];
platforms = platforms.linux;
};
}

View File

@ -1,29 +0,0 @@
{ stdenv, lib, callPackage, fetchFromGitHub, indilib }:
let
inherit (indilib) version;
indi-3rdparty-src = fetchFromGitHub {
owner = "indilib";
repo = "indi-3rdparty";
rev = "v${version}";
hash = "sha256-0M+k3A2Lw9EU9V5bX9dGztmdcJzc71XQZv8srmY5NmY=";
};
indi-firmware = callPackage ./indi-firmware.nix {
inherit version;
src = indi-3rdparty-src;
};
indi-3rdparty = callPackage ./indi-3rdparty.nix {
inherit version;
src = indi-3rdparty-src;
withFirmware = stdenv.isx86_64 || stdenv.isAarch64;
firmware = indi-firmware;
};
in
callPackage ./indi-with-drivers.nix {
pname = "indi-full";
inherit version;
extraDrivers = [
indi-3rdparty
] ++ lib.optional (stdenv.isx86_64 || stdenv.isAarch64) indi-firmware
;
}

View File

@ -1,18 +0,0 @@
{ buildEnv, makeBinaryWrapper, indilib ? indilib, pname ? "indi-with-drivers", version ? null, extraDrivers ? null }:
buildEnv {
name = "${pname}-${version}";
paths = [
indilib
]
++ extraDrivers;
nativeBuildInputs = [ makeBinaryWrapper ];
postBuild = ''
makeBinaryWrapper ${indilib}/bin/indiserver $out/bin/indiserver --set-default INDIPREFIX $out
'';
inherit (indilib) meta;
}

View File

@ -20942,7 +20942,7 @@ with pkgs;
indicator-sound-switcher = callPackage ../applications/audio/indicator-sound-switcher { };
indilib = darwin.apple_sdk_11_0.callPackage ../development/libraries/science/astronomy/indilib { };
indi-full = callPackage ../development/libraries/science/astronomy/indilib/indi-full.nix { };
indi-3rdparty = recurseIntoAttrs (callPackages ../development/libraries/science/astronomy/indilib/indi-3rdparty.nix { });
inih = callPackage ../development/libraries/inih { };