How to disable zfs for custom install image?

Hi there,

$ uname -a
Linux aermlich 6.2.8 #1-NixOS SMP Wed Mar 22 12:38:11 UTC 2023 aarch64 GNU/Linux

i try to build a installation image for my thinkpad x13s. But while building the image i get:

error: Package ‘zfs-kernel-2.1.9-6.2.8-x13s’ in /home/***/nixpkgs/pkgs/os-specific/linux/zfs/default.nix:196 is marked as broken, refusing to evaluate.

which is fine, i do not need zfs, but disabling zfs does not work? Or, i guess i am just doing it wrong? I tried:

boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
boot.initrd.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
# boot.zfs.enabled = false;

But it still gets pulled in, i am a beginner with nix, so i am still struggling with the nix language which at first glance is not very intuitive.

What is frustrating, the one very intuitive option:

boot.zfs.enabled = false;

does not work. I get the following error message:

error: The option `boot.zfs.enabled' is read-only, but it's set multiple times. Definition values:
       - In `/home/***/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix': true
       - In `/home/***/custom-install.nix': false

I am still at the very beginning of understanding nix, so this is probably a very obvious mistake. I am thankful for every response, hint and tip.

Thanks

custom-image.nix
# This module defines a NixOS installation CD that contains X11 and
# Plasma 5.

{ pkgs, lib, ... }:

{
  imports = [ ./nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix ];

  nixpkgs.config.allowUnfree = true;

  isoImage.edition = "plasma5";

  services.xserver = {
    desktopManager.plasma5 = {
      enable = true;
    };

    # Automatically login as nixos.
    displayManager = {
      sddm.enable = true;
      autoLogin = {
        enable = true;
        user = "nixos";
      };
    };
  };

  environment.systemPackages = with pkgs; [
    # Graphical text editor
    kate
  ];

  boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
  boot.initrd.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];

  system.activationScripts.installerDesktop = let

    # Comes from documentation.nix when xserver and nixos.enable are true.
    manualDesktopFile = "/run/current-system/sw/share/applications/nixos-manual.desktop";

    homeDir = "/home/nixos/";
    desktopDir = homeDir + "Desktop/";

  in ''
    mkdir -p ${desktopDir}
    chown nixos ${homeDir} ${desktopDir}

    ln -sfT ${manualDesktopFile} ${desktopDir + "nixos-manual.desktop"}
    ln -sfT ${pkgs.gparted}/share/applications/gparted.desktop ${desktopDir + "gparted.desktop"}
    ln -sfT ${pkgs.konsole}/share/applications/org.kde.konsole.desktop ${desktopDir + "org.kde.konsole.desktop"}
    ln -sfT ${pkgs.calamares-nixos}/share/applications/io.calamares.calamares.desktop ${desktopDir + "io.calamares.calamares.desktop"}
  '';

  boot.loader.systemd-boot.enable = false;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  boot.loader.grub = {
    efiSupport = true;
    efiInstallAsRemovable = true;
    device = "nodev";
  };

  boot.zfs.enabled = false;

  boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_6_2.override {
    argsOverride = rec {
      src = pkgs.fetchFromGitHub {
        owner = "steev";
        repo = "linux";
        rev = "lenovo-x13s-linux-6.2.y";
        sha256 = "sha256-//D7/9sDm7TYUG5bQV/WZ3DjT9cF7O8/e5R78h69MC0=";
      };
      version = "${pkgs.linux_6_2.version}-x13s";
      defconfig = "laptop_defconfig";
      extraConfig = ''
        CONFIG_SECCOMP y
      '';
    };
  });

  # hardware.deviceTree.enable = true;
  # hardware.deviceTree.name = "qcom/sc8280xp-lenovo-thinkpad-x13s.dtb";

  boot.initrd.availableKernelModules = [
    "nls_ascii" "snd_soc_hdmi_codec" "snd_soc_core" "snd_compress"
    "snd_pcm_dmaengine" "snd_pcm" "snd_timer" "snd" "soundcore" "qrtr_smd"
    "btqcomsmd"
    "extcon-qcom-spmi-misc"
    "qcom-spmi-adc5"
    "qcom-spmi-iadc"
    "qcom-spmi-vadc"
    "qcom-vadc-common"
    "qcom-emac"
    "dwmac-qcom-ethqos"
    "phy-qcom-apq8064-sata"
    "phy-qcom-ipq806x-sata"
    "qcom-pon"
    "qcom_battmgr"
    "qcom_smbb"
    "qcom_common"
    "qcom_pil_info"
    "qcom_q6v5"
    "qcom_q6v5_mss"
    "qcom_q6v5_pas"
    "qcom_sysmon"
    "slim-qcom-ctrl"
    "slim-qcom-ngd-ctrl"
    "qcom_gsbi"
    "soundwire-qcom"
    "qcom-spmi-adc-tm5"
    "qcom-spmi-temp-alarm"
    "snd-soc-qcom-common"
    "qcom_battmgr"
    "algif_aead" "des_generic"
    "joydev"
    "msm"
    "ath11k_pci"
    "qcom_pon"
    "ath11k"
    "ocmem"
    "sha1_ce" "gpu_sched" "mac80211"
    "libarc4" "mhi" "qcom_q6v5_pas" "qcom_pil_info" "qcom_q6v5" "qcom_sysmon" "qcom_common" "mdt_loader"
    "qrtr"
    "cfg80211" "rfkill" "sch_fq_codel" "pkcs8_key_parser" "fuse"
    "ip_tables" "x_tables"
    "overlay" "erofs" "libcrc32c"
    "isofs" "cdrom" "uas"
    "hid_multitouch"
    "dm_mod"
    "dm_crypt"
  ];

  boot.initrd.kernelModules = [
    "nls_ascii" "snd_soc_hdmi_codec" "snd_soc_core" "snd_compress"
    "snd_pcm_dmaengine" "snd_pcm" "snd_timer" "snd" "soundcore" "qrtr_smd"
    "btqcomsmd"
    "extcon-qcom-spmi-misc"
    "qcom-spmi-adc5"
    "qcom-spmi-iadc"
    "qcom-spmi-vadc"
    "qcom-vadc-common"
    "qcom-emac"
    "dwmac-qcom-ethqos"
    "phy-qcom-apq8064-sata"
    "phy-qcom-ipq806x-sata"
    "qcom-pon"
    "qcom_battmgr"
    "qcom_smbb"
    "qcom_common"
    "qcom_pil_info"
    "qcom_q6v5"
    "qcom_q6v5_mss"
    "qcom_q6v5_pas"
    "qcom_sysmon"
    "slim-qcom-ctrl"
    "slim-qcom-ngd-ctrl"
    "qcom_gsbi"
    "soundwire-qcom"
    "qcom-spmi-adc-tm5"
    "qcom-spmi-temp-alarm"
    "snd-soc-qcom-common"
    "qcom_battmgr"
    "algif_aead" "des_generic"
    "joydev"
    "msm"
    "ath11k_pci"
    "qcom_pon"
    "ath11k"
    "ocmem"
    "sha1_ce" "gpu_sched" "mac80211"
    "libarc4" "mhi" "qcom_q6v5_pas" "qcom_pil_info" "qcom_q6v5" "qcom_sysmon" "qcom_common" "mdt_loader"
    "qrtr"
    "cfg80211" "rfkill" "sch_fq_codel" "pkcs8_key_parser" "fuse"
    "ip_tables" "x_tables"
    "overlay" "erofs" "libcrc32c"
    "isofs" "cdrom" "uas"
    "hid_multitouch"
    "dm_mod"
    "dm_crypt"
  ];

  boot.kernelParams = [
    "efi=novamap,noruntime" "earlyprintk=efi" "loglevel=7" "console=tty0"
    "clk_ignore_unused"
  ];

}
{ pkgs, lib, ... }:

{
  imports = [ ./nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-plasma5.nix ];

  boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_6_2.override {
    argsOverride = rec {
      src = pkgs.fetchFromGitHub {
        owner = "steev";
        repo = "linux";
        rev = "lenovo-x13s-linux-6.2.y";
        sha256 = "sha256-//D7/9sDm7TYUG5bQV/WZ3DjT9cF7O8/e5R78h69MC0=";
      };
      version = "${pkgs.linux_6_2.version}-x13s";
      defconfig = "laptop_defconfig";
      extraConfig = ''
        CONFIG_SECCOMP y
      '';
    };
  });

  boot.supportedFilesystems = lib.mkForce [ "btrfs" "cifs" "f2fs" "jfs" "ntfs" "reiserfs" "vfat" "xfs" ];
}

This should be enough to build the ISO with custom kernel (assuming your kernel expression is correct). Don’t forget to also include your custom kernel to your configuration before running nixos-install.

@misuzu I don’t think this addresses the issue. This will still try to include ZFS, which doesn’t support kernel 6.2 yet, so it will still fail to evaluate.

NixOS does package an ISO that disables ZFS in order to have the newest kernel when ZFS doesn’t support it. Here’s the module that does it: https://github.com/NixOS/nixpkgs/blob/f8efa87fb581c6a63eca14a552988bbb097af4ed/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix

EDIT: Whoops, I missed that you forcefully overrode the supportedFileSystems attribute. That line alone might do it too, but is a little hostile to modules that want to be adding to supportedFileSystems :slight_smile:

2 Likes

Thanks, “lib.mkForce” did the trick. But it feels unintuitive, i am not sure why my explicitly defined list needs a force of some kind.

I guess i have to look into the nix interpreter/package manager code to get more comfortable with that.

Thanks, this solution looks interesting, but at my current level it creates more questions then it answers.

I really have to look into the interpreter/package manager code i guess. :slight_smile:

6 posts were split to a new topic: Lenovo X13s experience and support

I was also confused about why my images contained the ZFS kernel module but my config didn’t.

Lists are merged together by the module system.

You set: boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
But because you’re also importing nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix that imports multiple files. You’ll eventually find nixos/modules/profiles/base.nix which also sets boot.supportedFilesystems.

I can highly recommend using nix repl or tools like nix-inspect to inspect the config attrset and see the “actual” values.

btw nowadays you can disable ZFS with boot.supportedFilesystems.zfs = lib.mkForce false;. The option used to be a list of file systems, but now it’s an attrset of booleans so you can override specific file systems (and you can still set it to a list; this just gets coerced into the equivalent attrset definition).

2 Likes