Skip to content

Commit

Permalink
cosmic-ext-observatory: add in the nvtop dependency using suspicious …
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
lilyinstarlight committed Dec 12, 2024
1 parent 284d3dd commit f17b117
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pkgs/cosmic-ext-observatory/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
fetchFromGitHub,
libcosmicAppHook,
rustPlatform,
gnused,
gnutar,
jq,
just,
mesa,
stdenv,
udev,
nix-update-script,
}:

Expand Down Expand Up @@ -41,23 +46,62 @@ 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"
(placeholder "out")
"--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; {
Expand Down

0 comments on commit f17b117

Please sign in to comment.