nixpkgs-suyu/pkgs/tools/misc/memtest86-efi/default.nix

77 lines
2.5 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, fetchzip
2020-11-24 16:29:28 +01:00
, util-linux
, jq
, mtools
}:
2019-05-05 16:26:32 +02:00
stdenv.mkDerivation rec {
pname = "memtest86-efi";
2021-02-10 18:59:23 +01:00
version = "8.4";
2019-05-05 16:26:32 +02:00
src = fetchzip {
# TODO: We're using the previous version of memtest86 because the
# company developing memtest86 has stopped providing a versioned download
# link for the latest version:
#
2019-05-05 16:26:32 +02:00
# https://www.passmark.com/forum/memtest86/44494-version-8-1-distribution-file-is-not-versioned?p=44505#post44505
#
# However, versioned links for the previous version are available, so that
# is what is being used.
#
# It does look like redistribution is okay, so if we had somewhere to host
# binaries that we make sure to version, then we could probably keep up
# with the latest versions released by the company.
2019-05-05 16:26:32 +02:00
url = "https://www.memtest86.com/downloads/memtest86-${version}-usb.zip";
2021-02-10 18:59:23 +01:00
sha256 = "sha256-jh4FKCYZbOQhRv6B7N8Hmw6RQCQvbBGaGFTMLwM1nk8=";
stripRoot = false;
2019-05-05 16:26:32 +02:00
};
nativeBuildInputs = [
2020-11-24 16:29:28 +01:00
util-linux
jq
mtools
];
2019-05-05 16:26:32 +02:00
installPhase = ''
runHook preInstall
2019-05-05 16:26:32 +02:00
# memtest86 is distributed as a bootable USB image. It contains the actual
# memtest86 EFI app.
#
# The following uses sfdisk to calculate the offset of the FAT EFI System
# Partition in the disk image, and mcopy to extract the actual EFI app from
# the filesystem so that it can be installed directly on the hard drive.
IMG=$src/memtest86-usb.img
ESP_OFFSET=$(sfdisk --json $IMG | jq -r '
# Partition type GUID identifying EFI System Partitions
def ESP_GUID: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B";
.partitiontable |
.sectorsize * (.partitions[] | select(.type == ESP_GUID) | .start)
')
mkdir $out
mcopy -vsi $IMG@@$ESP_OFFSET ::'/EFI/BOOT/*' $out/
runHook postInstall
2019-05-05 16:26:32 +02:00
'';
meta = with lib; {
homepage = "http://memtest86.com/";
2019-05-05 16:26:32 +02:00
downloadPage = "https://www.memtest86.com/download.htm";
description = "A tool to detect memory errors, to be run from a bootloader";
longDescription = ''
2019-05-05 16:29:29 +02:00
A UEFI app that is able to detect errors in RAM. It can be run from a
2019-05-05 16:26:32 +02:00
bootloader. Released under a proprietary freeware license.
'';
# The Memtest86 License for the Free Edition states,
# "MemTest86 Free Edition is free to download with no restrictions on usage".
# However the source code for Memtest86 does not appear to be available.
#
# https://www.memtest86.com/license.htm
license = licenses.unfreeRedistributable;
maintainers = with maintainers; [ cdepillabout ];
platforms = platforms.linux;
};
}