Workarounds to run updates with packages marked as broken

A new personal here, still trying to wrap my head around Nix :slight_smile:

This does not happen a lot but occasionally I will come across an error

.... package/default.nix is marked as broken, refusing to evaluate.

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

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

Truth is that I do not want to turn on allowBroken in my config. I like the stability that NixOS offers. However, that means I cannot run the switch to upgrade/update my system, or what I know of.

Is there a way to safely skip this package (and perhaps its dependencies) but running the update or should I just wait until this particular package is marked as OK again?

Thank you!

I’m assuming you don’t now about pinning a particular package- in which case-

  		some_dated_commit = fetchTarball 
			url = archiveUrlBuilder "<commit_id_from_github>";
			sha256 = "0000000000"

	nixpkgs.config = basePackageConfig // {
		packageOverrides = pkgs: { 
                    pinnedPackageSet1= import some_dated_commit { config = config.nixpkgs.config} 

# and then
environment.systemPackages = [ nixpkgs.pinnedPackageSet1.mybrokenPackage] ;

# mostly expository, I'm assuming you can fill syntax errors etc

If you do already know about pinning, have you considered using that to solve your problem?

1 Like

Thank you! I guess this is what an overlay is?

I’ve never used an overlay before (knowingly) so don’t know (but non-technically speaking we are overlaying nixpkgs with some extra “data”. That data is another version of nixpkgs, specifically pinned to a commit). Search keyword would be nixpkgs pinning