From b0a982abeb698997bd124b56cb2d33f2fdbd5dac Mon Sep 17 00:00:00 2001 From: David Larsson Date: Tue, 23 May 2023 05:31:06 +0200 Subject: [PATCH 1/3] gnu: Add pydaemon * gnu/packages/bash.scm (pydaemon): new variable. --- gnu/packages/bash.scm | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm index 43f38303f7..1650fdeb72 100644 --- a/gnu/packages/bash.scm +++ b/gnu/packages/bash.scm @@ -26,16 +26,19 @@ (define-module (gnu packages bash) #:use-module ((guix licenses) #:prefix license:) #:use-module (gnu packages) + #:use-module (gnu packages admin) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) #:use-module (gnu packages elf) #:use-module (gnu packages ncurses) + #:use-module (gnu packages networking) #:use-module (gnu packages readline) #:use-module (gnu packages bison) #:use-module (gnu packages linux) #:use-module (gnu packages libffi) #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python) #:use-module (gnu packages guile) #:use-module (gnu packages version-control) #:use-module (gnu packages less) @@ -46,6 +49,7 @@ (define-module (gnu packages bash) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (guix store) + #:use-module (guix build-system copy) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:autoload (guix gnupg) (gnupg-verify*) @@ -482,3 +486,57 @@ (define-public blesh which replaces the default GNU Readline. It adds syntax highlighting, auto suggestions, vim modes, and more to Bash interactive sessions.") (license license:bsd-3))) + +(define-public pydaemon + (let ((commit "dae2798a2c1caa56025c6da69c0d464f70d9c79a") + (revision "0")) + (package + (name "pydaemon") + (version (git-version "0.0.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (commit commit) + (url "https://gitlab.com/methuselah-0/pydaemon.git"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1cbg48ljyjqw1vxcb0sqhg9cxx0vgs6ggsdg8yvj441s6gakp2sh")))) + (build-system trivial-build-system) + (arguments + (list #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (with-directory-excursion #$(package-source this-package) + (mkdir-p (string-append (assoc-ref %outputs "out") "/bin")) + (copy-file "pydaemon.py" (string-append (assoc-ref %outputs "out") + "/bin/pydaemon.py")) + (copy-file "py-net-daemon.py" (string-append (assoc-ref %outputs "out") + "/bin/py-net-daemon.py")) + (copy-file "pydaemon.sh" (string-append (assoc-ref %outputs "out") + "/bin/pydaemon.sh")) + ;; Substitute paths to binaries directly in the shell scripts + (substitute* (find-files (string-append #$output "/bin") "\\.sh$") + (("flock ") (string-append #$(this-package-input "util-linux") "/bin/flock ")) + (("socat ") (string-append #$(this-package-input "socat") "/bin/socat ")) + (("nc ") (string-append #$(this-package-input "netcat") "/bin/nc ")) + (("( )(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _) + (string-append pre #$(this-package-input "coreutils") "/bin/" command " ")) + (("(\\()(mkdir|cat|sleep|chown|id|kill|dirname) " all pre command _) + (string-append pre #$(this-package-input "coreutils") "/bin/" command " ")) + (("(python3) " library _) + (string-append #$(file-append (this-package-input "python") + "/bin/python" + (version-major+minor + (package-version + (this-package-input + "python")))) + " "))))))) + (inputs (list coreutils netcat python socat util-linux)) + (synopsis "Use python from bash") + (description "With pydaemon you can pipe strings of python code to one +or multiple persistent python processes that keeps state, and get the results +back as strings. Can be used over either of a unix or tcp socket.") + (home-page "https://gitlab.com/methuselah-0/pydaemon") + (license license:gpl3)))) -- 2.39.1