Overriding `zfsUnstable` `meta.broken` is not working?

I’m trying to avoid a global nixpkgs.config.allowBroken = true.

  nixpkgs.overlays = lib.optional enableUnstableZfs (_: prev: {
    zfsUnstable = prev.zfsUnstable.overrideAttrs
      (old: lib.recursiveUpdate old { meta.broken = false; });
  });

This is at the top of my filesystems.nix#L21.

I still see the typical error.

building the system configuration...
error: Package ‘zfs-kernel-2.1.5-5.19.8’ in /nix/store/fr68dr66gmggn62jir7vp1bcnignwxp9-source/pkgs/os-specific/linux/zfs/default.nix:196 is marked as broken, refusing to evaluate.

       a) To temporarily allow broken packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_BROKEN=1

        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowBroken = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowBroken = true; }
       to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)

All of my other overrides work fine, is it something to do with this being set with a manually imported instance of nixpkgs?

I tried to also set boot.zfs.package, but the option is read-only. is there a way to override this?

I would also like to know why I can use config in my HM configuration, but not the NixOS configuration.

error: Module `/nix/store/l4brpwjfwylhx7zvci0i7schrb4f2ivy-source/system/filesystems.nix' has an unsupported attribute `boot'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: boot fileSystems services swapDevices) into the explicit `config' attribute.

It would be useful knowledge to know how to override options.

1 Like

That’s because the zfs package used doesn’t come from the top-level of nixpkgs, and in fact if you eval that one normally:

nix-repl> zfsUnstable.meta.broken
false

It’s not broken. The reason why it is marked as broken is because of the particular combination of your kernel version and zfs combined:

nix-repl> linuxPackages_latest.zfsUnstable.meta.broken
true

The package you want to target for override is boot.zfs.package, which, if you are using boot.kernelPackages = linuxPackages_latest, would be linuxPackages_latest.zfsUnstable, for example.

However, I don’t know for sure if it will actually work with 5.19 as I haven’t actually tested it, so I would advise caution. I myself have pinning my config to 5.18 for now until the next ZFS version is released.

1 Like

It works with 5.19.8. I’m using it. I know it doesn’t come from top-level, there’s a link to the relevant source. You can’t override boot.zfs.package. I already tried that. If you know how to override read-only config options, let me know.

I am misunderstanding how overlays work, again. I thought that if I put the overlay in config.overlays during my manual import, any time that derivation would be requested the overrides would take effect. Allegedly not the case.

That evaluation you did with the REPL returns false because it is not fulfilling any of the negative conditions for it to be otherwise.

I want to override this condition but can’t see a way to affect any of the variables that make the decision that the package is broken.

Didn’t realize it was read-only, however you can still just override the kernel specific package in an overlay.

Not quite in this case, since the derivation at the top-level and the one nested in the kernel packages are distinct from one another. You can still override a nested derivation, but it’s a bit more work. Something like:

{
  boot.kernelPackages = pkgs.linuxPackages_latest.extend (final: prev: {
    zfsUnstable = prev.zfsUnstable.overrideAttrs (self: {
      # override here
      meta = self.meta // { broken = false; };
    };
  });
}

Ah. I’ve seen this one before, actually. I didn’t realize that the package was re-exported by linuxPackages_latest, That is interesting. Would you mind pointing me at a line in the repository?

building the system configuration...
error: The option `boot.kernelPackages' is defined multiple times.

       Definition values:
       - In `/nix/store/7df9h8qqf4iwqx7jr78l16v87833nf40-source/system/filesystems.nix'
       - In `/nix/store/fr68dr66gmggn62jir7vp1bcnignwxp9-source/flake.nix'
(use '--show-trace' to show detailed location information)

That second flake (filesystems is in mine) is just nixpkgs itself.

This is interesting, when I use :l <nixpkgs>; pkgs.linuxPackages it spams a bunch of refusals to evaluate.

       a) To temporarily allow broken packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_BROKEN=1

Why does it do this in the REPL?

That is a bit strange, are you absolutely positive that is a reference to nixpkgs? I’ve never seen nix point to the flake.nix file before when this error surfaces. But assuming it is actually nixpkgs and there is genuinely nothing you can do (which should be reported and fixed eventually), in that case you could try boot.kernelPackages = lib.mkForce #... to force a higher priority.

If you just do that in the repl and ask it to eval the entire linuxPackages then it will evaluate everything in the top-level of that set, printing any warnings for each derivation that might have one along the way.

Definitely Nixpkgs.

# Experimental flake interface to Nixpkgs.
# See https://github.com/NixOS/rfcs/pull/49 for details.
{
  description = "A collection of packages for the Nix package manager";

  outputs = { self }:
    let
      jobs = import ./pkgs/top-level/release.nix {
        nixpkgs = self;
      };

      lib = import ./lib;

      forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f system);

    in
    {
      lib = lib.extend (final: prev: {

        nixos = import ./nixos/lib { lib = final; };

        nixosSystem = args:
          import ./nixos/lib/eval-config.nix (
            args // {
              modules = args.modules ++ [{
                system.nixos.versionSuffix =
                  ".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
                system.nixos.revision = final.mkIf (self ? rev) self.rev;
              }];
            } // lib.optionalAttrs (! args?system) {
              # Allow system to be set modularly in nixpkgs.system.
              # We set it to null, to remove the "legacy" entrypoint's
              # non-hermetic default.
              system = null;
            }
          );
      });

      checks.x86_64-linux.tarball = jobs.tarball;

      htmlDocs = {
        nixpkgsManual = jobs.manual;
        nixosManual = (import ./nixos/release-small.nix {
          nixpkgs = self;
        }).nixos.manual.x86_64-linux;
      };

      legacyPackages = forAllSystems (system: import ./. { inherit system; });

      nixosModules = {
        notDetected = import ./nixos/modules/installer/scan/not-detected.nix;
      };
    };
}

On a hunch, I commented out modules.lenovo-thinkpad-p14s-amd-gen2 from the nixos-hardware repository, and it started to build without complaint (using the override you provided).

1 Like

This seems like nothing, why do I have to use mkForce for this one?

What?? mkForce = mkOverride 50; Why is the lower number a higher priority, whereas mkOrder priority is increasing?

I’m having a hard time navigating the source for extend. Do you have a blog article?

Even better, I stole your idea for my own system :sweat_smile: