From 604a41bb3b670dca72ea57068575c47032ce0dc1 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 20 Apr 2024 19:07:35 +0200 Subject: callObsolescentPackage: init from local definition --- pkgs/default.nix | 27 ++++++++++++++++++++++----- pkgs/simple/default.nix | 15 ++------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/pkgs/default.nix b/pkgs/default.nix index fb90696..fffd289 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -13,8 +13,25 @@ in # Import files and subdirectories like they are overlays. lib.fix (builtins.foldl' (lib.flip lib.extends) (_: super) - (map - (name: import (./. + "/${name}")) - (pushBack "override" - (builtins.attrNames - (lib.filterAttrs mylib.isNixDirEntry (builtins.readDir ./.)))))) + ( + [ + (self: super: { + callObsolescentPackage = path: args: let + override = self.callPackage path args; + upstream = lib.optionalAttrs (override ? "name") + (super.${(builtins.parseDrvName override.name).name} or {}); + in if upstream ? "name" && + override ? "name" && + builtins.compareVersions upstream.name override.name != -1 + then builtins.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override + else override; + }) + ] + ++ + map + (name: import (./. + "/${name}")) + (pushBack "override" + (builtins.attrNames + (lib.filterAttrs mylib.isNixDirEntry (builtins.readDir ./.)))) + ) + ) diff --git a/pkgs/simple/default.nix b/pkgs/simple/default.nix index 1e63017..3dac0aa 100644 --- a/pkgs/simple/default.nix +++ b/pkgs/simple/default.nix @@ -1,18 +1,7 @@ self: super: let - inherit (super) lib mylib; - - # This callPackage will try to detect obsolete overrides. - callPackage = path: args: let - override = self.callPackage path args; - upstream = lib.optionalAttrs (override ? "name") - (super.${(builtins.parseDrvName override.name).name} or {}); - in if upstream ? "name" && - override ? "name" && - builtins.compareVersions upstream.name override.name != -1 - then builtins.trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override - else override; + inherit (super) mylib; in - mylib.mapNixDir (path: callPackage path {}) ./. +mylib.mapNixDir (path: self.callObsolescentPackage path {}) ./. -- cgit v1.2.3