diff mbox series

[bug#53279] gnu: Add emacs-dtache

Message ID 877db13p1e.fsf@posteo.net
State Accepted
Headers show
Series [bug#53279] gnu: Add emacs-dtache | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Niklas Eklund Jan. 15, 2022, 5:08 p.m. UTC
Niklas Eklund <niklas.eklund@posteo.net> writes:

> Maxime Devos <maximedevos@telenet.be> writes:
>
>> Hi,
>>
>> Niklas Eklund schreef op za 15-01-2022 om 08:35 [+0000]:
>>> +      (modify-phases %standard-phases
>>> +        (add-before 'install 'install-dtache-env
>>> +          (lambda* (#:key outputs #:allow-other-keys)
>>> +            (let* ((out  (assoc-ref outputs "out"))
>>> +                   (bin  (string-append out "/bin")))
>>> +              (mkdir-p bin)
>>> +              (copy-file "dtache-env"
>>> +                         (string-append bin "/dtache-env"))))))))
>>
>> FWIW you can eliminate (#:key outputs #:allow-other-keys) here:
>>
>>    ,#~(modify-phases %standard-phases
>>         (add-before 'install 'install-dtache-env
>>           (lambda _
>>             (let ((bin (string-append #$output "/bin)))
>>               (mkdir-p bin)
>>               (copy-file "dtache-env"
>>                          (string-append bin "/dtache-env"))))))))
>>
>> YMMV on whether that's an improvement or not -- technically
>> they are equivalent.
>>
>> Greetings,
>> Maxime.
>
> Hi Maxime,
>
> thanks for the suggestion :). Here is a new patch with the changes.
>
> Cheers
> Niklas
>

Hi again,

there is an even newer version of the package available so here is a
patch featuring version 0.3 instead of version 0.2 :)

/Niklas

Comments

Nicolas Goaziou Jan. 15, 2022, 8:25 p.m. UTC | #1
Hello,

Niklas Eklund <niklas.eklund@posteo.net> writes:

> +(define-public emacs-dtache
> +  (package
> +    (name "emacs-dtache")
> +    (version "0.3")

Thank you.

> +    (native-inputs (list emacs-ert-runner))
> +    (inputs (list dtach))

Nitpick: native-inputs and inputs are usually located after arguments
and build-system.

Adding "dtach" to input is insufficient. You also need to set
`dtache-dtach-program' so it points to the dtach program provided as an
input. Likewise, you also need to set `dtache-shell-program' so it
points to the bash from the package inputs.

For example, you can do the first step with the following phase:

--8<---------------cut here---------------start------------->8---
(add-after 'unpack 'locate-dtach
  (lambda* (#:key inputs #:allow-other-keys)
    (make-file-writable "dtache.el")
    (emacs-substitute-variables "dtache.el"
      ("dtache-dtach-program"
       (search-input-file inputs "/bin/dtach")))))
--8<---------------cut here---------------end--------------->8---

> +    (arguments
> +     `(#:test-command '("ert-runner")
> +       #:phases
> +       ,#~(modify-phases %standard-phases
> +            (add-before 'install 'install-dtache-env
> +              (lambda _
> +                (let ((bin (string-append #$output "/bin")))
> +                  (mkdir-p bin)
> +                  (copy-file "dtache-env"
> +                             (string-append bin "/dtache-env"))))))))

You can simplify the arguments further:

--8<---------------cut here---------------start------------->8---
(arguments
 (list
  #:test-command #~(list "ert-runner")
  #:phases
  #~(modify-phases %standard-phases
      (add-before 'install 'install-dtache-env
        (lambda _
          (install-file "dtache-env" (string-append #$output "/bin")))))))
--8<---------------cut here---------------end--------------->8---

Could you send an updated patch?

Regards,
Nicolas Goaziou Jan. 16, 2022, 10:56 p.m. UTC | #2
Hello,

Niklas Eklund <niklas.eklund@posteo.net> writes:

> Ah good to know, I have updated that part now.

Thanks for the update. I merged the consecutive phases with
emacs-substitute-variables for clarity, and enabled tests with "#:tests?
#true". I'm sending the package definition in its current state:

--8<---------------cut here---------------start------------->8---
(define-public emacs-dtache
  (package
    (name "emacs-dtache")
    (version "0.3")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://gitlab.com/niklaseklund/dtache")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0f2yxrqfkslif2y88x9vlpshadifppxw6yl1rrf1qzfjy6cv144n"))))
    (arguments
     (list
      #:tests? #true
      #:test-command #~(list "ert-runner")
      #:phases
      #~(modify-phases %standard-phases
          (add-before 'install 'install-dtache-env
            (lambda _
              (install-file "dtache-env" (string-append #$output "/bin"))))
          (add-after 'unpack 'locate-dtach
            (lambda* (#:key inputs #:allow-other-keys)
              (make-file-writable "dtache.el")
              (emacs-substitute-variables "dtache.el"
                ("dtache-env"
                 (string-append #$output "/bin/dtache-env"))
                ("dtache-dtach-program"
                 (search-input-file inputs "/bin/dtach"))
                ("dtache-shell-program"
                 (search-input-file inputs "/bin/bash"))))))))
    (build-system emacs-build-system)
    (native-inputs (list emacs-ert-runner))
    (inputs (list dtach))
    (home-page "https://gitlab.com/niklaseklund/dtache")
    (synopsis "Run and interact with detached shell commands")
    (description
     "The dtache package allows users to run shell commands
detached from Emacs.  These commands are launched in sessions, using the
program dtach.")
(license license:gpl3+)))
--8<---------------cut here---------------end--------------->8---


Unfortunately, one test is failing with the following output:

--8<---------------cut here---------------start------------->8---
.......Test dtache-test-dtach-command backtrace:


Test dtache-test-dtach-command condition:

    (ert-test-failed
     ((should
       (equal expected-concat
	      (dtache-dtach-command session t)))
      :form
      (equal "dtach -c /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.socket -z bash -c \\{\\ dtache-env\\ ls\\\\\\ -la\\;\\ \\}\\ 2\\>\\&1\\ \\|\\ tee\\ /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.log" "/gnu/store/prhk20g1yp8qbn4rj5h25cdpimxynq3d-dtach-0.9/bin/dtach -c /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.socket -z bash -c \\{\\ dtache-env\\ ls\\\\\\ -la\\;\\ \\}\\ 2\\>\\&1\\ \\|\\ tee\\ /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.log")
      :value nil :explanation
      (arrays-of-different-length 268 326 "dtach -c /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.socket -z bash -c \\{\\ dtache-env\\ ls\\\\\\ -la\\;\\ \\}\\ 2\\>\\&1\\ \\|\\ tee\\ /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.log" "/gnu/store/prhk20g1yp8qbn4rj5h25cdpimxynq3d-dtach-0.9/bin/dtach -c /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.socket -z bash -c \\{\\ dtache-env\\ ls\\\\\\ -la\\;\\ \\}\\ 2\\>\\&1\\ \\|\\ tee\\ /tmp/guix-build-emacs-dtache-0.3.drv-0/dtache7Dw27E/sessions/7695240f5262181009a25db676161039.log" first-mismatch-at 0)))

F................
--8<---------------cut here---------------end--------------->8---

Do you think this can be fixed? Or shall we skip that test?

Regards,
Nicolas Goaziou Jan. 19, 2022, 5:11 p.m. UTC | #3
Hello,

Niklas Eklund <niklas.eklund@posteo.net> writes:

> I think it make sense to fix it, it was a small typo that I hadn't
> captured before. I have created a new patch, where I have updated the
> package definition to use a specific commit which solves the issue with
> the failing test.

I added a comment explaining why we do not use a tagged release, fixed
indentation, and applied your patch. Thank you.

Regards,
diff mbox series

Patch

From ec51862795bc3f746cd1cb6e7472826a204ad1f2 Mon Sep 17 00:00:00 2001
From: Niklas Eklund <niklas.eklund@posteo.net>
Date: Thu, 13 Jan 2022 18:19:57 +0100
Subject: [PATCH] gnu: Add emacs-dtache package.

---
 gnu/packages/emacs-xyz.scm | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index f7022d1f34..5020c4ba43 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -78,7 +78,7 @@ 
 ;;; Copyright © 2020 Eric Bavier <bavier@posteo.net>
 ;;; Copyright © 2020, 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
 ;;; Copyright © 2020 Peng Mei Yu <i@pengmeiyu.com>
-;;; Copyright © 2020, 2021 Niklas Eklund <niklas.eklund@posteo.net>
+;;; Copyright © 2020, 2021, 2022 Niklas Eklund <niklas.eklund@posteo.net>
 ;;; Copyright © 2020 Marco Grassi <marco.au.grassi98@protonmail.com>
 ;;; Copyright © 2020 Tomás Ortín Fernández <tomasortin@mailbox.org>
 ;;; Copyright © 2020, 2021 Zhu Zihao <all_but_last@163.com>
@@ -214,6 +214,7 @@  (define-module (gnu packages emacs-xyz)
   #:use-module (gnu packages password-utils)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages sphinx)
+  #:use-module (gnu packages screen)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages shells)
   #:use-module (gnu packages shellutils)
@@ -23366,6 +23367,40 @@  (define-public emacs-cmake-font-lock
 according to their use.")
       (license license:gpl3+))))
 
+(define-public emacs-dtache
+  (package
+    (name "emacs-dtache")
+    (version "0.3")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://gitlab.com/niklaseklund/dtache")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0f2yxrqfkslif2y88x9vlpshadifppxw6yl1rrf1qzfjy6cv144n"))))
+    (native-inputs (list emacs-ert-runner))
+    (inputs (list dtach))
+    (arguments
+     `(#:test-command '("ert-runner")
+       #:phases
+       ,#~(modify-phases %standard-phases
+            (add-before 'install 'install-dtache-env
+              (lambda _
+                (let ((bin (string-append #$output "/bin")))
+                  (mkdir-p bin)
+                  (copy-file "dtache-env"
+                             (string-append bin "/dtache-env"))))))))
+    (build-system emacs-build-system)
+    (home-page "https://gitlab.com/niklaseklund/dtache")
+    (synopsis "Run and interact with detached shell commands")
+    (description
+     "The dtache package allows users to run shell commands
+detached from Emacs.  These commands are launched in sessions, using the
+program dtach.")
+    (license license:gpl3+)))
+
 (define-public emacs-dtrt-indent
   (package
     (name "emacs-dtrt-indent")
-- 
2.32.0