nix

How can I override a package source in Nix?


So I want to replace pkgs.picom in my home-manager config with a newer fork. How can I do that?

I have a feeling it's something like:

let newPicom = pkgs.picom.override.src.url = "https://github.com/ibhagwan/picom";  
in 
services.picom.package = newPicom; 

But knowing Nix is probably actually some really long incantation with self: super: and so on.


Solution

  • wiki.nixos.org has an example of overriding the source of a package.

    You do need to provide a reproducible source. A github repo url is mutable, so you need to specify the revision.

    { pkgs, ... }:
    let newPicom = pkgs.picom.overrideAttrs (old: {
          version = "git"; # usually harmless to omit
          src = /* put your source here; typically a local path or
                   a fixed-output derivation produced by
                   `fetchFromGitHub`.
                   builtins.fetchGit is also an option. Doesn't run
                   in parallel but does fetch private sources. */;
        });
    in {
      services.picom.package = newPicom; 
    }