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