Overriding outdated sha256 hash for unityhub using overlays not working

Hello everyone, i’m completely new to nixos.
I tried to install unityhub from unstable and got an error:

hash mismatch in fixed-output derivation '/nix/store/9cqma387r5qxzgb0yp449bkw6ffaiy0n-UnityHub.AppImage':
  wanted: sha256:1rx7ih94ig3pd1yx1d3fpx7zpixq3j5birkpnzkh778qqsdrg0nf
  got:    sha256:05p5kqbwgqyk2aw2lix5dk1ql16aj6iczxrc63a1l0vj8wrha7z4

As i understood it means that package has outdated sha256. So i tried to override it. After googling i came up with this:

let 
  unstable = import (fetchTarball http://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
    overlays = [ (self: super: {
      unityhub-fixed = super.unityhub.overrideAttrs (oldAttrs: rec {
        src = super.fetchurl {  
          url = "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage";
          sha256 = "05p5kqbwgqyk2aw2lix5dk1ql16aj6iczxrc63a1l0vj8wrha7z4";
        };
      });
    }) ];

    config = {
      allowUnfree = true;
    };
  };
in {
   ...
   environment.systemPackages = with pkgs; [
    ...
    unstable.unityhub-fixed
    ...
  ];

I executed nix-collect-garbage first and tried to rebuild again, and noticed that now it use UnityHub.AppImage two times, nixos-rebuild even just hanged and i must to interrupt it.

I used nix-prefetch-url to check is AppImage downloadable and new hash is correct. After it tried again nixos-rebuild and still got this:

hash mismatch in fixed-output derivation '/nix/store/9cqma387r5qxzgb0yp449bkw6ffaiy0n-UnityHub.AppImage':
  wanted: sha256:1rx7ih94ig3pd1yx1d3fpx7zpixq3j5birkpnzkh778qqsdrg0nf
  got:    sha256:05p5kqbwgqyk2aw2lix5dk1ql16aj6iczxrc63a1l0vj8wrha7z4

So it’s not overrided by overlay? I tryed to change url to some gibberish in it and noticed that it’s still trying to build both AppImages:

building '/nix/store/7c34fp147wjvzip81y9fg7qdxf3sspng-UnityHub.AppImageWAT.drv'...
building '/nix/store/gbfzpqwjqajh08z5kd8nkijwvv6wff62-UnityHub.AppImage.drv'...

trying https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

trying https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImageWAT
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404 Not Found
error: cannot download UnityHub.AppImageWAT from any mirror

So, any help with that?

Would you mind share your configuration? I can’t figure out the problem here.

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:
let 
  unstable = import (fetchTarball http://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
    overlays = [ (self: super: {
      unityhub-fixed = super.unityhub.overrideAttrs (oldAttrs: rec {
        src = super.fetchurl {  
          url = "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage";
          sha256 = "05p5kqbwgqyk2aw2lix5dk1ql16aj6iczxrc63a1l0vj8wrha7z4";
        };
      });
    }) ];

    config = {
      allowUnfree = true;
    };
  };
in {
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.kernelPackages = pkgs.linuxPackages_latest;
  services.xserver.videoDrivers = [ "amdgpu" ];

  networking.hostName = "eklmv-nix"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
  networking.interfaces.enp3s0.useDHCP = true;
  networking.networkmanager.enable = true;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "us";
    defaultLocale = "en_US.UTF-8";
  };

  # Set your time zone.
  time.timeZone = "Europe/Moscow";

  nixpkgs.config.allowUnfree = true;
  virtualisation.virtualbox.host.enable = true;
  virtualisation.virtualbox.host.enableExtensionPack = true;
  users.extraGroups.vboxusers.members = [ "eklmv" ]; 

  #List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    wget
    zip
    unzip
    unrar
    p7zip
    ark
    vlc
        
    git
    vscode
    unstable.unityhub-fixed
    gimp

    keepass
    firefox
    okular
    steam
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = { enable = true; enableSSHSupport = true; };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;
  hardware.pulseaudio.support32Bit = true;
  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.extraPackages = with pkgs; [ libva ];  

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.layout = "us,ru";
  services.xserver.xkbOptions = "grp:alt_shift_toggle";

  # Enable touchpad support.
  # services.xserver.libinput.enable = true;

  # Enable the KDE Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.eklmv = {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user.
  };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "19.09"; # Did you read the comment?

}

I can reproduce the issue without the overlay and just the overrideAttrs. Since UnityHub is an AppImage it uses appimageTools.wrapType2 which may be why there are two unityhub packages? I’m not sure how .overrideAttrs behaves with that, but here’s the source of appimageTools for the curious.

That said, you can kind of hack around it by abusing the fact that fetchurl is passed to the derivation, but again it is a hack so I wouldn’t let my mother see this:

{ pkgs ? import <nixpkgs> {} }:

let
  fetchurl = _: pkgs.fetchurl {
    url = "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage";
    sha256 = "05p5kqbwgqyk2aw2lix5dk1ql16aj6iczxrc63a1l0vj8wrha7z4";
  };

  unityhub-fixed = pkgs.unityhub.override (_: { inherit fetchurl; });

in unityhub-fixed
1 Like

Thanks, it’s worked for me. Is there any need to create issue on github?

You can create an issue on GitHub, or just fix the sha and make a pull request so this gets fixed for everyone :wink: