Subject: Re: [PATCH] gnu: Add fastfetch.

From: Dariqq <[email-masked]>
Date: Thu, 20 Jun 2024 18:00:45 +0000

Hi Richard,

On 20.06.24 17:59, Richard Sent wrote:
> Hi Dariqq,
> 
> Dariqq <[email-masked]> writes:
> 
>> - For LM detection with logind "/var/run/systemd/sessions/" is used,
>>    however on (my) guix system that directory does not exist but is at
>>    "/run/systemd/sessions/" instead. Currently i have an extra
>>    substitute* to fix this in src/detection/lm/lm_linux.c but this
>>    might worth reporting to upstream. I havent got around to do this
>>   yet.
> 
> As implemented would this hurt fastfetch's login manager detection on
> foreign distros? If so I think reporting to upstream would be ideal.
> 

On my fedora and debian systems /run is symlinked to /var/run. Not sure 
on other systems. Sounds like this should be moved upstream.

>> Thoughts?
> 
> Sounds like yours is a lot more complete. I think it is best to merge
> your version. What else is left to do?
> 

I would not really like hijacking the patch like this from you. But i'll 
happily share what I have so far:

my yyjson package:

I am not sure where to put this? just c.scm? or somewhere else?
In the debian package they also build html docs. Tried that but they 
were not automatically installed with the standard phases and i am not 
sure if they are worth it. (maybe in a seperate output?)

#+begin_src scheme
(define-public yyjson
   (package
     (name "yyjson")
     (version "0.9.0")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
	     (url "https://github.com/ibireme/yyjson")
	     (commit version)))
        (file-name (git-file-name name version))
        (sha256
	(base32
	 "169rqh7mh01g5j4qkqjgfmgnyqjf9r8qxiywf4jkgcb7ln4j64w9"))))
     (arguments
      (list #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON"
				     "-DYYJSON_BUILD_TESTS=ON")))
     (build-system cmake-build-system)
     (home-page "https://github.com/ibireme/yyjson")
     (synopsis "A high performance JSON library written in ANSI C.")
     (description "A high performance JSON library written in ANSI C. 
Some features iclude
@itemize
@item Fast: can read or write gigabytes per second JSON data on modern CPUs.
@item Portable: complies with ANSI C (C89) for cross-platform compatibility.
@item Strict: complies with RFC 8259 JSON standard, ensuring strict 
number format and UTF-8 validation.
@item Extendable: offers options to allow comments, trailing commas, 
NaN/Inf, and custom memory allocator.
@item Accuracy: can accurately read and write int64, uint64, and double 
numbers.
@item Flexible: supports unlimited JSON nesting levels, \u0000 
characters, and non null-terminated strings.
@item Manipulation: supports querying and modifying using JSON Pointer, 
JSON Patch and JSON Merge Patch.
@item Developer-Friendly: easy integration with only one .h and one .c file.
@end itemize")
     (license license:expat)))
#+end_src

my fastfetch package:

For fastfetch i am following the nixos package to enable everything but 
mesa and directx. Also these are a lot of them  and with the wrapper 
guix install fastfetch would need to also download all of the other 
libraries. It would be great to create more modular packages for 
something like this as enabling everything like this will e.g now always 
pull in xfconf (only needed when using xfce), the x11/wayland libraries 
even if one is on a headless server, etc. I guess that is a beneift for 
dlopen but does not really work well on guix system.

Feel free to steal some things.

#+begin_src scheme
(define-public fastfetch
   (package
     (name "fastfetch")
     (version "2.16.0")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
	     (url "https://github.com/fastfetch-cli/fastfetch")
	     (commit version)))
        (file-name (git-file-name name version))
        (sha256
	(base32
	 "112dvfx7gvp6n20i1lkd0jbh897jf7bxjxq96bj4099j3x313y3m"))
        (modules '((guix build utils)))
        (snippet
         '(begin
            (delete-file-recursively "src/3rdparty")))))
     (arguments
      (list
       #:configure-flags #~(list
			   "-DBUILD_TESTS=ON"
			   "-DINSTALL_LICENSE=OFF"
			   "-DENABLE_SYSTEM_YYJSON=YES"
			   "-DENABLE_PROPRIETARY_GPU_DRIVER_API=OFF"
			   "-DENABLE_DIRECTX_HEADERS=false"
			   "-DENABLE_OSMESA=false"
			   (string-append "-DCUSTOM_PCI_IDS_PATH="
					  #$(this-package-input "hwdata")
					  "/share/hwdatay/pci.ids")
			   (string-append "-DCUSTOM_AMDGPU_IDS_PATH="
					  #$(this-package-input "libdrm")
					  "/share/libdrm/amdgpu.ids"))
       #:phases
       #~(modify-phases %standard-phases
	  (add-after 'unpack 'fix-logind-session-path
	    (lambda* _
	      (substitute* "src/detection/lm/lm_linux.c"
		  (("/var/run/systemd/sessions/") "/run/systemd/sessions/"))))
	  (add-after 'install 'wrap-programs
	    (lambda* _
	      (let ((ld-libs
		     '#$(map
			 (lambda (label)
                            (file-append (this-package-input label) "/lib"))
			 '("chafa"
			   "dbus"
			   "dconf"
			   "ddcutil"
			   "glib"
			   "imagemagick"
			   "libdrm"
			   "libglvnd"
			   "libx11"
			   "libxcb"
			   "libxrandr"
			   "network-manager"
			   "ocl-icd"
			   "opencl-headers"
			   "pulseaudio"
			   "rpm"
			   "sqlite"
			   "vulkan-loader"
			   "wayland"
			   "xfconf"
			   "zlib"))))
		(for-each
		 (lambda (prog)
		   (wrap-program (string-append #$output "/bin/" prog)
		     `("LD_LIBRARY_PATH" prefix ,ld-libs)))
		 '("fastfetch" "flashfetch"))))))))
     (native-inputs
      (list
       pkg-config
       python))
     (inputs
      (list
       bash-minimal ;; for wrap-program
       chafa
       dbus
       dconf
       ddcutil
       glib
       hwdata
       imagemagick
       libdrm
       libglvnd
       libx11
       libxcb
       libxrandr
       network-manager
       ocl-icd
       opencl-headers
       pulseaudio
       rpm
       sqlite
       vulkan-loader
       wayland
       xfconf
       yyjson
       zlib))
     (build-system cmake-build-system)
     (home-page "https://github.com/fastfetch-cli/fastfetch")
     (synopsis "Fast neofetch-like system information tool")
     (description "Fast neofetch-like system information tool.")
     (license license:expat)))
#+end_src

> Is there anything I can help with?

I have built with "-DBINARY_LINK_TYPE=dynamic" to dynamically link the 
dependencies instead. There was an error due to fastfetch wanting a 
newer version of ddcutil. Havent looked into how complicated that is to 
update yet.

On a related note dynamically linking would avoid the (kind of awkward) 
wrapper. Are there benefits/downsides to using that instead?

I hope the formating turned out ok for the code blocks