Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions pkgs/by-name/pr/prettier/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@

```nix
pkgs.prettier.override {
plugins = with pkgs.nodePackages; [
prettier-plugin-toml
plugins = with pkgs.prettier.plugins; [
prettier-plugin-php
prettier-plugin-pug
prettier-plugin-ruby
prettier-plugin-xml
# ...
];
}
```
*/
{
config,
fetchFromGitHub,
lib,
makeBinaryWrapper,
nodejs,
stdenv,
versionCheckHook,
yarn-berry,
pkgs,
plugins ? [ ],
}:
let
Expand Down Expand Up @@ -171,7 +176,18 @@ stdenv.mkDerivation (finalAttrs: {
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";

passthru.updateScript = ./update.sh;
passthru = {
updateScript = ./update.sh;
plugins = import ./plugins {
inherit
config
pkgs
lib
nodejs
stdenv
;
};
};

meta = {
changelog = "https://github.com/prettier/prettier/blob/${finalAttrs.version}/CHANGELOG.md";
Expand Down
41 changes: 41 additions & 0 deletions pkgs/by-name/pr/prettier/plugins/aliases.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pkgs: lib: self: super:

### Deprecated aliases - for backward compatibility
###
### !!! NOTE !!!
### Use `./remove-attr.py [attrname]` in this directory to remove your alias
### from the `nodePackages` set without regenerating the entire file.

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 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 {
## De-scope -> https://prettier.io/docs/plugins/#official-plugins
prettier-plugin-php = pkgs.prettier.plugins."@prettier/plugin-php";
prettier-plugin-pug = pkgs.prettier.plugins."@prettier/plugin-pug";
prettier-plugin-ruby = pkgs.prettier.plugins."@prettier/plugin-ruby";
prettier-plugin-xml = pkgs.prettier.plugins."@prettier/plugin-xml";
}
32 changes: 32 additions & 0 deletions pkgs/by-name/pr/prettier/plugins/composition.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file has been generated by node2nix 1.11.1. Do not edit!

{
pkgs,
system ? builtins.currentSystem,
nodejs ? pkgs."nodejs_22",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This shouldn't need quotes, because underscore is not a special character.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top of that file says;

# This file has been generated by node2nix 1.11.1. Do not edit!

... I'll remove the quotes, but expect 'em to resurrect next time node2nix gets ideas ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that. I'd just leave it in that case.

}:

let
nodeEnv = import ./node-env.nix {
inherit (pkgs)
stdenv
lib
python2
runCommand
writeTextFile
writeShellScript
;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.cctools or pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs)
fetchurl
nix-gitignore
stdenv
lib
fetchgit
;
inherit nodeEnv;
}
44 changes: 44 additions & 0 deletions pkgs/by-name/pr/prettier/plugins/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
config,
pkgs,
lib,
nodejs,
stdenv,
}:

let
inherit (lib)
composeManyExtensions
extends
makeExtensible
mapAttrs
;

nodePackages =
final:
import ./composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
};

mainProgramOverrides =
final: prev:
mapAttrs (
pkgName: mainProgram:
prev.${pkgName}.override (oldAttrs: {
meta = oldAttrs.meta // {
inherit mainProgram;
};
})
) (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; })
];
in
makeExtensible (extends extensions nodePackages)
23 changes: 23 additions & 0 deletions pkgs/by-name/pr/prettier/plugins/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -eu -o pipefail

cd "$( dirname "${BASH_SOURCE[0]}" )"

node2nix=$(nix-build ../../../../.. -A nodePackages.node2nix)

rm -f ./node-env.nix

# Track the latest active nodejs LTS here: https://nodejs.org/en/about/releases/
"${node2nix}/bin/node2nix" \
-i node-packages.json \
-o node-packages.nix \
-c composition.nix \
--pkg-name nodejs_22

# using --no-out-link in nix-build argument would cause the
# gc to run before the script finishes
# which would cause a failure
# it's safer to just remove the link after the script finishes
# see https://github.com/NixOS/nixpkgs/issues/112846 for more details
rm ./result
6 changes: 6 additions & 0 deletions pkgs/by-name/pr/prettier/plugins/main-programs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Use this file to add `meta.mainProgram` to packages in `nodePackages`.
{
# Packages that provide multiple executables where one is clearly the `mainProgram`.

# Packages that provide a single executable.
}
Loading
Loading