[PATCH] gnu: Add emacs-dtache

DoneSubmitted by Niklas Eklund.
Details
3 participants
  • Nicolas Goaziou
  • Maxime Devos
  • Niklas Eklund
Owner
unassigned
Severity
normal
N
N
Niklas Eklund wrote on 15 Jan 09:35 +0100
(address . guix-patches@gnu.org)
87pmotpfam.fsf@posteo.net
Hi,

I would like to contribute with my package dtache to guix.

/Niklas
From 3e04c575776a8f1fb4afa4df3146f63cd7b5a094 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 | 39 +++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)

Toggle diff (66 lines)
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index df469fa..ea97bac 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,42 @@ (define-public emacs-cmake-font-lock
 according to their use.")
       (license license:gpl3+))))
 
+(define-public emacs-dtache
+  (package
+    (name "emacs-dtache")
+    (version "0.2")
+    (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 "1dnwdkd9bhrvspmp83k40ji1ylm6dhbj4hfhmscjd8s1f4n6jyym"))))
+    (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* (#: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"))))))))
+    (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
M
M
Maxime Devos wrote on 15 Jan 12:11 +0100
d11eb6723931c9e8c8f8e87faa08b833de4d247c.camel@telenet.be
Hi,

Niklas Eklund schreef op za 15-01-2022 om 08:35 [+0000]:
Toggle quote (9 lines)
> +      (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.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeKr9hccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7u1nAP4jvOn/3MBKgtIdQquA2sosGhoh
a2oZtPUZvaDRwI2zPwEAvb0oDS6iYqEGFmhH66b/+ie9zVUo3dRSTjXSic6YoAk=
=C3+R
-----END PGP SIGNATURE-----


N
N
Niklas Eklund wrote on 15 Jan 15:31 +0100
(address . 53279@debbugs.gnu.org)
87czktkr40.fsf@posteo.net
Maxime Devos <maximedevos@telenet.be> writes:
Toggle quote (27 lines)
> 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
From a0bba7a205bcf542804fe2c67f7d2a5192e90489 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(-)

Toggle diff (64 lines)
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index f7022d1f34..8d86429c02 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.2")
+    (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
+                "1dnwdkd9bhrvspmp83k40ji1ylm6dhbj4hfhmscjd8s1f4n6jyym"))))
+    (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
N
N
Niklas Eklund wrote on 15 Jan 18:08 +0100
(address . 53279@debbugs.gnu.org)
877db13p1e.fsf@posteo.net
Niklas Eklund <niklas.eklund@posteo.net> writes:

Toggle quote (38 lines)
> 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
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(-)

Toggle diff (64 lines)
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
N
N
Nicolas Goaziou wrote on 15 Jan 21:25 +0100
(name . Niklas Eklund)(address . niklas.eklund@posteo.net)(address . 53279@debbugs.gnu.org)
87a6fw3fxa.fsf@nicolasgoaziou.fr
Hello,

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

Toggle quote (5 lines)
> +(define-public emacs-dtache
> + (package
> + (name "emacs-dtache")
> + (version "0.3")

Thank you.

Toggle quote (3 lines)
> + (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:

Toggle snippet (8 lines)
(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")))))

Toggle quote (11 lines)
> + (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:

Toggle snippet (10 lines)
(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")))))))

Could you send an updated patch?

Regards,
--
Nicolas Goaziou
N
N
Nicolas Goaziou wrote on 16 Jan 23:56 +0100
(name . Niklas Eklund)(address . niklas.eklund@posteo.net)(address . 53279@debbugs.gnu.org)
87tue3i92p.fsf@nicolasgoaziou.fr
Hello,

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

Toggle quote (2 lines)
> 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:

Toggle snippet (45 lines)
(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+)))


Unfortunately, one test is failing with the following output:

Toggle snippet (17 lines)
.......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................

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

Regards,
--
Nicolas Goaziou
N
N
Nicolas Goaziou wrote 5 days ago
(name . Niklas Eklund)(address . niklas.eklund@posteo.net)(address . 53279-done@debbugs.gnu.org)
87k0evabwd.fsf@nicolasgoaziou.fr
Hello,

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

Toggle quote (5 lines)
> 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,
--
Nicolas Goaziou
Closed
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 53279@debbugs.gnu.org