diff --git a/.gitignore b/.gitignore index 10c26b5..6ee0974 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ scratch/ /.dir-locals.el +/gnu +*-tarball-pack.tar.gz +/mybin diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce944c7 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Ordo + +Ordo ab chao: from chaos, comes order. + +## Installing Dependencies + +On a Guix system, you can simply run: + +``` bash +guix package -m manifest.scm +``` + +If Guix is not available where you plan to run ordo, but you have access to a +system running Guix, you can create a tarball containing all the dependencies: + +``` bash +guix pack -RR -m manifest.scm +``` + +Copy the tarball to your system and unpack it (somewhere). + +Find the name of the profile in the tarball and use that to configure paths etc. + +``` bash +export GUIX_PROFILE=$(realpath gnu/store/*-profile) +source "${GUIX_PROFILE}/etc/profile" +``` diff --git a/manifest.scm b/manifest.scm new file mode 100644 index 0000000..f8f834c --- /dev/null +++ b/manifest.scm @@ -0,0 +1,26 @@ +(specifications->manifest '("git" + "git-crypt" + "git-lfs" + "gnupg" + "guile" + "guile-config" + "guile-dsv" + "guile-file-names" + "guile-filesystem" + "guile-gcrypt" + "guile-gnutls" + "guile-ini" + "guile-irregex" + "guile-json" + "guile-lib" + "guile-libyaml" + "guile-quickcheck" + "guile-readline" + "guile-semver" + "guile-sqlite3" + "guile-srfi-145" + "guile-srfi-158" + "guile-srfi-197" + "guile-srfi-235" + "guile-ssh" + "password-store")) diff --git a/modules/ordo/connection.scm b/modules/ordo/connection.scm new file mode 100644 index 0000000..7812419 --- /dev/null +++ b/modules/ordo/connection.scm @@ -0,0 +1,41 @@ +(define-module (ordo connection) + #:use-module (oop goops) + #:use-module (ice-9 popen) + #:use-module (ice-9 rdelim) + #:use-module (ssh session) + #:use-module (ssh auth) + #:use-module (ssh popen) + #:use-module (srfi srfi-197)) + +(define-class () + (sudo? #:init-value #f #:getter sudo? #:init-keyword #:sudo?)) + +(define-class ()) + +(define-class () + (user #:getter get-user #:init-keyword #:user) + (host #:getter get-host #:init-keyword #:host) + (session #:getter get-session #:setter set-session!)) + +(define-method (init! (c )) + c) + +(define-method (init! (c )) + (unless (slot-bound? c 'session) + (let ((session (make-session #:user (get-user c) #:host (get-host c)))) + (connect! session) + (userauth-public-key/auto! s) + (set-session! c session))) + c) + +(define (build-command pwd env prog args sudo?) + (let ((cmd (list (if sudo? "sudo" "env")))) + (chain-when cmd + (pwd (append _ (list "--chdir" pwd))) + (env (append _ (map (lambda (x) (format #f "~a=~a" (car x) (cdr x))) env))) + (#t (append _ (list prog))) + (args (append _ args))))) + +(define-method (run (c ) pwd env prog args)) + +(define-method (run (c ) pwd env prog args)) diff --git a/modules/ordo/util/process.scm b/modules/ordo/util/process.scm index ed63346..810a42f 100644 --- a/modules/ordo/util/process.scm +++ b/modules/ordo/util/process.scm @@ -47,3 +47,16 @@ (let ((output (get-string-all (car output-pipe)))) (close-port (car output-pipe)) (values (cdr (waitpid pid)) output))))) + +;; Possibly nicer way to do this, suggested by dsmith on IRC: https://bpa.st/3JYTA +;; (use-modules (ice-9 popen) +;; (ice-9 rdelim) +;; (ice-9 receive)) + +;; (define (filter text) +;; (receive (from to pids) (pipeline '(("the-command"))) +;; (write text to) +;; (close to) +;; (read-line from))) + +;; See also https://github.com/ray1729/ordo/blob/main/modules/ordo/util/process.scm