uwufetch: 2.0 -> 2.1

This commit is contained in:
rewine 2023-02-15 01:11:52 +08:00
parent 349eefb89f
commit c7c8258c27
No known key found for this signature in database
GPG key ID: AABB329787290824
2 changed files with 20 additions and 40 deletions

View file

@ -1,20 +1,31 @@
{ lib, stdenv, fetchFromGitHub, fetchpatch, makeWrapper, viu }:
{ lib, stdenv, fetchFromGitHub, makeWrapper, viu }:
stdenv.mkDerivation rec {
pname = "uwufetch";
version = "2.0";
version = "2.1";
src = fetchFromGitHub {
owner = "TheDarkBug";
repo = pname;
rev = version;
hash = "sha256-2kktKdQ1xjQRIQR2auwveHgNWGaX1jdJsdlgWrH6l2g=";
hash = "sha256-cA8sajh+puswyKikr0Jp9ei+EpVkH+vhEp+pTerkUqA=";
};
patches = [
# cannot find images in /usr
./fix-paths.patch
];
postPatch = ''
substituteInPlace uwufetch.c \
--replace "/usr/lib/uwufetch" "$out/lib/uwufetch" \
--replace "/usr/local/lib/uwufetch" "$out/lib/uwufetch" \
--replace "/etc/uwufetch/config" "$out/etc/uwufetch/config"
# fix command_path for package manager (nix-store)
substituteInPlace fetch.c \
--replace "/usr/bin" "/run/current-system/sw/bin"
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace Makefile \
--replace "local/bin" "bin" \
--replace "local/lib" "lib" \
--replace "local/include" "include" \
--replace "local/share" "share"
'';
nativeBuildInputs = [ makeWrapper ];
@ -24,13 +35,9 @@ stdenv.mkDerivation rec {
installFlags = [
"DESTDIR=${placeholder "out"}"
"ETC_DIR=${placeholder "out"}"
"ETC_DIR=${placeholder "out"}/etc"
];
postPatch = ''
substituteAllInPlace uwufetch.c
'';
postFixup = ''
wrapProgram $out/bin/uwufetch \
--prefix PATH ":" ${lib.makeBinPath [ viu ]}
@ -40,6 +47,7 @@ stdenv.mkDerivation rec {
description = "A meme system info tool for Linux";
homepage = "https://github.com/TheDarkBug/uwufetch";
license = licenses.gpl3Plus;
platforms = platforms.unix;
maintainers = with maintainers; [ lourkeur ];
};
}

View file

@ -1,28 +0,0 @@
diff --git a/uwufetch.c b/uwufetch.c
index f2d7857..8191888 100644
--- a/uwufetch.c
+++ b/uwufetch.c
@@ -160,9 +160,9 @@ void print_image(struct info* user_info) {
if (strcmp(user_info->os_name, "android") == 0)
sprintf(command, "viu -t -w 18 -h 8 /data/data/com.termux/files/usr/lib/uwufetch/%s.png 2> /dev/null", user_info->os_name); // image command for android
else if (strcmp(user_info->os_name, "macos") == 0)
- sprintf(command, "viu -t -w 18 -h 8 /usr/local/lib/uwufetch/%s.png 2> /dev/null", user_info->os_name);
+ sprintf(command, "viu -t -w 18 -h 8 @out@/lib/uwufetch/%s.png 2> /dev/null", user_info->os_name);
else
- sprintf(command, "viu -t -w 18 -h 8 /usr/lib/uwufetch/%s.png 2> /dev/null", user_info->os_name); // image command for other systems
+ sprintf(command, "viu -t -w 18 -h 8 @out@/lib/uwufetch/%s.png 2> /dev/null", user_info->os_name); // image command for other systems
}
printf("\n");
if (system(command) != 0) // if viu is not installed or the image is missing
@@ -587,9 +587,9 @@ void print_ascii(struct info* user_info) {
if (strcmp(user_info->os_name, "android") == 0)
sprintf(ascii_file, "/data/data/com.termux/files/usr/lib/uwufetch/ascii/%s.txt", user_info->os_name);
else if (strcmp(user_info->os_name, "macos") == 0)
- sprintf(ascii_file, "/usr/local/lib/uwufetch/ascii/%s.txt", user_info->os_name);
+ sprintf(ascii_file, "@out@/lib/uwufetch/ascii/%s.txt", user_info->os_name);
else
- sprintf(ascii_file, "/usr/lib/uwufetch/ascii/%s.txt", user_info->os_name);
+ sprintf(ascii_file, "@out@/lib/uwufetch/ascii/%s.txt", user_info->os_name);
file = fopen(ascii_file, "r");
if (!file) {