4f0dadbf38
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
105 lines
2.4 KiB
Nix
105 lines
2.4 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
buildEnv,
|
|
buildRubyGem,
|
|
ruby,
|
|
gemConfig,
|
|
makeBinaryWrapper,
|
|
}:
|
|
|
|
/*
|
|
Example usage:
|
|
nix-shell -E "(import <nixpkgs> {}).ruby.withPackages (pkgs: with pkgs; [ pry nokogiri ])"
|
|
|
|
You can also use this for writing ruby scripts that run anywhere that has nix
|
|
using a nix-shell shebang:
|
|
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i ruby -p "ruby.withPackages (pkgs: with pkgs; [ pry nokogiri ])"
|
|
|
|
Run the following in the nixpkgs root directory to update the ruby-packages.nix:
|
|
./maintainers/scripts/update-ruby-packages
|
|
*/
|
|
|
|
let
|
|
functions = import ../bundled-common/functions.nix { inherit lib gemConfig; };
|
|
|
|
buildGems =
|
|
gemset:
|
|
let
|
|
realGemset = if builtins.isAttrs gemset then gemset else import gemset;
|
|
builtGems = lib.mapAttrs (
|
|
name: initialAttrs:
|
|
let
|
|
attrs = functions.applyGemConfigs (
|
|
{
|
|
inherit ruby;
|
|
gemName = name;
|
|
}
|
|
// initialAttrs
|
|
);
|
|
in
|
|
buildRubyGem (functions.composeGemAttrs ruby builtGems name attrs)
|
|
) realGemset;
|
|
in
|
|
builtGems;
|
|
|
|
gems = buildGems (import ../../../top-level/ruby-packages.nix);
|
|
|
|
withPackages =
|
|
selector:
|
|
let
|
|
selected = selector gems;
|
|
|
|
gemEnv = buildEnv {
|
|
name = "ruby-gems";
|
|
paths = selected;
|
|
pathsToLink = [
|
|
"/lib"
|
|
"/bin"
|
|
"/nix-support"
|
|
];
|
|
};
|
|
|
|
wrappedRuby = stdenv.mkDerivation {
|
|
name = "wrapped-${ruby.name}";
|
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
|
buildCommand = ''
|
|
mkdir -p $out/bin
|
|
for i in ${ruby}/bin/*; do
|
|
makeWrapper "$i" $out/bin/$(basename "$i") --set GEM_PATH ${gemEnv}/${ruby.gemPath}
|
|
done
|
|
'';
|
|
};
|
|
|
|
in
|
|
stdenv.mkDerivation {
|
|
name = "${ruby.name}-with-packages";
|
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
|
buildInputs = [
|
|
selected
|
|
ruby
|
|
];
|
|
|
|
dontUnpack = true;
|
|
|
|
installPhase = ''
|
|
for i in ${ruby}/bin/* ${gemEnv}/bin/*; do
|
|
rm -f $out/bin/$(basename "$i")
|
|
makeWrapper "$i" $out/bin/$(basename "$i") --set GEM_PATH ${gemEnv}/${ruby.gemPath}
|
|
done
|
|
|
|
ln -s ${ruby}/nix-support $out/nix-support
|
|
'';
|
|
|
|
passthru = {
|
|
inherit wrappedRuby;
|
|
gems = selected;
|
|
};
|
|
};
|
|
|
|
in
|
|
{
|
|
inherit withPackages gems buildGems;
|
|
}
|