lm_sensors: fix build, split outputs, modernize and remove perl from library closure (#373242)

authored by

Ramses and committed by
GitHub
322147e3 7d0f11e5

+51 -22
+3 -4
pkgs/by-name/fa/fan2go/package.nix
··· 18 18 19 19 vendorHash = "sha256-ad0e/cxbcU/KfPDOdD46KdCcvns83dgGDAyLLQiGyiA="; 20 20 21 + buildInputs = [ lm_sensors ]; 22 + 21 23 postConfigure = '' 22 24 substituteInPlace vendor/github.com/md14454/gosensors/gosensors.go \ 23 - --replace-fail '"/etc/sensors3.conf"' '"${lm_sensors}/etc/sensors3.conf"' 25 + --replace-fail '"/etc/sensors3.conf"' '"${lib.getLib lm_sensors}/etc/sensors3.conf"' 24 26 25 27 # Uses /usr/bin/echo, and even if we patch that, it refuses to execute any 26 28 # binary without being able to confirm that it's owned by root, which isn't 27 29 # possible under the sandbox. 28 30 rm internal/fans/cmd_test.go 29 31 ''; 30 - 31 - CGO_CFLAGS = "-I ${lm_sensors}/include"; 32 - CGO_LDFLAGS = "-L ${lm_sensors}/lib"; 33 32 34 33 meta = with lib; { 35 34 description = "Simple daemon providing dynamic fan speed control based on temperature sensors";
+47 -17
pkgs/by-name/lm/lm_sensors/package.nix
··· 2 2 lib, 3 3 stdenv, 4 4 fetchFromGitHub, 5 + fetchpatch, 5 6 bash, 6 7 bison, 7 8 flex, 8 9 which, 9 10 perl, 11 + rrdtool, 10 12 sensord ? false, 11 - rrdtool ? null, 12 13 }: 13 14 14 - assert sensord -> rrdtool != null; 15 + let 16 + version = "3.6.0"; 17 + tag = lib.replaceStrings [ "." ] [ "-" ] version; 18 + in 15 19 16 - stdenv.mkDerivation rec { 20 + stdenv.mkDerivation { 17 21 pname = "lm-sensors"; 18 - version = "3.6.0"; 19 - dashedVersion = lib.replaceStrings [ "." ] [ "-" ] version; 22 + inherit version; 20 23 21 24 src = fetchFromGitHub { 22 25 owner = "lm-sensors"; 23 26 repo = "lm-sensors"; 24 - rev = "V${dashedVersion}"; 27 + inherit tag; 25 28 hash = "sha256-9lfHCcODlS7sZMjQhK0yQcCBEoGyZOChx/oM0CU37sY="; 26 29 }; 30 + 31 + patches = [ 32 + # Fix compile failure on GCC 14 with `sensord` enabled. 33 + # From: https://github.com/lm-sensors/lm-sensors/pull/483 34 + (fetchpatch { 35 + url = "https://github.com/lm-sensors/lm-sensors/pull/483/commits/7a6170f07d05cc6601b4668f211e9389f2e75286.patch"; 36 + hash = "sha256-Q49quv3eXeMvY3jgZFs/F7Rljbq4YyehIDIlsgmloBQ="; 37 + }) 38 + ]; 39 + 40 + outputs = [ 41 + "bin" 42 + "out" 43 + "dev" 44 + "man" 45 + "doc" 46 + ]; 27 47 28 48 # Upstream build system have knob to enable and disable building of static 29 49 # library, shared library is built unconditionally. 30 50 postPatch = lib.optionalString stdenv.hostPlatform.isStatic '' 31 51 sed -i 'lib/Module.mk' -e '/LIBTARGETS :=/,+1d; /-m 755/ d' 32 - substituteInPlace prog/sensors/Module.mk --replace 'lib/$(LIBSHBASENAME)' "" 52 + substituteInPlace prog/sensors/Module.mk \ 53 + --replace-fail 'lib/$(LIBSHBASENAME)' "" 33 54 ''; 34 55 35 56 nativeBuildInputs = [ ··· 37 58 flex 38 59 which 39 60 ]; 61 + 40 62 # bash is required for correctly replacing the shebangs in all tools for cross-compilation. 41 63 buildInputs = [ 42 64 bash ··· 45 67 46 68 makeFlags = [ 47 69 "PREFIX=${placeholder "out"}" 70 + "BINDIR=${placeholder "bin"}/bin" 71 + "SBINDIR=${placeholder "bin"}/bin" 72 + "INCLUDEDIR=${placeholder "dev"}/include" 73 + "MANDIR=${placeholder "man"}/share/man" 74 + # This is a dependency of the library. 75 + "ETCDIR=${placeholder "out"}/etc" 76 + 48 77 "CC=${stdenv.cc.targetPrefix}cc" 49 78 "AR=${stdenv.cc.targetPrefix}ar" 50 79 ] ++ lib.optional sensord "PROG_EXTRA=sensord"; 51 80 52 - installFlags = [ 53 - "ETCDIR=${placeholder "out"}/etc" 54 - ]; 81 + enableParallelBuilding = true; 55 82 56 83 # Making regexp to patch-out installing of .so symlinks from Makefile is 57 84 # complicated, it is easier to remove them post-install. 58 85 postInstall = 59 86 '' 60 - mkdir -p $out/share/doc/${pname} 61 - cp -r configs doc/* $out/share/doc/${pname} 87 + mkdir -p $doc/share/doc/lm_sensors 88 + cp -r configs doc/* $doc/share/doc/lm_sensors 62 89 '' 63 90 + lib.optionalString stdenv.hostPlatform.isStatic '' 64 91 rm $out/lib/*.so* 65 92 ''; 66 93 67 - meta = with lib; { 94 + meta = { 68 95 homepage = "https://hwmon.wiki.kernel.org/lm_sensors"; 69 - changelog = "https://raw.githubusercontent.com/lm-sensors/lm-sensors/V${dashedVersion}/CHANGES"; 96 + changelog = "https://raw.githubusercontent.com/lm-sensors/lm-sensors/${tag}/CHANGES"; 70 97 description = "Tools for reading hardware sensors"; 71 - license = with licenses; [ 98 + license = with lib.licenses; [ 72 99 lgpl21Plus 73 100 gpl2Plus 74 101 ]; 75 - maintainers = with maintainers; [ pmy ]; 76 - platforms = platforms.linux; 102 + maintainers = with lib.maintainers; [ 103 + pmy 104 + oxalica 105 + ]; 106 + platforms = lib.platforms.linux; 77 107 mainProgram = "sensors"; 78 108 }; 79 109 }
+1 -1
pkgs/tools/system/htop/default.nix
··· 67 67 optionalPatch = pred: so: lib.optionalString pred "patchelf --add-needed ${so} $out/bin/htop"; 68 68 in 69 69 lib.optionalString (!stdenv.hostPlatform.isStatic) '' 70 - ${optionalPatch sensorsSupport "${lm_sensors}/lib/libsensors.so"} 70 + ${optionalPatch sensorsSupport "${lib.getLib lm_sensors}/lib/libsensors.so"} 71 71 ${optionalPatch systemdSupport "${systemd}/lib/libsystemd.so"} 72 72 ''; 73 73