Hi, I’m trying to apply a patch in a devshell defintion of a flake to the nixos-rebuild script defined in nixpkgs
. The patch was generated via git diff >PATCHNAME.patch
from a checked-out nixpkgs repository. The devshell definition is the following:
devShells = with flake-utils.lib; nixpkgs.lib.genAttrs [ system.x86_64-linux system.aarch64-linux ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
default = pkgs.mkShell {
packages = [
(pkgs.nixos-rebuild.overrideAttrs (prevAttrs: {
patches = (prevAttrs.patches or []) ++ [ ./PATCHNAME.patch ];
}))
...
];
};
}
);
and the patch header looks like:
diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
index bc0b6507ecb..584298b9cb9 100755
--- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
+++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
...
However, when entering the shell with nix develop
the patch isn’t applied to nixos-rebuild
and no error message is shown. I end up with a vanilla version of the script in the shell, but the patch itself is added to the nix store (but no patched version of the script is present in the store).
(I tried to modify the paths in the header because I couldn’t find any information about to which directory the paths should be relative too, but it didn’t help.)
I probably misunderstood how patching works (I was following this article) and would be glad to get some hints what I’m doing wrong. Thanks!
Note: I only want to apply this patch in the devshell for now as it’s intended to be usable on a non-nixos system. I tried to apply it with an overlay on a NixOS system but to no avail.