zowoq
2026-09-30 06:35:43 +10:00
parent f11be3deb3
commit d0bc1c7aa7
3 changed files with 36 additions and 58 deletions

View File

@@ -174,7 +174,7 @@ in
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${cfg.package}/bin/ras-mc-ctl --register-labels";
ExecStart = "${cfg.package}/bin/ras-mc-ctl dimm --register-labels";
RemainAfterExit = true;
};
};

View File

@@ -24,11 +24,13 @@
};
testScript = ''
import json
start_all()
machine.wait_for_unit("multi-user.target")
# confirm rasdaemon is running and has a valid database
# some disk errors detected in qemu for some reason ¯\_(ツ)_/¯
machine.wait_until_succeeds("ras-mc-ctl --errors | tee /dev/stderr | grep -q 'No .* errors.'")
errors = json.loads(machine.wait_until_succeeds("ras-mc-ctl database --errors --json"))
assert errors["records"] == []
# confirm the supplied labels text made it into the system
machine.succeed("grep -q 'vendor: none' /etc/ras/dimm_labels.d/labels >&2")
machine.shutdown()

View File

@@ -1,90 +1,67 @@
{
autoreconfHook,
cmocka,
dmidecode,
fetchFromGitHub,
lib,
libtraceevent,
meson,
ninja,
nix-update-script,
nixosTests,
pciutils,
perl,
pkg-config,
python3,
sqlite,
stdenv,
# Options
enableDmidecode ? stdenv.hostPlatform.isx86_64,
dmidecode,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "rasdaemon";
version = "0.8.5";
version = "1.0.0";
src = fetchFromGitHub {
owner = "mchehab";
repo = "rasdaemon";
tag = "v${finalAttrs.version}";
hash = "sha256-CN9fSo7CQFkbpxPRwFSNJovTJBAjqEhqQzwHfYirGmo=";
hash = "sha256-fSrGE6Y21+yGb8pYid+As3YHJ3g3820UmFU9rnxj5WU=";
};
__structuredAttrs = true;
strictDeps = true;
enableParallelBuilding = true;
nativeBuildInputs = [
autoreconfHook
meson
ninja
pkg-config
(python3.withPackages (p: [ p.sqlalchemy ]))
];
# don't add systemd, it isn't needed
buildInputs = [
libtraceevent
(perl.withPackages (
ps: with ps; [
DBDSQLite
]
))
pciutils
sqlite
]
++ lib.optionals enableDmidecode [
dmidecode
];
configureFlags = [
"--sysconfdir=/etc"
"--localstatedir=/var"
"--enable-all"
propagatedBuildInputs = [
(python3.withPackages (p: [ p.sqlalchemy ]))
];
# The installation attempts to create the following directories:
# /var/lib/rasdaemon
# location of the RAS event log generated by rasdaemon -r
# /etc/ras/dimm_labels.d
# location of the DIMM labels generated by ras-mc-ctl
# /etc/sysconfig/rasdaemon
# location of rasdaemon config file, currently only used for CE PFA config
# these are optional (for logging, DIMM label storage and user config)
# /var/lib/rasdaemon should be created by the NixOS module
# /etc/ras/dimm_labels.d should probably be generated,
# from user supplied content, in the NixOS module
# /etc/sysconfig/rasdaemon should be generated if there is user supplied content
# and default to $out/etc/sysconfig/rasdaemon which should hold the supplied default
# therefore, stripping these from the generated Makefile
# (needed in the config flags because those set where the tools look for these)
# easy way out, ends up installing /nix/store/...rasdaemon/bin in $out
checkInputs = [
cmocka
];
postPatch = ''
patchShebangs contrib/
substituteInPlace util/ras_dimm.py \
--replace-fail 'which("dmidecode")' '"${lib.getExe dmidecode}"'
substituteInPlace tests/test-db-cli.c \
--replace-fail "'%s/util/ras-mc-ctl.py'" "python3 '%s/util/ras-mc-ctl.py'"
'';
preConfigure = ''
substituteInPlace Makefile.am \
--replace-fail '"$(DESTDIR)@sysconfdir@/ras/dimm_labels.d"' '"$(prefix)@sysconfdir@/ras/dimm_labels.d"' \
--replace-fail '"$(DESTDIR)@SYSCONFDEFDIR@/rasdaemon"' '"$(prefix)@SYSCONFDEFDIR@/rasdaemon"' \
--replace-fail '"$(DESTDIR)@sysconfdir@/ras/triggers' '"$(prefix)@sysconfdir@/ras/triggers'
'';
mesonFlags = [
(lib.mesonEnable "mysql" false)
(lib.mesonEnable "postgresql" false)
];
outputs = [
"out"
@@ -93,17 +70,16 @@ stdenv.mkDerivation (finalAttrs: {
"inject"
];
doCheck = true;
postInstall = ''
install -Dm 0755 contrib/edac-fake-inject $inject/bin/edac-fake-inject
install -Dm 0755 contrib/edac-tests $inject/bin/edac-tests
# remove incorrectly installed meson file
rm $out/etc/ras/dimm_labels.d/meson.build
install -Dm 0755 ../contrib/edac-fake-inject $inject/bin/edac-fake-inject
install -Dm 0755 ../contrib/edac-tests $inject/bin/edac-tests
'';
postFixup = lib.optionalString enableDmidecode ''
substituteInPlace $out/bin/ras-mc-ctl \
--replace-fail 'find_prog ("dmidecode")' '"${dmidecode}/bin/dmidecode"'
'';
passthru.tests = nixosTests.rasdaemon;
passthru.tests = { inherit (nixosTests) rasdaemon; };
passthru.updateScript = nix-update-script { };