linyaps: init at 1.9.12

rewine cb2ef2c9 8be63875

+235
+91
pkgs/by-name/li/linyaps/fix-host-path.patch
···
··· 1 + diff --git a/libs/oci-cfg-generators/src/linglong/oci-cfg-generators/container_cfg_builder.cpp b/libs/oci-cfg-generators/src/linglong/oci-cfg-generators/container_cfg_builder.cpp 2 + index 787e70cb..a71df46a 100644 3 + --- a/libs/oci-cfg-generators/src/linglong/oci-cfg-generators/container_cfg_builder.cpp 4 + +++ b/libs/oci-cfg-generators/src/linglong/oci-cfg-generators/container_cfg_builder.cpp 5 + @@ -19,6 +19,8 @@ 6 + #include <iomanip> 7 + #include <iostream> 8 + #include <vector> 9 + +#include <unordered_map> 10 + +#include <unordered_set> 11 + 12 + #include <sys/stat.h> 13 + #include <sys/types.h> 14 + @@ -432,19 +434,67 @@ ContainerCfgBuilder &ContainerCfgBuilder::bindHostRoot() noexcept 15 + 16 + ContainerCfgBuilder &ContainerCfgBuilder::bindHostStatics() noexcept 17 + { 18 + - std::vector<std::filesystem::path> statics{ 19 + - "/etc/machine-id", 20 + - // FIXME: support for host /etc/ssl, ref https://github.com/p11-glue/p11-kit 21 + - "/usr/lib/locale", 22 + - "/usr/share/fonts", 23 + - "/usr/share/icons", 24 + - "/usr/share/themes", 25 + - "/var/cache/fontconfig", 26 + + std::unordered_map<std::filesystem::path, std::string> statics{ 27 + + { "/etc/machine-id", "" }, 28 + + { "/usr/lib/locale", "" }, 29 + + { "/var/cache/fontconfig", "" }, 30 + + 31 + + { "/run/current-system/sw/share/X11/fonts", "/usr/share/fonts" }, 32 + + { "/run/current-system/sw/share/icons", "/usr/share/icons" }, 33 + + { "/run/current-system/sw/share/themes", "/usr/share/themes" }, 34 + }; 35 + 36 + hostStaticsMount = std::vector<Mount>{}; 37 + - for (const auto &loc : statics) { 38 + - bindIfExist(*hostStaticsMount, loc); 39 + + auto nixStorePaths = std::unordered_set<std::string>{}; 40 + + for (const auto &[source, destination] : statics) { 41 + + if (!std::filesystem::exists(source)) { 42 + + std::cerr << "[bindHostStatics] Skipping non-existent path: " << source << std::endl; 43 + + continue; 44 + + } 45 + + 46 + + bindIfExist(*hostStaticsMount, source, destination); 47 + + 48 + + std::string sourcePathPrefix = "/run/current-system/sw/share/"; 49 + + std::string nixStorePrefix = "/nix/store/"; 50 + + 51 + + if (source.string().rfind(sourcePathPrefix, 0) != 0) 52 + + continue; 53 + + 54 + + std::error_code ec; 55 + + for (const std::filesystem::directory_entry &dir_entry : 56 + + std::filesystem::recursive_directory_iterator(source, std::filesystem::directory_options::skip_permission_denied, ec)) 57 + + { 58 + + if (ec) { 59 + + std::cerr << "[bindHostStatics] Failed to iterate directory: " << source << ", error: " << ec.message() << std::endl; 60 + + break; 61 + + } 62 + + 63 + + if (!dir_entry.is_symlink(ec) || ec) { 64 + + if (ec) 65 + + std::cerr << "[bindHostStatics] Failed to check symlink: " << dir_entry.path() << ", error: " << ec.message() << std::endl; 66 + + continue; 67 + + } 68 + + 69 + + std::filesystem::path targetPath = std::filesystem::canonical(dir_entry.path(), ec); 70 + + if (ec) { 71 + + std::cerr << "[bindHostStatics] Failed to resolve symlink: " << dir_entry.path() << ", error: " << ec.message() << std::endl; 72 + + continue; 73 + + } 74 + + 75 + + std::string target = targetPath.string(); 76 + + if (target.rfind(nixStorePrefix, 0) != 0) 77 + + continue; 78 + + 79 + + auto endPos = target.find('/', nixStorePrefix.length()); 80 + + if (endPos != std::string::npos) 81 + + nixStorePaths.insert(target.substr(0, endPos)); 82 + + else 83 + + nixStorePaths.insert(target); 84 + + } 85 + + } 86 + + 87 + + for (const std::string &path : nixStorePaths) { 88 + + bindIfExist(*hostStaticsMount, path); 89 + } 90 + 91 + return *this;
+144
pkgs/by-name/li/linyaps/package.nix
···
··· 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 + 40 + stdenv.mkDerivation (finalAttrs: { 41 + pname = "linyaps"; 42 + version = "1.9.12"; 43 + 44 + src = fetchFromGitHub { 45 + owner = "OpenAtom-Linyaps"; 46 + repo = finalAttrs.pname; 47 + tag = finalAttrs.version; 48 + hash = "sha256-BNP/CenPXMuEixEleil9zB08qLn/SZ9Ur/Im4MQy5nE="; 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; [ wineee ]; 143 + }; 144 + })