lol
1{
2 lib,
3 fetchFromGitHub,
4 buildRubyGem,
5 bundlerEnv,
6 ruby_3_4,
7}:
8
9let
10 gemName = "github-linguist";
11 version = "9.1.0";
12 src = fetchFromGitHub {
13 owner = "github-linguist";
14 repo = "linguist";
15 tag = "v${version}";
16 hash = "sha256-nPIUo6yQY6WvKuXvT1oOx6LZq49QLa9YIJmOrRYgAdg=";
17 };
18
19 deps = bundlerEnv {
20 name = "github-linguist-dep";
21 gemfile = "${src}/Gemfile";
22 lockfile = ./Gemfile.lock;
23 gemset = ./gemset.nix;
24 inherit ruby;
25 };
26
27 ruby = ruby_3_4;
28
29in
30buildRubyGem rec {
31 name = "${gemName}-${version}";
32 inherit
33 gemName
34 version
35 src
36 ruby
37 ;
38
39 doInstallCheck = true;
40 dontBuild = false;
41
42 postInstall = ''
43 export GEM_PATH="${deps}/lib/ruby/gems/${ruby.version.libDir}"
44 bundle exec rake samples
45 install --mode=0644 -Dm 0755 lib/linguist/samples.json $out/lib/ruby/gems/${ruby.version.libDir}/gems/${name}/lib/linguist
46
47 wrapProgram "$out/bin/github-linguist" \
48 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}"
49
50 wrapProgram "$out/bin/git-linguist" \
51 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}"
52 '';
53
54 passthru = {
55 inherit ruby deps;
56 };
57
58 meta = {
59 description = "Language savant Ruby library";
60 longDescription = ''
61 A Ruby library that is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs.
62 '';
63 homepage = "https://github.com/github-linguist/linguist";
64 license = lib.licenses.mit;
65 maintainers = with lib.maintainers; [ Cryolitia ];
66 platforms = with lib.platforms; linux ++ darwin;
67 };
68}