aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix72
1 files changed, 72 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix b/infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix
new file mode 100644
index 000000000000..c33aa074404f
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/tools/misc/memtest86-efi/default.nix
@@ -0,0 +1,72 @@
+{ stdenv
+, lib
+, fetchzip
+, utillinux
+, jq
+, mtools
+}:
+
+stdenv.mkDerivation rec {
+ pname = "memtest86-efi";
+ version = "8.3";
+
+ 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:
+ #
+ # 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.
+ url = "https://www.memtest86.com/downloads/memtest86-${version}-usb.zip";
+ sha256 = "0aldz7rvnfnzb4h447q10k9c9p5ghwzdyn7f6g5lrxiv5vxf3x96";
+ stripRoot = false;
+ };
+
+ nativeBuildInputs = [
+ utillinux
+ jq
+ mtools
+ ];
+
+ installPhase = ''
+ # 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/
+ '';
+
+ meta = with lib; {
+ homepage = "http://memtest86.com/";
+ downloadPage = "https://www.memtest86.com/download.htm";
+ description = "A tool to detect memory errors, to be run from a bootloader";
+ longDescription = ''
+ A UEFI app that is able to detect errors in RAM. It can be run from a
+ 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;
+ };
+}