From f7e48890cde24463f584c973cce80cfce2f2caa1 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sat, 14 Sep 2024 19:47:41 +0200 Subject: [PATCH 1/3] pkgs/overlays/unstable: factor out adding unstable package set to different file --- pkgs/overlays/unstable-from-source.nix | 30 ++++++++++++++++++++++++++ pkgs/overlays/unstable.nix | 22 +++---------------- 2 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 pkgs/overlays/unstable-from-source.nix diff --git a/pkgs/overlays/unstable-from-source.nix b/pkgs/overlays/unstable-from-source.nix new file mode 100644 index 0000000..128da58 --- /dev/null +++ b/pkgs/overlays/unstable-from-source.nix @@ -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; +} diff --git a/pkgs/overlays/unstable.nix b/pkgs/overlays/unstable.nix index 1cf4bae..297b3ae 100644 --- a/pkgs/overlays/unstable.nix +++ b/pkgs/overlays/unstable.nix @@ -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; } From d4e7760eb8210a6f2735eb90735f1f76c1c01294 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sat, 14 Sep 2024 19:49:32 +0200 Subject: [PATCH 2/3] pkgs/overlays/unstable-from-source: remove "emulator" attribute from forwarded platform https://github.com/NixOS/nixpkgs/pull/324071 broke the overlay --- pkgs/overlays/unstable-from-source.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/overlays/unstable-from-source.nix b/pkgs/overlays/unstable-from-source.nix index 128da58..afb8f2e 100644 --- a/pkgs/overlays/unstable-from-source.nix +++ b/pkgs/overlays/unstable-from-source.nix @@ -6,10 +6,14 @@ self: super: let useUnstable = self.config.useUnstable or true; + sanitizePlatform = platformConfig: self.lib.removeAttrs platformConfig [ + "emulator" + "emulatorAvailable" + ]; unstablePkgsForNixpkgs = nixpkgs: import unstableSource { # localSystem -> pkgs.stdenv.buildPlatform - localSystem = nixpkgs.stdenv.buildPlatform; + localSystem = sanitizePlatform nixpkgs.stdenv.buildPlatform; # crossSystem -> pkgs.stdenv.hostPlatform or pkgs.stdenv.targetPlatform ?? # passing below # config -> pkgs.config @@ -22,7 +26,7 @@ let } // (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; + crossSystem = sanitizePlatform nixpkgs.stdenv.hostPlatform; }); in { From d543c41694fca95a5e0a3bc1f2b952cc68a11374 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sat, 14 Sep 2024 19:51:36 +0200 Subject: [PATCH 3/3] pkgs/overlays/unstable: remove fetching using unstableRevision options use unstable-from-source overlay instead --- pkgs/overlays/unstable.nix | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkgs/overlays/unstable.nix b/pkgs/overlays/unstable.nix index 297b3ae..73e79b9 100644 --- a/pkgs/overlays/unstable.nix +++ b/pkgs/overlays/unstable.nix @@ -2,18 +2,9 @@ self: super: let nixos = self.config.nixos or true; - unstableRevision = self.config.unstableRevision or null; - unstableRevisionHash = self.config.unstableRevisionHash or null; useUnstable = self.config.useUnstable or true; - unstablePkgsExprs = if !builtins.isNull unstableRevision - then if !builtins.isNull unstableRevisionHash - then builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/${unstableRevision}.tar.gz"; - sha256 = unstableRevisionHash; - } - else builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/${unstableRevision}.tar.gz" - else if nixos + unstablePkgsExprs = if nixos then builtins.fetchTarball "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" else builtins.fetchTarball "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";