lol
1{
2 fetchFromGitHub,
3 fetchpatch,
4 lib,
5 stdenv,
6 cmake,
7 copyDesktopItems,
8 pkg-config,
9 qt6Packages,
10 linyaps-box,
11 cli11,
12 curl,
13 gpgme,
14 gtest,
15 libarchive,
16 libelf,
17 libsodium,
18 libsysprof-capture,
19 nlohmann_json,
20 openssl,
21 ostree,
22 systemdLibs,
23 tl-expected,
24 uncrustify,
25 xz,
26 yaml-cpp,
27 replaceVars,
28 bash,
29 binutils,
30 coreutils,
31 desktop-file-utils,
32 erofs-utils,
33 fuse3,
34 fuse-overlayfs,
35 gnutar,
36 glib,
37 shared-mime-info,
38}:
39
40stdenv.mkDerivation (finalAttrs: {
41 pname = "linyaps";
42 version = "1.9.13";
43
44 src = fetchFromGitHub {
45 owner = "OpenAtom-Linyaps";
46 repo = finalAttrs.pname;
47 tag = finalAttrs.version;
48 hash = "sha256-sAxHDvhRz7okElk8vdISJt/yrNnCdu95hW3ImHOjiyw=";
49 };
50
51 patches = [
52 ./fix-host-path.patch
53 ];
54
55 postPatch = ''
56 substituteInPlace apps/ll-init/CMakeLists.txt \
57 --replace-fail "target_link_options(\''${LL_INIT_TARGET} PRIVATE -static -static-libgcc" \
58 "target_link_options(\''${LL_INIT_TARGET} PRIVATE -static -static-libgcc -L${stdenv.cc.libc.static}/lib"
59
60 substituteInPlace misc/share/applications/linyaps.desktop \
61 --replace-fail "/usr/bin/ll-cli" "$out/bin/ll-cli"
62
63 # Don't use hardcoded paths in the application's desktop file, as it would become invalid when the old linyaps gets removed.
64 substituteInPlace libs/linglong/src/linglong/repo/ostree_repo.cpp \
65 --replace-fail 'LINGLONG_CLIENT_PATH' 'LINGLONG_CLIENT_NAME'
66 '';
67
68 buildInputs = [
69 cli11
70 curl
71 gpgme
72 gtest
73 libarchive
74 libelf
75 libsodium
76 libsysprof-capture
77 nlohmann_json
78 openssl
79 ostree
80 qt6Packages.qtbase
81 systemdLibs
82 tl-expected
83 uncrustify
84 xz
85 yaml-cpp
86 ];
87
88 nativeBuildInputs = [
89 cmake
90 copyDesktopItems
91 pkg-config
92 qt6Packages.wrapQtAppsNoGuiHook
93 ];
94
95 postInstall = ''
96 # move to the right location for systemd.packages option
97 # https://github.com/NixOS/nixpkgs/blob/85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054/nixos/modules/system/boot/systemd.nix#L605
98 mv $out/lib/systemd/system-environment-generators $out/lib/systemd/system-generators
99 '';
100
101 # Disable automatic Qt wrapping to handle it manually
102 dontWrapQtApps = true;
103
104 # Add runtime dependencies to PATH for all wrapped binaries
105 qtWrapperArgs = [
106 "--prefix PATH : ${
107 lib.makeBinPath [
108 bash
109 binutils
110 coreutils
111 desktop-file-utils
112 erofs-utils
113 fuse3
114 fuse-overlayfs
115 glib
116 gnutar
117 shared-mime-info
118 linyaps-box
119 ]
120 }"
121 ];
122
123 # Note: ll-init must be statically linked and should not be wrapped
124 postFixup = ''
125 # Wrap all executables except ll-init
126 find "$out" -type f -executable \
127 \( -path "$out/bin/*" -o -path "$out/libexec/*" \) \
128 ! -name "ll-init" \
129 -print0 | while IFS= read -r -d "" f; do
130 wrapQtApp "$f"
131 done
132 '';
133
134 meta = {
135 description = "Cross-distribution package manager with sandboxed apps and shared runtime";
136 homepage = "https://linyaps.org.cn";
137 downloadPage = "https://github.com/OpenAtom-Linyaps/linyaps";
138 changelog = "https://github.com/OpenAtom-Linyaps/linyaps/releases/tag/${finalAttrs.version}";
139 license = lib.licenses.lgpl3Plus;
140 platforms = lib.platforms.linux;
141 mainProgram = "ll-cli";
142 maintainers = with lib.maintainers; [
143 wineee
144 hhr2020
145 ];
146 };
147})