Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 fetchFromGitHub, 5 crystal, 6 wrapGAppsHook4, 7 gobject-introspection, 8 desktopToDarwinBundle, 9 webkitgtk_6_0, 10 sqlite, 11 libadwaita, 12 gtk4, 13 glib, 14 pango, 15 symlinkJoin, 16 gitUpdater, 17 _experimental-update-script-combinators, 18 runCommand, 19 crystal2nix, 20 writeShellScript, 21}: 22let 23 version = "0.6.2"; 24 25 src = fetchFromGitHub { 26 owner = "hugopl"; 27 repo = "rtfm"; 28 tag = "v${version}"; 29 hash = "sha256-0yKldVTZdFV1Tj1MUI7TCqF3Ho/D7NOGR9UuLaLUFdo="; 30 }; 31 32 gtk-doc = 33 let 34 gtk4' = gtk4.override { x11Support = true; }; 35 pango' = pango.override { withIntrospection = true; }; 36 in 37 symlinkJoin { 38 name = "gtk-doc"; 39 paths = [ 40 gtk4'.devdoc 41 pango'.devdoc 42 glib.devdoc 43 libadwaita.devdoc 44 webkitgtk_6_0.devdoc 45 ]; 46 }; 47in 48crystal.buildCrystalPackage { 49 pname = "rtfm"; 50 inherit version src; 51 52 shardsFile = ./shards.nix; 53 copyShardDeps = true; 54 55 postPatch = '' 56 substituteInPlace src/doc2dash/create_gtk_docset.cr \ 57 --replace-fail 'basedir = Path.new("/usr/share/doc")' 'basedir = Path.new(ARGV[0]? || "${gtk-doc}/share/doc")' \ 58 --replace-fail 'webkit2gtk-4.0' 'webkitgtk-6.0' 59 substituteInPlace src/doc2dash/create_crystal_docset.cr \ 60 --replace-fail 'doc_source = Path.new(ARGV[0]? || "/usr/share/doc/crystal/api")' 'doc_source = Path.new(ARGV[0]? || "${crystal}/share/doc/crystal/api")' 61 substituteInPlace src/doc2dash/docset_builder.cr \ 62 --replace-fail 'File.copy(original, real_dest)' 'File.copy(original, real_dest); File.chmod(real_dest, 0o600)' 63 ''; 64 65 preBuild = '' 66 cd lib/gi-crystal 67 shards build -Dpreview_mt --release --no-debug 68 cd ../.. 69 install -Dm755 lib/gi-crystal/bin/gi-crystal bin/gi-crystal 70 ''; 71 72 buildTargets = [ "all" ]; 73 74 nativeBuildInputs = [ 75 wrapGAppsHook4 76 gobject-introspection 77 ] 78 ++ lib.optionals stdenv.hostPlatform.isDarwin [ desktopToDarwinBundle ]; 79 80 buildInputs = [ 81 webkitgtk_6_0 82 sqlite 83 libadwaita 84 gtk4 85 pango 86 ]; 87 88 postInstall = '' 89 glib-compile-schemas $out/share/glib-2.0/schemas 90 ''; 91 92 doInstallCheck = false; 93 94 passthru = { 95 updateScript = _experimental-update-script-combinators.sequence [ 96 (gitUpdater { rev-prefix = "v"; }) 97 (_experimental-update-script-combinators.copyAttrOutputToFile "rtfm.shardLock" "./shard.lock") 98 { 99 command = [ 100 (writeShellScript "update-lock" "cd $1; ${lib.getExe crystal2nix}") 101 ./. 102 ]; 103 supportedFeatures = [ "silent" ]; 104 } 105 { 106 command = [ 107 "rm" 108 "./shard.lock" 109 ]; 110 supportedFeatures = [ "silent" ]; 111 } 112 ]; 113 shardLock = runCommand "shard.lock" { inherit src; } '' 114 cp $src/shard.lock $out 115 ''; 116 }; 117 118 meta = with lib; { 119 description = "Dash/docset reader with built in documentation for Crystal and GTK APIs"; 120 homepage = "https://github.com/hugopl/rtfm/"; 121 license = licenses.mit; 122 mainProgram = "rtfm"; 123 maintainers = with maintainers; [ sund3RRR ]; 124 platforms = platforms.unix; 125 }; 126}