|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + buildDotnetModule, |
| 5 | + fetchFromGitHub, |
| 6 | + dotnetCorePackages, |
| 7 | + copyDesktopItems, |
| 8 | + makeDesktopItem, |
| 9 | + libicns, |
| 10 | + |
| 11 | + libXcursor, |
| 12 | + libXext, |
| 13 | + libXi, |
| 14 | + libXrandr, |
| 15 | + |
| 16 | + git, |
| 17 | + xdg-utils, |
| 18 | +}: |
| 19 | + |
| 20 | +buildDotnetModule (finalAttrs: { |
| 21 | + pname = "sourcegit"; |
| 22 | + version = "2025.01"; |
| 23 | + |
| 24 | + src = fetchFromGitHub { |
| 25 | + owner = "sourcegit-scm"; |
| 26 | + repo = "sourcegit"; |
| 27 | + tag = "v${finalAttrs.version}"; |
| 28 | + hash = "sha256-6FO0WRUcWm7xnuw6Br97+cWZhvzIOesg/eANZzeyxZo="; |
| 29 | + }; |
| 30 | + |
| 31 | + patches = [ ./fix-darwin-git-path.patch ]; |
| 32 | + |
| 33 | + dotnet-sdk = dotnetCorePackages.sdk_9_0; |
| 34 | + dotnet-runtime = dotnetCorePackages.runtime_9_0; |
| 35 | + |
| 36 | + nugetDeps = ./deps.json; |
| 37 | + |
| 38 | + projectFile = [ "src/SourceGit.csproj" ]; |
| 39 | + |
| 40 | + executables = [ "SourceGit" ]; |
| 41 | + |
| 42 | + dotnetFlags = [ |
| 43 | + "-p:DisableUpdateDetection=true" |
| 44 | + "-p:DisableAOT=true" |
| 45 | + ]; |
| 46 | + |
| 47 | + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ |
| 48 | + copyDesktopItems |
| 49 | + libicns |
| 50 | + ]; |
| 51 | + |
| 52 | + # these are dlopen-ed at runtime |
| 53 | + # libXi is needed for right-click support |
| 54 | + # not sure about what the other ones are needed for, but I'll include them anyways |
| 55 | + runtimeDeps = [ |
| 56 | + libXcursor |
| 57 | + libXext |
| 58 | + libXi |
| 59 | + libXrandr |
| 60 | + ]; |
| 61 | + |
| 62 | + # Note: users can use `.overrideAttrs` to append to this list |
| 63 | + runtimePathDeps = [ |
| 64 | + git |
| 65 | + xdg-utils |
| 66 | + ]; |
| 67 | + |
| 68 | + # add fallback binaries to use if the user doesn't already have them in their PATH |
| 69 | + preInstall = '' |
| 70 | + makeWrapperArgs+=( |
| 71 | + --suffix PATH : ${lib.makeBinPath finalAttrs.runtimePathDeps} |
| 72 | + ) |
| 73 | + ''; |
| 74 | + |
| 75 | + desktopItems = [ |
| 76 | + (makeDesktopItem { |
| 77 | + name = "SourceGit"; |
| 78 | + exec = "SourceGit"; |
| 79 | + icon = "SourceGit"; |
| 80 | + desktopName = "SourceGit"; |
| 81 | + terminal = false; |
| 82 | + comment = finalAttrs.meta.description; |
| 83 | + }) |
| 84 | + ]; |
| 85 | + |
| 86 | + postInstall = |
| 87 | + lib.optionalString stdenv.hostPlatform.isLinux '' |
| 88 | + # extract the .icns file into multiple .png files |
| 89 | + # where the format of the .png file names is App_"$n"x"$n"x32.png |
| 90 | +
|
| 91 | + icns2png -x build/resources/app/App.icns |
| 92 | +
|
| 93 | + for f in App_*x32.png; do |
| 94 | + res=''${f//App_} |
| 95 | + res=''${res//x32.png} |
| 96 | + install -Dm644 $f "$out/share/icons/hicolor/$res/apps/SourceGit.png" |
| 97 | + done |
| 98 | + '' |
| 99 | + + lib.optionalString stdenv.hostPlatform.isDarwin '' |
| 100 | + install -Dm644 build/resources/app/App.icns $out/Applications/SourceGit.app/Contents/Resources/App.icns |
| 101 | +
|
| 102 | + substitute build/resources/app/App.plist $out/Applications/SourceGit.app/Contents/Info.plist \ |
| 103 | + --replace-fail "SOURCE_GIT_VERSION" "${finalAttrs.version}" |
| 104 | +
|
| 105 | + mkdir -p $out/Applications/SourceGit.app/Contents/MacOS |
| 106 | + ln -s $out/bin/SourceGit $out/Applications/SourceGit.app/Contents/MacOS/SourceGit |
| 107 | + ''; |
| 108 | + |
| 109 | + meta = { |
| 110 | + changelog = "https://github.com/sourcegit-scm/sourcegit/releases/tag/${finalAttrs.src.tag}"; |
| 111 | + description = "Free & OpenSource GUI client for GIT users"; |
| 112 | + homepage = "https://github.com/sourcegit-scm/sourcegit"; |
| 113 | + license = lib.licenses.mit; |
| 114 | + mainProgram = "SourceGit"; |
| 115 | + maintainers = with lib.maintainers; [ tomasajt ]; |
| 116 | + }; |
| 117 | +}) |
0 commit comments