Merge pull request #21578 from Mic92/zfs

zfs: add unstable variant
This commit is contained in:
Jörg Thalheim 2017-01-05 12:52:56 +01:00 committed by GitHub
commit ca0d747d6d
5 changed files with 245 additions and 301 deletions

View File

@ -22,12 +22,18 @@ let
kernel = config.boot.kernelPackages;
splKernelPkg = kernel.spl;
zfsKernelPkg = kernel.zfs;
zfsUserPkg = pkgs.zfs;
packages = if config.boot.zfs.enableUnstable then {
spl = kernel.splUnstable;
zfs = kernel.zfsUnstable;
zfsUser = pkgs.zfsUnstable;
} else {
spl = kernel.spl;
zfs = kernel.zfs;
zfsUser = pkgs.zfs;
};
autosnapPkg = pkgs.zfstools.override {
zfs = zfsUserPkg;
zfs = packages.zfsUser;
};
zfsAutoSnap = "${autosnapPkg}/bin/zfs-auto-snapshot";
@ -54,6 +60,18 @@ in
options = {
boot.zfs = {
enableUnstable = mkOption {
type = types.bool;
default = false;
description = ''
Use the unstable zfs package. This might be an option, if the latest
kernel is not yet supported by a published release of ZFS. Enabling
this option will install a development version of ZFS on Linux. The
version will have already passed an extensive test suite, but it is
more likely to hit an undiscovered bug compared to running a released
version of ZFS on Linux.
'';
};
extraPools = mkOption {
type = types.listOf types.str;
@ -218,16 +236,16 @@ in
boot = {
kernelModules = [ "spl" "zfs" ] ;
extraModulePackages = [ splKernelPkg zfsKernelPkg ];
extraModulePackages = with packages; [ spl zfs ];
};
boot.initrd = mkIf inInitrd {
kernelModules = [ "spl" "zfs" ];
extraUtilsCommands =
''
copy_bin_and_libs ${zfsUserPkg}/sbin/zfs
copy_bin_and_libs ${zfsUserPkg}/sbin/zdb
copy_bin_and_libs ${zfsUserPkg}/sbin/zpool
copy_bin_and_libs ${packages.zfsUser}/sbin/zfs
copy_bin_and_libs ${packages.zfsUser}/sbin/zdb
copy_bin_and_libs ${packages.zfsUser}/sbin/zpool
'';
extraUtilsCommandsTest = mkIf inInitrd
''
@ -264,14 +282,14 @@ in
zfsSupport = true;
};
environment.etc."zfs/zed.d".source = "${zfsUserPkg}/etc/zfs/zed.d/*";
environment.etc."zfs/zed.d".source = "${packages.zfsUser}/etc/zfs/zed.d/*";
system.fsPackages = [ zfsUserPkg ]; # XXX: needed? zfs doesn't have (need) a fsck
environment.systemPackages = [ zfsUserPkg ]
system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
environment.systemPackages = [ packages.zfsUser ]
++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags
services.udev.packages = [ zfsUserPkg ]; # to hook zvol naming, etc.
systemd.packages = [ zfsUserPkg ];
services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc.
systemd.packages = [ packages.zfsUser ];
systemd.services = let
getPoolFilesystems = pool:
@ -298,7 +316,7 @@ in
RemainAfterExit = true;
};
script = ''
zpool_cmd="${zfsUserPkg}/sbin/zpool"
zpool_cmd="${packages.zfsUser}/sbin/zpool"
("$zpool_cmd" list "${pool}" >/dev/null) || "$zpool_cmd" import -d ${cfgZfs.devNodes} -N ${optionalString cfgZfs.forceImportAll "-f"} "${pool}"
'';
};
@ -314,7 +332,7 @@ in
RemainAfterExit = true;
};
script = ''
${zfsUserPkg}/sbin/zfs set nixos:shutdown-time="$(date)" "${pool}"
${packages.zfsUser}/sbin/zfs set nixos:shutdown-time="$(date)" "${pool}"
'';
};

View File

@ -9,21 +9,15 @@ with stdenv.lib;
let
buildKernel = any (n: n == configFile) [ "kernel" "all" ];
buildUser = any (n: n == configFile) [ "user" "all" ];
in
assert any (n: n == configFile) [ "kernel" "user" "all" ];
assert buildKernel -> kernel != null;
stdenv.mkDerivation rec {
common = { version, sha256 } @ args : stdenv.mkDerivation rec {
name = "spl-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
version = "0.6.5.8";
src = fetchFromGitHub {
owner = "zfsonlinux";
repo = "spl";
rev = "spl-${version}";
sha256 = "000yvaccqlkrq15sdz0734fp3lkmx58182cdcfpm4869i0q7rf0s";
inherit sha256;
};
patches = [ ./const.patch ./install_prefix.patch ];
@ -61,4 +55,18 @@ stdenv.mkDerivation rec {
license = licenses.gpl2Plus;
maintainers = with maintainers; [ jcumming wizeman wkennington fpletz ];
};
}
};
in
assert any (n: n == configFile) [ "kernel" "user" "all" ];
assert buildKernel -> kernel != null;
{
splStable = common {
version = "0.6.5.8";
sha256 = "000yvaccqlkrq15sdz0734fp3lkmx58182cdcfpm4869i0q7rf0s";
};
splUnstable = common {
version = "0.7.0-rc2";
sha256 = "1y7jlyj8jwgrgnd6hiabms5h9430b6wjbnr3pwb16mv40wns1i65";
};
}

View File

@ -1,39 +1,38 @@
{ stdenv, fetchFromGitHub, autoreconfHook, utillinux, nukeReferences, coreutils
{ stdenv, fetchFromGitHub, autoreconfHook, utillinux, nukeReferences, coreutils, fetchpatch
, configFile ? "all"
# Userspace dependencies
, zlib, libuuid, python
, zlib, libuuid, python, attr
# Kernel dependencies
, kernel ? null, spl ? null
, kernel ? null, spl ? null, splUnstable ? null
}:
with stdenv.lib;
let
buildKernel = any (n: n == configFile) [ "kernel" "all" ];
buildUser = any (n: n == configFile) [ "user" "all" ];
in
assert any (n: n == configFile) [ "kernel" "user" "all" ];
assert buildKernel -> kernel != null && spl != null;
stdenv.mkDerivation rec {
common = { version, sha256, extraPatches, spl, inkompatibleKernelVersion ? null } @ args:
if buildKernel &&
(inkompatibleKernelVersion != null) &&
versionAtLeast kernel.version inkompatibleKernelVersion then
throw "linux v${kernel.version} is not yet supported by zfsonlinux v${version}"
else stdenv.mkDerivation rec {
name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
version = "0.6.5.8";
src = fetchFromGitHub {
owner = "zfsonlinux";
repo = "zfs";
rev = "zfs-${version}";
sha256 = "0qccz1832p3i80qlrrrypypspb9sy9hmpgcfx9vmhnqmkf0yri4a";
inherit sha256;
};
patches = [ ./nix-build.patch ];
patches = extraPatches;
buildInputs = [ autoreconfHook nukeReferences ]
++ optionals buildKernel [ spl ]
++ optionals buildUser [ zlib libuuid python ];
++ optionals buildUser [ zlib libuuid python attr ];
# for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
NIX_CFLAGS_LINK = "-lgcc_s";
@ -114,4 +113,49 @@ stdenv.mkDerivation rec {
platforms = platforms.linux;
maintainers = with maintainers; [ jcumming wizeman wkennington fpletz ];
};
}
};
in
assert any (n: n == configFile) [ "kernel" "user" "all" ];
assert buildKernel -> kernel != null && spl != null;
{
# also check if kernel version constraints in
# ./nixos/modules/tasks/filesystems/zfs.nix needs
# to be adapted
zfsStable = common {
# comment/uncomment if breaking kernel versions are known
inkompatibleKernelVersion = "4.9";
version = "0.6.5.8";
# this package should point to the latest release.
sha256 = "0qccz1832p3i80qlrrrypypspb9sy9hmpgcfx9vmhnqmkf0yri4a";
extraPatches = [
(fetchpatch {
url = "https://github.com/Mic92/zfs/compare/zfs-0.6.5.8...nixos-zfs-0.6.5.8.patch";
sha256 = "14kqqphzg02m9a7qncdhff8958cfzdrvsid3vsrm9k75lqv1w08z";
})
];
inherit spl;
};
zfsUnstable = common {
# comment/uncomment if breaking kernel versions are known
inkompatibleKernelVersion = "4.10";
version = "0.7.0-rc2";
# this package should point to a version / git revision compatible with the latest kernel release
sha256 = "197y2jyav9h1ksri9kzqvrwmzpb58mlgw27vfvgd4bvxpwfxq53s";
extraPatches = [
(fetchpatch {
url = "https://github.com/Mic92/zfs/compare/zfs-0.7.0-rc2...nixos-zfs-0.7.0-rc2.patch";
sha256 = "1p33bwd6p5r5phbqb657x8h9x3bd012k2mdmbzgnb09drh9v0r82";
})
(fetchpatch {
name = "Kernel_4.9_zfs_aio_fsync_removal.patch";
url = "https://github.com/zfsonlinux/zfs/commit/99ca173929cb693012dabe98bcee4f12ec7e6e92.patch";
sha256 = "10npvpj52rpq88vdsn7zkdhx2lphzvqypsd9abdadjbqkwxld9la";
})
];
spl = splUnstable;
};
}

View File

@ -1,134 +0,0 @@
diff --git a/Makefile.am b/Makefile.am
index f8abb5f..82e8fb6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,10 +11,10 @@ endif
if CONFIG_KERNEL
SUBDIRS += module
-extradir = @prefix@/src/zfs-$(VERSION)
+extradir = @prefix@/libexec/zfs-$(VERSION)
extra_HEADERS = zfs.release.in zfs_config.h.in
-kerneldir = @prefix@/src/zfs-$(VERSION)/$(LINUX_VERSION)
+kerneldir = @prefix@/zfs-$(VERSION)/$(LINUX_VERSION)
nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
endif
diff --git a/include/Makefile.am b/include/Makefile.am
index a94cad5..a160fe2 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -29,6 +29,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include
+kerneldir = @prefix@/include
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
index 595d1db..d41375d 100644
--- a/include/linux/Makefile.am
+++ b/include/linux/Makefile.am
@@ -18,6 +18,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux
+kerneldir = @prefix@/include/linux
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am
index 77ecfb2..52b3612 100644
--- a/include/sys/Makefile.am
+++ b/include/sys/Makefile.am
@@ -114,6 +114,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys
+kerneldir = @prefix@/include/sys
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/include/sys/fm/Makefile.am b/include/sys/fm/Makefile.am
index 8bca5d8..a5eafcd 100644
--- a/include/sys/fm/Makefile.am
+++ b/include/sys/fm/Makefile.am
@@ -16,6 +16,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm
+kerneldir = @prefix@/include/sys/fm
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/include/sys/fm/fs/Makefile.am b/include/sys/fm/fs/Makefile.am
index fdc9eb5..807c47c 100644
--- a/include/sys/fm/fs/Makefile.am
+++ b/include/sys/fm/fs/Makefile.am
@@ -13,6 +13,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm/fs
+kerneldir = @prefix@/include/sys/fm/fs
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/include/sys/fs/Makefile.am b/include/sys/fs/Makefile.am
index 0859b9f..b0c6eec 100644
--- a/include/sys/fs/Makefile.am
+++ b/include/sys/fs/Makefile.am
@@ -13,6 +13,6 @@ libzfs_HEADERS = $(COMMON_H) $(USER_H)
endif
if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fs
+kerneldir = @prefix@/include/sys/fs
kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
endif
diff --git a/module/Makefile.in b/module/Makefile.in
index d4ddee2..876c811 100644
--- a/module/Makefile.in
+++ b/module/Makefile.in
@@ -18,9 +18,9 @@ modules:
@# installed devel headers, or they may be in the module
@# subdirectory when building against the spl source tree.
@if [ -f @SPL_OBJ@/@SPL_SYMBOLS@ ]; then \
- /bin/cp @SPL_OBJ@/@SPL_SYMBOLS@ .; \
+ cp @SPL_OBJ@/@SPL_SYMBOLS@ .; \
elif [ -f @SPL_OBJ@/module/@SPL_SYMBOLS@ ]; then \
- /bin/cp @SPL_OBJ@/module/@SPL_SYMBOLS@ .; \
+ cp @SPL_OBJ@/module/@SPL_SYMBOLS@ .; \
else \
echo -e "\n" \
"*** Missing spl symbols ensure you have built the spl:\n" \
@@ -28,6 +28,8 @@ modules:
"*** - @SPL_OBJ@/module/@SPL_SYMBOLS@\n"; \
exit 1; \
fi
+ @# when copying a file out of the nix store, we need to make it writable again.
+ chmod +w @SPL_SYMBOLS@
$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_ZFS=m $@
clean:
@@ -42,15 +44,15 @@ clean:
modules_install:
@# Install the kernel modules
$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \
- INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
+ INSTALL_MOD_PATH=@prefix@/$(INSTALL_MOD_PATH) \
INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
KERNELRELEASE=@LINUX_VERSION@
@# Remove extraneous build products when packaging
- kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
- if [ -n "$(DESTDIR)" ]; then \
+ kmoddir=@prefix@/$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
+ if [ -n "@prefix@" ]; then \
find $$kmoddir -name 'modules.*' | xargs $(RM); \
fi
- sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
+ sysmap=@prefix@/$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
if [ -f $$sysmap ]; then \
depmod -ae -F $$sysmap @LINUX_VERSION@; \
fi

View File

@ -11302,10 +11302,12 @@ in
seturgent = callPackage ../os-specific/linux/seturgent { };
spl = callPackage ../os-specific/linux/spl {
inherit (callPackage ../os-specific/linux/spl {
configFile = "kernel";
inherit kernel;
};
}) splStable splUnstable;
spl = splStable;
sysdig = callPackage ../os-specific/linux/sysdig {};
@ -11329,10 +11331,12 @@ in
x86_energy_perf_policy = callPackage ../os-specific/linux/x86_energy_perf_policy { };
zfs = callPackage ../os-specific/linux/zfs {
inherit (callPackage ../os-specific/linux/zfs {
configFile = "kernel";
inherit kernel spl;
};
}) zfsStable zfsUnstable;
zfs = zfsStable;
});
# The current default kernel / kernel modules.
@ -11641,9 +11645,11 @@ in
statifier = callPackage ../os-specific/linux/statifier { };
spl = callPackage ../os-specific/linux/spl {
inherit (callPackage ../os-specific/linux/spl {
configFile = "user";
};
}) splStable splUnstable;
spl = splStable;
sysdig = callPackage ../os-specific/linux/sysdig {
kernel = null;
@ -11847,9 +11853,11 @@ in
zd1211fw = callPackage ../os-specific/linux/firmware/zd1211 { };
zfs = callPackage ../os-specific/linux/zfs {
inherit (callPackage ../os-specific/linux/zfs {
configFile = "user";
};
}) zfsStable zfsUnstable;
zfs = zfsStable;
### DATA