about summary refs log tree commit diff
path: root/nixos/modules/tasks/filesystems
diff options
context:
space:
mode:
authorRyan Lahfa <masterancpp@gmail.com>2023-07-08 14:41:00 +0200
committerGitHub <noreply@github.com>2023-07-08 14:41:00 +0200
commited2f00913041d44b90a818a49e4cff14cc2c04d0 (patch)
tree9f882882d5486854769f2b94392c9cb7b0d74e46 /nixos/modules/tasks/filesystems
parent7be83143e8a1ded323116175a67539dcbbe65bf3 (diff)
parentd4cab20b3a76fef4b9a487c37107df6351ebce33 (diff)
downloadnixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar.gz
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar.bz2
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar.lz
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar.xz
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.tar.zst
nixlib-ed2f00913041d44b90a818a49e4cff14cc2c04d0.zip
Merge pull request #237873 from Mic92/fix-aarch64-zfs
Diffstat (limited to 'nixos/modules/tasks/filesystems')
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix47
1 files changed, 44 insertions, 3 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index f18ab10bafd7..72b937f3732b 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -323,6 +323,30 @@ in
           Defaults to 0, which waits forever.
         '';
       };
+
+      removeLinuxDRM = lib.mkOption {
+        type = types.bool;
+        default = false;
+        description = lib.mdDoc ''
+          Linux 6.2 dropped some kernel symbols required on aarch64 required by zfs.
+          Enabling this option will bring them back to allow this kernel version.
+          Note that in some jurisdictions this may be illegal as it might be considered
+          removing copyright protection from the code.
+          See https://www.ifross.org/?q=en/artikel/ongoing-dispute-over-value-exportsymbolgpl-function for further information.
+
+          If configure your kernel package with `zfs.latestCompatibleLinuxPackages`, you will need to also pass removeLinuxDRM to that package like this:
+
+          ```
+          { pkgs, ... }: {
+            boot.kernelPackages = (pkgs.zfs.override {
+              removeLinuxDRM = pkgs.hostPlatform.isAarch64;
+            }).latestCompatibleLinuxPackages;
+
+            boot.zfs.removeLinuxDRM = true;
+          }
+          ```
+        '';
+      };
     };
 
     services.zfs.autoSnapshot = {
@@ -541,11 +565,13 @@ in
         # https://github.com/NixOS/nixpkgs/issues/106093
         kernelParams = lib.optionals (!config.boot.zfs.allowHibernation) [ "nohibernate" ];
 
-        extraModulePackages = [
-          (if config.boot.zfs.enableUnstable then
+        extraModulePackages = let
+          kernelPkg = if config.boot.zfs.enableUnstable then
             config.boot.kernelPackages.zfsUnstable
            else
-            config.boot.kernelPackages.zfs)
+            config.boot.kernelPackages.zfs;
+        in [
+          (kernelPkg.override { inherit (cfgZfs) removeLinuxDRM; })
         ];
       };
 
@@ -663,6 +689,21 @@ in
       services.udev.packages = [ cfgZfs.package ]; # to hook zvol naming, etc.
       systemd.packages = [ cfgZfs.package ];
 
+      # Export kernel_neon_* symbols again.
+      # This change is necessary until ZFS figures out a solution
+      # with upstream or in their build system to fill the gap for
+      # this symbol.
+      # In the meantime, we restore what was once a working piece of code
+      # in the kernel.
+      boot.kernelPatches = lib.optional (cfgZfs.removeLinuxDRM && pkgs.stdenv.hostPlatform.system == "aarch64-linux") {
+        name = "export-neon-symbols-as-gpl";
+        patch = pkgs.fetchpatch {
+          url = "https://github.com/torvalds/linux/commit/aaeca98456431a8d9382ecf48ac4843e252c07b3.patch";
+          hash = "sha256-L2g4G1tlWPIi/QRckMuHDcdWBcKpObSWSRTvbHRIwIk=";
+          revert = true;
+        };
+      };
+
       systemd.services = let
         createImportService' = pool: createImportService {
           inherit pool;