Installing the latest/master Hyprland on 24.05

After setting up cachix, the Hyprland wiki says to use:

# configuration.nix

{pkgs, ...}: let
  flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz";

  hyprland = (import flake-compat {
    src = builtins.fetchTarball "https://github.com/hyprwm/Hyprland/archive/main.tar.gz";
  }).defaultNix;
in {
  programs.hyprland = {
    enable = true;
    # set the flake package
    package = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
    # make sure to also set the portal package, so that they are in sync
    portalPackage = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
  };
}

But that just gives me the following error:
error: in pure evaluation mode, 'fetchTarball' requires a 'sha256' argument

Is there a better method to use in NixOS to get the latest version of hyprland on 24.05? If not, where do I put the ‘sha256’ argument missing from the wiki’s instructions?

Hi, with flakes it would be easier to update your system without having to set the hash manually every time hyprland is updated, but except that I think it’s fine.

You should first put a fake hash:

{pkgs, ...}: let
  flake-compat = (builtins.fetchTarball {
    url = "https://github.com/edolstra/flake-compat/archive/master.tar.gz";
    sha256 = lib.fakeHash;
  }) {};

  hyprland = (import flake-compat {
    src = (builtins.fetchTarball {
      url = "https://github.com/hyprwm/Hyprland/archive/main.tar.gz";
      sha256 = lib.fakeHash;
    }) {};
  }).defaultNix;
in ...

Than rebuild, it will fail but gives you the current hash to copy in your config. Havent tested this code, I hope I didn’t miss something :slight_smile:

I noticed that the hyprland repo has a flake.nix file. How would I set this up to use the flake and avoid having to update the hash every time hyprland updates?

Flakes pins all your dependencies versions in a lockfile (flake.lock), you can update them running nix flake update.

Hyprland provides some package overlays, here is how your flake.nix would look like (it also includes home-manager which is useful to configure hyprland):

{
  inputs = {
    home-manager.url = "github:nix-community/home-manager/release-24.05";
    hyprland.url = "git+https://github.com/hyprwm/hyprland?submodules=1";
    nixpkgs.url = "nixpkgs/nixos-24.05";
  };

  outputs = { home-manager, hyprland, nixpkgs, ... }:
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      overlays = [ hyprland.overlays.hyprland-packages ];
      # config.allowunfree = true;
    };

  in {
    nixosconfigurations = {
      yourhostname = nixpkgs.lib.nixossystem {
        inherit pkgs system;
        modules = [
          ./configuration.nix
          home-manager.nixosmodules.home-manager {
            home-manager.useglobalpkgs = true;
            home-manager.useuserpackages = true;
            home-manager.users.yourUsername.imports = [ ./home.nix ];
          }
        ];
      };
    };
  };
}

Watch out for some of caps here (correction to above post):

          home-manager.nixosModules.home-manager {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users."guttermonk" = import ./home.nix; # CHANGE ME - USERNAME
            home-manager.extraSpecialArgs = {
              inherit inputs;
              inherit hyprland;
            };
          }

Also still struggling through this libinput issue. The instructions for this are difficult to tailor for everyone’s unique setup. I wouldn’t recommend going down this path if you’re a new user like me.

Currently getting this error:

error: The option `additions' does not exist. Definition values:
       - In `/nix/store/lq0xf7r3w87wq5fjh369l2073pq38kfg-source/overlays/hyprland': <function>`

Another user on another thread recommends not mixing channels for graphical applications, such as hyprland. As an alternative, the user recommends using the ‘unstable’ channel, but that caused other, bigger issues like this python dependency bug and gnome keyring bug. I’m curious what other users experiences have been here. If you have a similar or opposing stance, please leave a comment below.

I didn’t just not recommend it, I said it’s explicitly something that Nixpkgs does not support (on a technical level). If you mix channels, you’re on your own.

If you want something that is supported by the upstream nixpkgs community in any way, you need to use exactly one revision of nixpkgs at once. Anything more might work for some cases but is likely to fail for others and we can’t help you with those.

Stuff like that will crop up; it’s the unstable channel afterall. Bugs like that typically get fixed within a few days. You can survive for a week without updates. Just wait a few days if you’re not in a position to fix the bugs yourself and perhaps help review PRs that intend to fix such issues (re-assurance that PRs do what they intend to do helps us maintainers quite a lot).

There is no “opposing stance”; this isn’t an opinion.

2 Likes