diff --git a/nix/noninteractive.nix b/nix/noninteractive.nix index d775beb..3d39182 100644 --- a/nix/noninteractive.nix +++ b/nix/noninteractive.nix @@ -1,13 +1,18 @@ # This module optimizes for non-interactive deployments by remove some store paths # which are primarily useful for interactive installations. -{ config, lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ disabledModules = [ # This module adds values to multiple lists (systemPackages, supportedFilesystems) # which are impossible/unpractical to remove, so we disable the entire module. "profiles/base.nix" ]; + imports = [ + ./zfs-minimal.nix + ]; + # among others, this prevents carrying a stdenv with gcc in the image system.extraDependencies = lib.mkForce [ ]; @@ -21,10 +26,6 @@ environment.defaultPackages = lib.mkForce [ pkgs.rsync pkgs.parted - (pkgs.zfs.override { - # this overrides saves 10MB - samba = pkgs.coreutils; - }) pkgs.gptfdisk ]; @@ -42,28 +43,9 @@ "vfat" "xfs" ]; - boot = { - kernelModules = [ - "zfs" - # we have to explicitly enable this, otherwise it is not loaded even when creating a raid: - # https://github.com/nix-community/nixos-anywhere/issues/249 - "dm-raid" - ]; - extraModulePackages = [ - (config.boot.kernelPackages.zfs.override { - inherit (config.boot.zfs) removeLinuxDRM; - }) - ]; - }; - - boot.kernelPatches = lib.optional (config.boot.zfs.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; - }; - }; - - networking.hostId = lib.mkDefault "8425e349"; + boot.kernelModules = [ + # we have to explicitly enable this, otherwise it is not loaded even when creating a raid: + # https://github.com/nix-community/nixos-anywhere/issues/249 + "dm-raid" + ]; } diff --git a/nix/zfs-minimal.nix b/nix/zfs-minimal.nix new file mode 100644 index 0000000..5674dc1 --- /dev/null +++ b/nix/zfs-minimal.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: +# incorperate a space-optimized version of zfs +let + zfs = pkgs.zfs.override { + # this overrides saves 10MB + samba = pkgs.coreutils; + }; +in +{ + services.udev.packages = [ zfs ]; # to hook zvol naming, etc. + # unsure if need this, but in future udev rules could potentially point to systemd services. + systemd.packages = [ zfs ]; + environment.defaultPackages = lib.mkForce [ zfs ]; # this merges with outer noninteractive module. + + boot.kernelModules = [ "zfs" ]; + boot.extraModulePackages = [ + (config.boot.kernelPackages.zfs.override { + inherit (config.boot.zfs) removeLinuxDRM; + }) + ]; + + boot.kernelPatches = lib.optional (config.boot.zfs.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; + }; + }; + + networking.hostId = lib.mkDefault "8425e349"; +}