Skip to content

Commit

Permalink
nix: Reduce number of nixpkgs variants
Browse files Browse the repository at this point in the history
Now the `applyPatches` (derivation-creating) function can be supplied
from a pre-instantiated nixpkgs derivation, or from
`nixpkgs.legacyPackages` if `nixpkgs` is a flake, or from an import of
the unpatches `nixpkgs` otherwise.

The previous code would instantiate a version of nixpkgs just for the
call to `applyPatches`.
  • Loading branch information
dbaynard committed Mar 31, 2024
1 parent 9f0c328 commit e01b4fa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
url = "https://github.com/nixos/nixpkgs/archive/${nixpkgsVersion.rev}.tar.gz";
sha256 = nixpkgsVersion.tarballHash;
}
, applyPatches ? (
# If nixpkgs is a flake
nixpkgs.legacyPackages.${system}
or
# If nixpkgs is a derivation
import nixpkgs
{ inherit system; }
).applyPatches
}:

let
Expand All @@ -26,7 +34,8 @@ let
(pkgs.gitignoreSource ./.)
[ ".cabal" ".hs" ".lhs" "LICENSE" ];

nixpkgs-patched = (import nixpkgs { inherit overlays system; }).applyPatches {
# Workaround for https://github.com/NixOS/nixpkgs/issues/286285
nixpkgs-patched = applyPatches {
name = "nixpkgs-patched";
src = nixpkgs;
patches = [ nix/split-sections-cross.patch ];
Expand Down

0 comments on commit e01b4fa

Please sign in to comment.