From 45fd7a61df2d52cd0615c056edfd283098d7b149 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Thu, 4 May 2023 19:08:44 -0400 Subject: [PATCH] nodePackages: add aliases --- pkgs/development/node-packages/aliases.nix | 38 +++++++++++++++++++ pkgs/development/node-packages/default.nix | 7 +++- .../node-packages/main-programs.nix | 1 - pkgs/development/node-packages/overrides.nix | 2 - 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/node-packages/aliases.nix diff --git a/pkgs/development/node-packages/aliases.nix b/pkgs/development/node-packages/aliases.nix new file mode 100644 index 000000000000..f5b73e9f352f --- /dev/null +++ b/pkgs/development/node-packages/aliases.nix @@ -0,0 +1,38 @@ +pkgs: lib: self: super: + +### Deprecated aliases - for backward compatibility + +with self; + +let + # Removing recurseForDerivation prevents derivations of aliased attribute + # set to appear while listing all the packages available. + removeRecurseForDerivations = alias: with lib; + if alias.recurseForDerivations or false + then removeAttrs alias ["recurseForDerivations"] + else alias; + + # Disabling distribution prevents top-level aliases for non-recursed package + # sets from building on Hydra. + removeDistribute = alias: with lib; + if isDerivation alias then + dontDistribute alias + else alias; + + # Make sure that we are not shadowing something from node-packages.nix. + checkInPkgs = n: alias: + if builtins.hasAttr n super + then throw "Alias ${n} is still in node-packages.nix" + else alias; + + mapAliases = aliases: + lib.mapAttrs (n: alias: + removeDistribute + (removeRecurseForDerivations + (checkInPkgs n alias))) + aliases; +in + +mapAliases ({ + "@githubnext/github-copilot-cli" = pkgs.github-copilot-cli; # Added 2023-05-02 +}) diff --git a/pkgs/development/node-packages/default.nix b/pkgs/development/node-packages/default.nix index 0fcd508012e8..506dc8a525ca 100644 --- a/pkgs/development/node-packages/default.nix +++ b/pkgs/development/node-packages/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, nodejs, stdenv}: +{ config, pkgs, lib, nodejs, stdenv }: let inherit (lib) composeManyExtensions extends makeExtensible mapAttrs; @@ -15,7 +15,12 @@ let }) ) (import ./main-programs.nix); + aliases = final: prev: + lib.optionalAttrs config.allowAliases + (import ./aliases.nix pkgs lib final prev); + extensions = composeManyExtensions [ + aliases mainProgramOverrides (import ./overrides.nix { inherit pkgs nodejs; }) ]; diff --git a/pkgs/development/node-packages/main-programs.nix b/pkgs/development/node-packages/main-programs.nix index 7fc28c6cdd40..ab425e91ff99 100644 --- a/pkgs/development/node-packages/main-programs.nix +++ b/pkgs/development/node-packages/main-programs.nix @@ -20,7 +20,6 @@ "@commitlint/cli" = "commitlint"; "@forge/cli" = "forge"; "@gitbeaker/cli" = "gitbeaker"; - "@githubnext/github-copilot-cli" = "github-copilot-cli"; "@google/clasp" = "clasp"; "@medable/mdctl-cli" = "mdctl"; "@mermaid-js/mermaid-cli" = "mmdc"; diff --git a/pkgs/development/node-packages/overrides.nix b/pkgs/development/node-packages/overrides.nix index 77bf8e3f8f22..a7e827fb163f 100644 --- a/pkgs/development/node-packages/overrides.nix +++ b/pkgs/development/node-packages/overrides.nix @@ -39,8 +39,6 @@ final: prev: { ]; }; - "@githubnext/github-copilot-cli" = pkgs.github-copilot-cli; - "@medable/mdctl-cli" = prev."@medable/mdctl-cli".override (oldAttrs: { nativeBuildInputs = with pkgs; with darwin.apple_sdk.frameworks; [ glib