smartmontools: update drivedb; move to github; support auto updates (#478194)

This commit is contained in:
Matt Sturgeon
2026-01-13 23:06:54 +00:00
committed by GitHub
2 changed files with 52 additions and 30 deletions
+50 -15
View File
@@ -1,23 +1,18 @@
{
lib,
stdenv,
fetchurl,
fetchFromGitHub,
autoreconfHook,
enableMail ? false,
gnused,
hostname,
mailutils,
systemdLibs,
writeShellScript,
nix-update,
}:
let
dbrev = "5714";
drivedbBranch = "RELEASE_7_5_DRIVEDB";
driverdb = fetchurl {
url = "https://sourceforge.net/p/smartmontools/code/${dbrev}/tree/branches/${drivedbBranch}/smartmontools/drivedb.h?format=raw";
sha256 = "sha256-DndzUHpZex3F9WXYq+kNDWvkLNc1OZX3KR0mby5cKbA=";
name = "smartmontools-drivedb.h";
};
scriptPath = lib.makeBinPath (
[
gnused
@@ -27,21 +22,26 @@ let
);
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "smartmontools";
version = "7.5";
src = fetchurl {
url = "mirror://sourceforge/smartmontools/${pname}-${version}.tar.gz";
hash = "sha256-aQuDyjMTeNqeoNnWEAjEsi3eOROHubutfyk4fyWV924=";
src = fetchFromGitHub {
owner = "smartmontools";
repo = "smartmontools";
tag = "RELEASE_${lib.replaceString "." "_" finalAttrs.version}";
hash = "sha256-/2J73F97yiPlUnGkzewWzU+sARaeqgVc/3ScjVlHhQE=";
};
prePatch = ''
cd smartmontools
'';
patches = [
# fixes darwin build
./smartmontools.patch
];
postPatch = ''
cp -v ${driverdb} drivedb.h
ln -sf "$drivedb" drivedb.h
'';
configureFlags = [
@@ -54,12 +54,47 @@ stdenv.mkDerivation rec {
buildInputs = lib.optionals (lib.meta.availableOn stdenv.hostPlatform systemdLibs) [ systemdLibs ];
enableParallelBuilding = true;
drivedb = fetchFromGitHub {
owner = "smartmontools";
repo = "smartmontools";
rev = "794fa5069ee298c82f93ff0a7f7ef6a5fdd10e5e";
hash = "sha256-WBed5elI+WsIiIJ1YVkdVGJ4XMrGRFIFWqk6ffVl0bU=";
postFetch = ''
mv "$out/smartmontools/drivedb.h" "$TMPDIR/drivedb.h"
rm -rf "$out"
mv "$TMPDIR/drivedb.h" "$out"
'';
passthru = {
# Necessary so that nix-update can update the drivedb
src = finalAttrs.drivedb;
pname = "smartmontools-drivedb";
version = "${finalAttrs.version}-drivedb-unstable";
};
};
passthru.updateScript = writeShellScript "update-smartmontools" ''
# Set a default attribute path
# When running maintainers/scripts/update.nix this is set automatically,
# but this allows running this update script directly.
UPDATE_NIX_ATTR_PATH="''${UPDATE_NIX_ATTR_PATH:-smartmontools}"
# Update smartmontools
${lib.getExe nix-update} "$UPDATE_NIX_ATTR_PATH" --version-regex 'RELEASE_(\d+)_(\d+)(?:_(\d+))?'
# Update drivedb.h
branch="origin/$(nix-instantiate --eval --raw --attr "$UPDATE_NIX_ATTR_PATH.src.tag")_DRIVEDB"
${lib.getExe nix-update} "$UPDATE_NIX_ATTR_PATH.drivedb" "--version=branch=$branch"
'';
meta = {
description = "Tools for monitoring the health of hard drives";
homepage = "https://www.smartmontools.org/";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ Frostman ];
maintainers = with lib.maintainers; [
Frostman
samasaur
];
platforms = with lib.platforms; linux ++ darwin;
mainProgram = "smartctl";
};
}
})
@@ -1,19 +1,6 @@
diff --git a/../smartmontools-6.5/configure b/./configure
index acb028a..5e2c7a1 100755
--- a/../smartmontools-6.5/configure
+++ b/./configure
@@ -6703,7 +6703,7 @@ fi
;;
*-*-darwin*)
os_deps='os_darwin.o'
- os_libs='-framework CoreFoundation -framework IOKit'
+ os_libs='-framework ApplicationServices -framework IOKit'
os_darwin=yes
os_man_filter=Darwin
;;
diff --git a/../smartmontools-6.5/configure.ac b/./configure.ac
diff --git a/./configure.ac b/./configure.ac
index 6bd61d7..32ff50c 100644
--- a/../smartmontools-6.5/configure.ac
--- a/./configure.ac
+++ b/./configure.ac
@@ -508,7 +508,7 @@ case "${host}" in
;;