From 31dc171e974f7738a628c8c8b1a12606f34b95e1 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Tue, 26 Mar 2024 21:19:39 -0400 Subject: [PATCH 1/2] darwin: add darwin-aliases.nix --- pkgs/top-level/darwin-aliases.nix | 50 ++++++++++++++++++++++++++++++ pkgs/top-level/darwin-packages.nix | 4 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 pkgs/top-level/darwin-aliases.nix diff --git a/pkgs/top-level/darwin-aliases.nix b/pkgs/top-level/darwin-aliases.nix new file mode 100644 index 0000000000000..9c4147b8cc710 --- /dev/null +++ b/pkgs/top-level/darwin-aliases.nix @@ -0,0 +1,50 @@ +lib: self: super: pkgs: + +### Deprecated aliases - for backward compatibility + +### Please maintain this list in ASCIIbetical ordering. +### Hint: the "sections" are delimited by ### ### + +# These aliases should not be used within nixpkgs, but exist to improve +# backward compatibility in projects outside of nixpkgs. See the +# documentation for the `allowAliases` option for more background. + +# A script to convert old aliases to throws and remove old +# throws can be found in './maintainers/scripts/remove-old-aliases.py'. + +# Add 'preserve, reason: reason why' after the date if the alias should not be removed. +# Try to keep them to a minimum. +# valid examples of what to preserve: +# distro aliases such as: +# debian-package-name -> nixos-package-name + +# pkgs is provided to allow packages to be moved out of the darwin attrset. + +with self; + +let + # Removing recurseForDerivation prevents derivations of aliased attribute set + # to appear while listing all the packages available. + removeRecurseForDerivations = + alias: + if alias.recurseForDerivations or false then + lib.removeAttrs alias [ "recurseForDerivations" ] + else + alias; + + # Disabling distribution prevents top-level aliases for non-recursed package + # sets from building on Hydra. + removeDistribute = alias: if lib.isDerivation alias then lib.dontDistribute alias else alias; + + # Make sure that we are not shadowing something from darwin-packages.nix. + checkInPkgs = + n: alias: + if builtins.hasAttr n super then throw "Alias ${n} is still in darwin-packages.nix" else alias; + + mapAliases = lib.mapAttrs ( + n: alias: removeDistribute (removeRecurseForDerivations (checkInPkgs n alias)) + ); +in + +mapAliases ({ +}) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index a6c98831eee6a..724ef8972a8f5 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -18,12 +18,14 @@ let fetchurlBoot = import ../build-support/fetchurl/boot.nix { inherit (stdenv) system; }; + + aliases = self: super: lib.optionalAttrs config.allowAliases (import ../top-level/darwin-aliases.nix lib self super pkgs); in makeScopeWithSplicing' { otherSplices = generateSplicesForMkScope "darwin"; extra = spliced: spliced.apple_sdk.frameworks; - f = (self: let + f = lib.extends aliases (self: let inherit (self) mkDerivation callPackage; # Must use pkgs.callPackage to avoid infinite recursion. From 80186737d03ed394b3d9d932a48700994ac46175 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Tue, 26 Mar 2024 21:22:00 -0400 Subject: [PATCH 2/2] darwin.builder: move to darwin-aliases --- pkgs/top-level/darwin-aliases.nix | 3 +++ pkgs/top-level/darwin-packages.nix | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/darwin-aliases.nix b/pkgs/top-level/darwin-aliases.nix index 9c4147b8cc710..2466cae23ed8e 100644 --- a/pkgs/top-level/darwin-aliases.nix +++ b/pkgs/top-level/darwin-aliases.nix @@ -47,4 +47,7 @@ let in mapAliases ({ + ### B ### + + builder = throw "'darwin.builder' has been changed and renamed to 'darwin.linux-builder'. The default ssh port is now 31022. Please update your configuration or override the port back to 22. See https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder"; # added 2023-07-06 }) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index 724ef8972a8f5..1302541234f53 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -260,7 +260,5 @@ impure-cmds // appleSourcePackages // chooseLibs // { modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ]; }; -} // lib.optionalAttrs config.allowAliases { - builder = throw "'darwin.builder' has been changed and renamed to 'darwin.linux-builder'. The default ssh port is now 31022. Please update your configuration or override the port back to 22. See https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder"; # added 2023-07-06 }); }