Overriding kitty package

Hello, everyone. I am trying to override the kitty package to build version 0.39.1, which is not yet available in nixpkgs.

Here’s what I have put in my configuration file


(unstable.kitty.overrideAttrs (oldAttrs: rec{
			 pname = "kitty";
			 version = "0.39.1";
			 format = "other";
			src = fetchFromGitHub {
			   owner = "kovidgoyal";
			   repo = "kitty";
			   tag = "v${version}";
			   hash = "sha256-Cgbs9tdEGKhDShNh3M8N1UdRJu4aMylr9xLOGLpDAZE";
  			};

		       goModules = (buildGo123Module {
			     pname = "kitty-go-modules";
			     inherit src version;
			     vendorHash = "sha256-j5ToLPQeaf4xIaziBAROYZNvoaOx2TkTcuY95X4Neqc";
			   }).goModules;
		}))

But, when I run the command nixos-rebuild --switch, it builds version 0.39.0. Why is this happening? What is wrong with my configuration?

Where did you put it? Are you using any kitty module?

I have put it in a packages.nix file, which I import in configuration.nix.

I am using home-manager to configure kitty, if that is relevant.

Here is my packages.nix file

{ config, lib, inputs,...}:
let
	system   = "x86_64-linux";
	unstable = import inputs.nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; };
	stable   = import inputs.nixpkgs-stable   { system = "x86_64-linux"; config.allowUnfree = true; };
in {
	environment.systemPackages = with stable; [
		(unstable.kitty.overrideAttrs (oldAttrs: rec{
			 pname = "kitty";
			 version = "0.39.1";
			 format = "other";
			src = fetchFromGitHub {
			   owner = "kovidgoyal";
			   repo = "kitty";
			   tag = "v${version}";
			   hash = "sha256-Cgbs9tdEGKhDShNh3M8N1UdRJu4aMylr9xLOGLpDAZE";
  			};

		       goModules = (buildGo123Module {
			     pname = "kitty-go-modules";
			     inherit src version;
			     vendorHash = "sha256-j5ToLPQeaf4xIaziBAROYZNvoaOx2TkTcuY95X4Neqc";
			   }).goModules;
		}))

Yes it is relevant, you’d have to explicitly set programs.kitty.package.

It is currently set to unstable.kitty;

What do I set it, so that it uses the overridden package?

The full override expression you wrote.

Thank you, that solves it. Although, I have transformed it into an overlay and used it. I am including my complete configuration here, if anybody needs it in the future.

Here is my overwrite function I wrote down in kitty.nix:-

final: prev: {
   kitty = prev.kitty.overrideAttrs (old: rec{
	  pname = "kitty";
	  version = "0.39.1";
	  format = "other";

  	  src = prev.fetchFromGitHub {
	  owner = "kovidgoyal";
           repo = "kitty";
           tag = "v${version}";
           hash = "";
           };

  	  goModules =
           (prev.buildGo123Module {
           pname = "kitty-go-modules";
           inherit src version;
           vendorHash = "";
           }).goModules;
  });
}

I’ve left the hashes empty, so that for future usage one can input the correct hashes.

Here’s how I have imported kitty.nix into my home.nix and packages.nix

{ config, pkgs, inputs, ... }:
let 
	unstable = import inputs.nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; overlays = [ (import ./kitty.nix) ]; };

Now, it is possible to install/enable the package using unstable.kitty.