Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs: fix evaluation and build on aarch64 systems #237873

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions nixos/modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -532,11 +556,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; })
];
};

Expand Down Expand Up @@ -654,6 +680,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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should only apply the patch if the kernel is at least 6.2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not possible to check the kernel version here. This will lead to infinite recursion.

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;
Expand Down
8 changes: 6 additions & 2 deletions pkgs/os-specific/linux/zfs/stable.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, kernel ? null
, stdenv
, linuxKernel
, removeLinuxDRM ? false
, ...
} @ args:

Expand All @@ -11,10 +12,13 @@ in
callPackage ./generic.nix args {
# check the release notes for compatible kernels
kernelCompatible =
if stdenv'.isx86_64
if stdenv'.isx86_64 || removeLinuxDRM
then kernel.kernelOlder "6.4"
else kernel.kernelOlder "6.2";
latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_3;
latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM then
linuxKernel.packages.linux_6_3
else
linuxKernel.packages.linux_6_1;

# this package should point to the latest release.
version = "2.1.12";
Expand Down
16 changes: 10 additions & 6 deletions pkgs/os-specific/linux/zfs/unstable.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, kernel ? null
, stdenv
, linuxKernel
, removeLinuxDRM ? false
, ...
} @ args:

Expand All @@ -13,19 +14,22 @@ callPackage ./generic.nix args {
# NOTE:
# zfs-2.1.9<=x<=2.1.10 is broken with aarch64-linux-6.2
# for future releases, please delete this condition.
kernelCompatible = if stdenv'.isx86_64
then kernel.kernelOlder "6.3"
kernelCompatible = if stdenv'.isx86_64 || removeLinuxDRM
then kernel.kernelOlder "6.4"
else kernel.kernelOlder "6.2";
latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_1;

latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM then
linuxKernel.packages.linux_6_3
else
linuxKernel.packages.linux_6_1;

# this package should point to a version / git revision compatible with the latest kernel release
# IMPORTANT: Always use a tagged release candidate or commits from the
# zfs-<version>-staging branch, because this is tested by the OpenZFS
# maintainers.
version = "2.1.12-staging-2023-04-18";
rev = "e25f9131d679692704c11dc0c1df6d4585b70c35";
version = "2.1.12";
Mic92 marked this conversation as resolved.
Show resolved Hide resolved

sha256 = "tJLwyqUj1l5F0WKZDeMGrEFa8fc/axKqm31xtN51a5M=";
sha256 = "eYUR5d4gpTrlFu6j1uL83DWL9uPGgAUDRdSEb73V5i4=";

isUnstable = true;
}