pkgs/overlays/unstable: factor out adding unstable package set to different file

This commit is contained in:
Wroclaw 2024-09-14 19:47:41 +02:00
parent c188003188
commit f7e48890cd
2 changed files with 33 additions and 19 deletions

View file

@ -0,0 +1,30 @@
{
unstableSource,
}:
self: super:
let
useUnstable = self.config.useUnstable or true;
unstablePkgsForNixpkgs = nixpkgs: import unstableSource {
# localSystem -> pkgs.stdenv.buildPlatform
localSystem = nixpkgs.stdenv.buildPlatform;
# crossSystem -> pkgs.stdenv.hostPlatform or pkgs.stdenv.targetPlatform ??
# passing below
# config -> pkgs.config
config = nixpkgs.config;
# overlays -> partial of pkgs.overlays
overlays = nixpkgs.overlays;
# crossOverlays -> partial of pkgs.overlays
# crossOverlays are merged to overlays, not sure what issues that might raise.
# ignoring.
} // (if nixpkgs.stdenv.buildPlatform == nixpkgs.stdenv.hostPlatform then {} else {
# workaround for some odd structured packages that changes behaviour
# when crossSystem is passed.
crossSystem = nixpkgs.stdenv.hostPlatform;
});
in
{
unstable = if useUnstable then unstablePkgsForNixpkgs self else self;
}

View file

@ -24,26 +24,10 @@ let
];
nixpkgsRevision = (builtins.readFile "${unstablePkgsExprs}/.git-revision");
unstablePkgsForNixpkgs = nixpkgs: import unstablePkgsExprs {
# localSystem -> pkgs.stdenv.buildPlatform
localSystem = nixpkgs.stdenv.buildPlatform;
# crossSystem -> pkgs.stdenv.hostPlatform or pkgs.stdenv.targetPlatform ??
# passing below
# config -> pkgs.config
config = nixpkgs.config;
# overlays -> partial of pkgs.overlays
overlays = nixpkgs.overlays;
# crossOverlays -> partial of pkgs.overlays
# crossOverlays are merged to overlays, not sure what issues that might raise.
# ignoring.
} // (if nixpkgs.stdenv.buildPlatform == nixpkgs.stdenv.hostPlatform then {} else {
# workaround for some odd structured packages that changes behaviour
# when crossSystem is passed.
crossSystem = nixpkgs.stdenv.hostPlatform;
});
in
{
unstable = if useUnstable then unstablePkgsForNixpkgs self else self;
import ./unstable-from-source.nix {
unstableSource = unstablePkgsExprs;
} self super // {
unstableVersion = self.lib.optionalString useUnstable nixpkgsVersion;
unstableRevision = self.lib.optionalString useUnstable nixpkgsRevision;
}