Subject: [bug#49969] [PATCH v2 3/7] gnu: freedesktop: Add greetd 0.7.0

From: Xinglu Chen <[email-masked]>
Date: Wed, 11 Aug 2021 13:29:06 +0200

On Tue, Aug 10 2021, muradm wrote:

> * gnu/packages/freedesktop.scm (greetd): Add greetd 0.7.0
> ---
>  gnu/packages/freedesktop.scm | 80 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 80 insertions(+)
>
> diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
> index 693a79c738..631d36e765 100644
> --- a/gnu/packages/freedesktop.scm
> +++ b/gnu/packages/freedesktop.scm
> @@ -24,6 +24,7 @@
>  ;;; Copyright © 2020 Raghav Gururajan <[email-masked]>
>  ;;; Copyright © 2021 Brendan Tildesley <[email-masked]>
>  ;;; Copyright © 2021 pineapples <[email-masked]>
> +;;; Copyright © 2021 muradm <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -46,6 +47,7 @@
>    #:use-module (guix packages)
>    #:use-module (guix download)
>    #:use-module (guix git-download)
> +  #:use-module (guix build-system cargo)
>    #:use-module (guix build-system cmake)
>    #:use-module (guix build-system gnu)
>    #:use-module (guix build-system meson)
> @@ -62,6 +64,7 @@
>    #:use-module (gnu packages check)
>    #:use-module (gnu packages cmake)
>    #:use-module (gnu packages compression)
> +  #:use-module (gnu packages crates-io)
>    #:use-module (gnu packages cryptsetup)
>    #:use-module (gnu packages databases)
>    #:use-module (gnu packages disk)
> @@ -862,6 +865,83 @@ that require it.  It also provides a universal seat management library that
>  allows applications to use whatever seat management is available.")
>      (license license:expat)))
>  
> +(define-public greetd
> +  (package
> +    (name "greetd")
> +    (version "0.7.0")
> +    (home-page "https://git.sr.ht/~kennylevinsen/greetd")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url home-page)
> +                    (commit version)))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32 "0lmwr5ld9x2wlq00i7mjgm9by8zndiq9girj8g93k0kww9zbgr3g"))))
> +    (build-system cargo-build-system)
> +    (arguments
> +     `(#:cargo-inputs
> +       (("rust-nix" ,rust-nix-0.17)
> +        ("rust-pam-sys" ,rust-pam-sys-0.5.6)
> +        ("rust-rpassword" ,rust-rpassword-4)
> +        ("rust-users" ,rust-users-0.9)
> +        ("rust-serde" ,rust-serde-1)
> +        ("rust-serde-json" ,rust-serde-json-1)
> +        ("rust-libc" ,rust-libc-0.2)
> +        ("rust-tokio" ,rust-tokio-0.2)
> +        ("rust-getopts" ,rust-getopts-0.2)
> +        ("rust-thiserror" ,rust-thiserror-1)
> +        ("rust-async-trait" ,rust-async-trait-0.1)
> +        ("rust-enquote" ,rust-enquote-1))
> +       #:phases
> +       (modify-phases %standard-phases
> +         ;; once https://todo.sr.ht/~kennylevinsen/greetd/25
> +         ;; is solved, below patch can be removed
> +         (add-after 'unpack 'patch-terminal-switch
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (substitute* "greetd/src/server.rs"
> +               (("switch: true,")
> +                "switch: false,"))))
> +         (delete 'package)
> +         (replace 'install
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (bin (string-append out "/bin"))
> +                    (sbin (string-append out "/sbin"))
> +                    (share (string-append out "/share"))
> +                    (man (string-append share "/man"))
> +                    (man1 (string-append man "/man1"))
> +                    (man5 (string-append man "/man5"))
> +                    (man7 (string-append man "/man7"))
> +                    (release "target/release")
> +                    (greetd-bin (string-append release "/greetd"))
> +                    (agreety-bin (string-append release "/agreety")))
> +               (install-file greetd-bin sbin)
> +               (install-file agreety-bin bin)
> +               (mkdir-p man1)
> +               (mkdir-p man5)
> +               (mkdir-p man7)

No need to ‘mkdir-p’ if you will call ‘install-file’ on the directory.

> +               (with-directory-excursion "man"
> +                 (system "scdoc < greetd-1.scd > greetd.1")
> +                 (system "scdoc < greetd-5.scd > greetd.5")
> +                 (system "scdoc < greetd-ipc-7.scd > greetd-ipc.7")
> +                 (system "scdoc < agreety-1.scd > agreety.1"))
> +               (install-file "man/greetd.1" man1)
> +               (install-file "man/greetd.5" man5)
> +               (install-file "man/greetd-ipc.7" man7)
> +               (install-file "man/agreety.1" man1)

Why not put these four lines inside the (with-directory-excursion "man"
…) form, and remove the "man" prefix?

> +               #t))))))

Phases don’t need to return #t once the ‘core-updates’ branch gets
merged.

> +    (native-inputs
> +     `(("linux-pam" ,linux-pam)
> +       ("scdoc" ,scdoc)))
> +    (synopsis
> +     "greetd is a minimal and flexible login manager daemon
> +that makes no assumptions about what you want to launch.")

The synosis is a bit long, maybe

  Minimal and flexible login manager daemon

> +    (description
> +     "greetd is a minimal and flexible login manager daemon
> +that makes no assumptions about what you want to launch.")

“what you want to launch” sounds a bit vague, is it referring to desktop
environment, window manager, or something else?