nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 144 lines 3.8 kB view raw
1{ 2 lib, 3 rustPlatform, 4 stdenv, 5 fetchFromGitHub, 6 pkg-config, 7 wrapGAppsHook4, 8 gdk-pixbuf, 9 gtk4, 10 libdrm, 11 ocl-icd, 12 vulkan-loader, 13 vulkan-tools, 14 coreutils, 15 systemdMinimal, 16 nix-update-script, 17 nixosTests, 18 hwdata, 19 fuse3, 20 autoAddDriverRunpath, 21 fetchpatch, 22}: 23 24rustPlatform.buildRustPackage (finalAttrs: { 25 pname = "lact"; 26 version = "0.8.0"; 27 28 src = fetchFromGitHub { 29 owner = "ilya-zlobintsev"; 30 repo = "LACT"; 31 tag = "v${finalAttrs.version}"; 32 hash = "sha256-HsDVz9Wd1WoGWIB4Cs/GsvC7RDyHAeXfFGXZDWEmo/c="; 33 }; 34 35 cargoHash = "sha256-fgF7gOXxB9sQqA5H1hw6A0Fb5tTBPySAbSxVhcKVhcM="; 36 37 nativeBuildInputs = [ 38 pkg-config 39 wrapGAppsHook4 40 rustPlatform.bindgenHook 41 autoAddDriverRunpath 42 ]; 43 44 buildInputs = [ 45 gdk-pixbuf 46 gtk4 47 libdrm 48 ocl-icd 49 vulkan-loader 50 vulkan-tools 51 hwdata 52 fuse3 53 ]; 54 55 # we do this here so that the binary is usable during integration tests 56 RUSTFLAGS = lib.optionalString stdenv.targetPlatform.isElf ( 57 lib.concatStringsSep " " [ 58 "-C link-arg=-Wl,-rpath,${ 59 lib.makeLibraryPath [ 60 vulkan-loader 61 libdrm 62 ocl-icd 63 ] 64 }" 65 "-C link-arg=-Wl,--add-needed,${vulkan-loader}/lib/libvulkan.so" 66 "-C link-arg=-Wl,--add-needed,${libdrm}/lib/libdrm.so" 67 "-C link-arg=-Wl,--add-needed,${ocl-icd}/lib/libOpenCL.so" 68 ] 69 ); 70 71 patches = [ 72 (fetchpatch { 73 name = "fix-tests::snapshot_everything-due-to-outdated-hwdata-649.patch"; 74 url = "https://github.com/ilya-zlobintsev/LACT/commit/c9a59e48a36d590d7522c22bd15a8f9208bef0ee.patch"; 75 hash = "sha256-Ehq8vRosqyqpRPeabkdpBHBF6ONqSJHOeq3AXw8PXPU="; 76 }) 77 ]; 78 79 postPatch = '' 80 substituteInPlace lact-daemon/src/system.rs \ 81 --replace-fail 'Command::new("uname")' 'Command::new("${coreutils}/bin/uname")' 82 83 substituteInPlace lact-daemon/src/server/handler.rs \ 84 --replace-fail 'run_command("journalctl",' 'run_command("${systemdMinimal}/bin/journalctl",' 85 86 substituteInPlace lact-daemon/src/server/vulkan.rs \ 87 --replace-fail 'Command::new("vulkaninfo")' 'Command::new("${vulkan-tools}/bin/vulkaninfo")' 88 89 substituteInPlace res/lactd.service \ 90 --replace-fail ExecStart={lact,$out/bin/lact} 91 92 substituteInPlace res/io.github.ilya_zlobintsev.LACT.desktop \ 93 --replace-fail Exec={lact,$out/bin/lact} 94 95 # read() looks for the database in /usr/share so we use read_from_file() instead 96 substituteInPlace lact-daemon/src/server/handler.rs \ 97 --replace-fail 'Database::read()' 'Database::read_from_file("${hwdata}/share/hwdata/pci.ids")' 98 ''; 99 100 postInstall = '' 101 install -Dm444 res/lactd.service -t $out/lib/systemd/system 102 install -Dm444 res/io.github.ilya_zlobintsev.LACT.desktop -t $out/share/applications 103 install -Dm444 res/io.github.ilya_zlobintsev.LACT.svg -t $out/share/pixmaps 104 ''; 105 106 preFixup = '' 107 gappsWrapperArgs+=( 108 --prefix PATH : "${lib.makeBinPath [ vulkan-tools ]}" 109 ) 110 ''; 111 112 postFixup = lib.optionalString stdenv.targetPlatform.isElf '' 113 patchelf $out/bin/.lact-wrapped \ 114 --add-needed libvulkan.so \ 115 --add-needed libdrm.so \ 116 --add-needed libOpenCL.so \ 117 --add-rpath ${ 118 lib.makeLibraryPath [ 119 vulkan-loader 120 libdrm 121 ocl-icd 122 ] 123 } 124 ''; 125 126 passthru.updateScript = nix-update-script { }; 127 passthru.tests = { 128 inherit (nixosTests) lact; 129 }; 130 131 meta = { 132 description = "Linux GPU Configuration Tool for AMD and NVIDIA"; 133 homepage = "https://github.com/ilya-zlobintsev/LACT"; 134 license = lib.licenses.mit; 135 maintainers = with lib.maintainers; [ 136 figsoda 137 atemu 138 cything 139 johnrtitor 140 ]; 141 platforms = lib.platforms.linux; 142 mainProgram = "lact"; 143 }; 144})