diff --git a/pkgs/cosmic-ext-observatory/package.nix b/pkgs/cosmic-ext-observatory/package.nix index ca290397..f47f7cb3 100644 --- a/pkgs/cosmic-ext-observatory/package.nix +++ b/pkgs/cosmic-ext-observatory/package.nix @@ -3,8 +3,13 @@ fetchFromGitHub, libcosmicAppHook, rustPlatform, + gnused, + gnutar, + jq, just, + mesa, stdenv, + udev, nix-update-script, }: @@ -41,14 +46,46 @@ rustPlatform.buildRustPackage { }; }; + nvtop = fetchFromGitHub { + owner = "Syllo"; + repo = "nvtop"; + rev = "6e91c745cd051d902fc57e9195068df03eb192bb"; + hash = "sha256-1wKNBRlWAsXcWAXrNhYg2TBTxkE0QnMig0hunHkQLFA="; + }; + nativeBuildInputs = [ libcosmicAppHook + gnused + gnutar + jq just ]; + buildInputs = [ + mesa + udev + ]; + + postPatch = '' + nvtop_json="observatory-daemon/3rdparty/nvtop/nvtop.json" + nvtop_archive="target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/build/native/$(jq -r '(."source-url" | split("/"))[-1]' "$nvtop_json")" + mkdir -p "$(dirname "$nvtop_archive")" + tar -czf "$nvtop_archive" --absolute-names --transform="s,$nvtop,$(jq -r '.directory' "$nvtop_json")," --mode=+w "$nvtop" + sed -i -e 's/\("source-hash":\s*"\)[^"]*\("\)/\1'"$(sha256sum -b "$nvtop_archive" | cut -d' ' -f1)"'\2/' "$nvtop_json" + + substituteInPlace observatory-daemon/build/build.rs \ + --replace-fail "$(printf ' #[cfg(not(debug_assertions))]\n build_def.flag("-flto");\n')" "" + + substituteInPlace justfile \ + --replace-fail "'res'" "name / 'res'" \ + --replace-fail ' res/' ' observatory/res/' + ''; + dontUseJustBuild = true; dontUseJustCheck = true; + doCheck = false; + justFlags = [ "--set" "prefix" @@ -56,8 +93,15 @@ rustPlatform.buildRustPackage { "--set" "bin-src" "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/observatory" + "--set" + "dae-src" + "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/observatory-daemon" ]; + postInstall = '' + libcosmicAppWrapperArgs+=(--prefix PATH : $out/bin) + ''; + passthru.updateScript = nix-update-script { }; meta = with lib; {