about summary refs log tree commit diff
path: root/pkgs/applications/virtualization
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2023-12-10 17:57:46 -0300
committerAnderson Torres <torres.anderson.85@protonmail.com>2023-12-11 08:22:52 -0300
commit799c6a1fc734cb2f330c5116bf50db1e57abeb65 (patch)
treef932a2cd0397c55502d10b5ee6af87578e897dbc /pkgs/applications/virtualization
parentf0d62e899b3c6a9e81ffab6332a1de388305f8fc (diff)
seabios: refactor
- finalAttrs design pattern
- split outputs
- generate config file instead of inlining it
- tag distribution in EXTRAVERSION
- install the Csm16.bin biosfile to $out/share/seabios/ instead of $out/
- remove nested with
- add myself as maintainer
Diffstat (limited to 'pkgs/applications/virtualization')
-rw-r--r--pkgs/applications/virtualization/seabios/default.nix71
1 files changed, 46 insertions, 25 deletions
diff --git a/pkgs/applications/virtualization/seabios/default.nix b/pkgs/applications/virtualization/seabios/default.nix
index 6f34017d295d6..cfe4b0eb974c3 100644
--- a/pkgs/applications/virtualization/seabios/default.nix
+++ b/pkgs/applications/virtualization/seabios/default.nix
@@ -1,50 +1,71 @@
-{ lib, stdenv, fetchgit, acpica-tools, python3 }:
-
-stdenv.mkDerivation rec {
+{ lib
+, stdenv
+, fetchgit
+, acpica-tools
+, python3
+, writeText
+}:
 
+stdenv.mkDerivation (finalAttrs: {
   pname = "seabios";
   version = "1.16.3";
 
   src = fetchgit {
     url = "https://git.seabios.org/seabios.git";
-    rev = "rel-${version}";
-    sha256 = "sha256-hWemj83cxdY8p+Jhkh5GcPvI0Sy5aKYZJCsKDjHTUUk=";
+    rev = "rel-${finalAttrs.version}";
+    hash = "sha256-hWemj83cxdY8p+Jhkh5GcPvI0Sy5aKYZJCsKDjHTUUk=";
   };
 
+  outputs = [ "out" "doc" ];
+
   nativeBuildInputs = [ python3 ];
 
   buildInputs = [ acpica-tools ];
 
   strictDeps = true;
 
-  hardeningDisable = [ "pic" "stackprotector" "fortify" ];
+  makeFlags = [
+    # https://www.seabios.org/Build_overview#Distribution_builds
+    "EXTRAVERSION=\"-nixpkgs\""
+  ];
 
-  configurePhase = ''
-    # build SeaBIOS for CSM
-    cat > .config << EOF
-    CONFIG_CSM=y
-    CONFIG_QEMU_HARDWARE=y
-    CONFIG_PERMIT_UNALIGNED_PCIROM=y
-    EOF
+  hardeningDisable = [ "pic" "stackprotector" "fortify" ];
 
+  postConfigure = let
+    config = writeText "config.txt" (lib.generators.toKeyValue { } {
+      # SeaBIOS with CSM (Compatible Support Module) support; learn more at
+      # https://www.electronicshub.org/what-is-csm-bios/
+      "CONFIG_CSM" = "y";
+      "CONFIG_PERMIT_UNALIGNED_PCIROM" = "y";
+      "CONFIG_QEMU_HARDWARE" = "y";
+    });
+  in ''
+    cp ${config} .config
     make olddefconfig
   '';
 
   installPhase = ''
-    mkdir $out
-    cp out/Csm16.bin $out/Csm16.bin
+    runHook preInstall
+
+    mkdir -pv $doc/share/doc/seabios-${finalAttrs.version}/
+    cp -v docs/* $doc/share/doc/seabios-${finalAttrs.version}/
+    install -Dm644 out/Csm16.bin -t $out/share/seabios/
+
+    runHook postInstall
   '';
 
-  meta = with lib; {
-    description = "Open source implementation of a 16bit X86 BIOS";
+  meta = {
+    homepage = "https://www.seabios.org";
+    description = "Open source implementation of a 16bit x86 BIOS";
     longDescription = ''
-      SeaBIOS is an open source implementation of a 16bit X86 BIOS.
-      It can run in an emulator or it can run natively on X86 hardware with the use of coreboot.
-      SeaBIOS is the default BIOS for QEMU and KVM.
+      SeaBIOS is an open source implementation of a 16bit x86 BIOS.
+      It can run in an emulator or it can run natively on x86 hardware with the
+      use of coreboot.
     '';
-    homepage = "http://www.seabios.org";
-    license = licenses.lgpl3;
-    maintainers = with maintainers; [ ];
-    platforms = [ "i686-linux" "x86_64-linux" ];
+    license = with lib.licenses; [ lgpl3Plus ];
+    maintainers = with lib.maintainers; [ AndersonTorres ];
+    platforms = lib.systems.inspect.patternLogicalAnd
+      lib.systems.inspect.patterns.isUnix
+      lib.systems.inspect.patterns.isx86;
   };
-}
+})