Overriding flakes package attribute in configuration.nix

Is there a way to override attributes of a package coming from a flake ?
I’m configuring my system using flake.nix and I want to override a package that comes from a flake, but I cannot figure out how.

flake.nix:

{
  inputs = {
    # nixpkgs
    nixpkgs.url = github:NixOS/nixpkgs;
    # hyprland
    hyprland = {
      url = github:hyprwm/Hyprland;
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, hyprland }: {
    nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
      # ...
      specialArgs = { flake-self = self; };
      modules = [
        hyprland.nixosModules.default
        ./configuration.nix
        # ...
      ];
    };
}

configuration.nix:

{ config, pkgs, flake-self, ... }:

{
  # ...
  programs.hyprland = {
    enable = true;
    package = # flake-self.inputs.hyperland ???
  };
  # ...
}

I want to override the package to add the { nvidiaPatches = true; } attribute. How can I achieve this ?

1 Like

Would this work?

flake-self.inputs.hyperland.packages.${pkgs.system}.default.override {
  nvidiaPatches = true;
}
2 Likes

It worked !
How did you figures the ${pkgs.system} part ? I was stuck on this and could not find documentation.

There’s a conventional output schema for flakes that commands like nix build and whatnot expect. This is documented somewhere but I don’t remember where to find it. Many of a flake’s outputs in this schema, including packages, include the system in the attribute path; i.e. someflake.packages.x86_64-linux.hello. And Nix just has a handy syntax that lets you evaluate an expression to determine an attribute, like someflake.packages.${pkgs.system}.hello.