Skip to content

Conversation

@Dariqq
Copy link
Contributor

@Dariqq Dariqq commented Jun 6, 2024

Here is logic of your first code. There was not much I needed to do.

Compared to it I've renamed the argument to filename to be more explicit what it acts on, have replaced the last memcmp call with compare32 and added the comment from my first try to try to explain what the code should do.

Thanks for helping me with this, I have added you as Co-author because you did almost everything.

Haven't tested how it interacts which edge cases (like malformed manifest files) as these are symlinked from a read-only filesystem and i figured if this happens problems with fastfetch are probably not the top priority.

Speed wise it is now much faster from the 200-300ms total to ~5ms and the count is at a lot more accurate (but still not perfect) as (transitive) dependencies of installed packages are now also counted.

Closes #988.

@CarterLi
Copy link
Member

CarterLi commented Jun 6, 2024

What about renaming compare32 to compareHash

Instead of waiting for guix to parse the manifest file of a profile
parse it directly by counting "/gnu/store" entries and fitlering out duplicates.

The new implementation now also accounts for propagated-inputs of packages.

Co-authored-by: Carter Li <zhangsongcui3371@sina.com>
@Dariqq
Copy link
Contributor Author

Dariqq commented Jun 6, 2024

What about renaming compare32 to compareHash

Done.

@CarterLi CarterLi merged commit 999f52b into fastfetch-cli:dev Jun 6, 2024
@Dariqq
Copy link
Contributor Author

Dariqq commented Jun 6, 2024

Awesome. Thanks again for your help :)

@CarterLi
Copy link
Member

CarterLi commented Jun 6, 2024

Do you know how can I submit fastfetch to GNU guix repo?

@Dariqq
Copy link
Contributor Author

Dariqq commented Jun 6, 2024

https://guix.gnu.org/manual/devel/en/html_node/Contributing.html.

The tldr is: Create a patch for the guix repo and mail it to guix-patches@gnu.org.

I have a (somewhat) working package definition locally (which I used to test these changes) but it is a bit thrown together eg fastfetch cant find the extra dependencies at runtime yet. Also almost surely all the vendored dependencies would need to be packaged seperately.

@CarterLi
Copy link
Member

CarterLi commented Jun 6, 2024

I have a (somewhat) working package definition locally

Good

fastfetch cant find the extra dependencies at runtime yet

Maybe CMake failed to find these deps. You need to make sure that CMake prints Library: found XXX when configuring and fastfetch --list-features prints expected features.

@Dariqq
Copy link
Contributor Author

Dariqq commented Jun 6, 2024

cmake/pkgconfig finds them fine during build.

{
    "type": "Vulkan",
    "error": "dlopen libvulkan.so failed",
    "stat": 0
  },
  {
    "type": "OpenGL",
    "error": "dlopen glx failed",
    "stat": 1
  },
  {
    "type": "OpenCL",
    "error": "dlopen libOpenCL.so failed",
    "stat": 0
  },
...
  {
    "type": "Bluetooth",
    "error": "Failed to load DBus library",
    "stat": 0
  },
  {
    "type": "Sound",
    "error": "Failed to load libpulse.so",
    "stat": 0
  },

@CarterLi
Copy link
Member

CarterLi commented Jun 6, 2024

What does lurk or strace print?

@Dariqq
Copy link
Contributor Author

Dariqq commented Jun 6, 2024

Probably because these are not in the default path? Nix seems to wrap with LD_LIBRARY_PATH, maybe I need something similiar

EDIT: That seems to work. But currently it is a bit ugly as I write out the LD_LIBRARY_PATH manually

openat(AT_FDCWD, "/gnu/store/71clg810lzlv7xw6qmapb2353jjqgjxw-fastfetch-2.14.0/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0444, st_size=5555, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 5555, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f8ca9377000
close(4)                                = 0
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
munmap(0x7f8ca9377000, 5555)            = 0
openat(AT_FDCWD, "/gnu/store/71clg810lzlv7xw6qmapb2353jjqgjxw-fastfetch-2.14.0/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0444, st_size=5555, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 5555, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f8ca9377000
close(4)                                = 0
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
munmap(0x7f8ca9377000, 5555)            = 0
write(1, "Sound", 5)                    = 5
write(1, ": ", 2)                       = 2
write(1, "Failed to load libpulse.so", 26) = 26
``

@CarterLi
Copy link
Member

CarterLi commented Jul 1, 2024

Just saw someone submitted fastfetch to guix repo with a few features enabled but no LD_LIBRARY_PATH set

https://git.savannah.gnu.org/cgit/guix.git/commit/?id=ddb0401d82be8b1a43b6f47fb5794d08119f8d54

Does it really work?

@Dariqq
Copy link
Contributor Author

Dariqq commented Jul 1, 2024

I am not quite happy with the package yet.

Everything that does not need use the external libraries works.

However I am getting some errors when the guix fastfetch tries to dlopen the external libraries:

Bluetooth: Failed to load DBus library
OpenGL: dlopen egl failed

and strace suggests it is the LD_LIBRARY_PATH issue again.

Can look into submitting a patch later this week.
Writing out the LIBRARY_PATH manually is kind of awkward. Dynamic linking seems to work without manual intervention.

@Dariqq
Copy link
Contributor Author

Dariqq commented Jul 6, 2024

@CarterLi
Copy link
Member

CarterLi commented Jul 6, 2024

I don't like the idea. You shouldn't force people to install wayland if they use only x11.

One solution is to set rpath in -DCMAKE_EXE_LINKER_FLAGS. See https://github.com/fastfetch-cli/fastfetch/blob/dev/CMakeLists.txt#L871-L873 for reference

@Dariqq
Copy link
Contributor Author

Dariqq commented Jul 6, 2024

I agree, but there is currently no way to declare optional dependencies in guix without creating a seperate package (i.e. fastfetch-wayland, fastfetch-x11, etc but there is a combinatorical explosion going on for all different combinations.

Also wrapping with LD_LIBRARARY_PATH would do the same as the resulting store would reference the specifc wayland package.

I saw some discussions to create a minimal variant (because there also might be problems with e.g. libnm when someone is using connman instead of networkmanager for networking). But there is then a problem what dependencies (if any?) should be included in such a variant. Some might not use dbus, gsettings or on a server any displayserver at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Make guix package manager detection faster

2 participants