From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:40825) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1himjj-0004aM-AZ for gwl-devel@gnu.org; Wed, 03 Jul 2019 17:24:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1himji-0001Me-AX for gwl-devel@gnu.org; Wed, 03 Jul 2019 17:24:19 -0400 Received: from pelzflorian.de ([5.45.111.108]:42228 helo=mail.pelzflorian.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1himjh-0001M7-Vy for gwl-devel@gnu.org; Wed, 03 Jul 2019 17:24:18 -0400 Date: Wed, 3 Jul 2019 23:24:16 +0200 From: "pelzflorian (Florian Pelz)" Message-ID: <20190703212416.mqdd2jlifqlsak5n@pelzflorian.localdomain> References: <20190703132504.4vxrdbscwwz3vpnj@pelzflorian.localdomain> <87sgrntbjh.fsf@elephly.net> <20190703212342.lwa5cq6oepr2nf53@pelzflorian.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ehphvgle6fz5a5a3" Content-Disposition: inline In-Reply-To: <20190703212342.lwa5cq6oepr2nf53@pelzflorian.localdomain> Subject: Re: [Bug?] Cannot use Guix Workflow Language on Guix System List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gwl-devel-bounces+kyle=kyleam.com@gnu.org Sender: "gwl-devel" To: Ricardo Wurmus , zimoun Cc: gwl-devel@gnu.org --ehphvgle6fz5a5a3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Forgot attachment. --ehphvgle6fz5a5a3 Content-Type: application/vnd.lotus-screencam Content-Disposition: attachment; filename="workflows.scm" Content-Transfer-Encoding: quoted-printable ;;; Islamische Hochschulvereinigung Kaiserslautern Website=0A;;; Copyright = =C2=A9 2018=E2=80=932019 Florian Pelz=0A;;;=0A;;; This website=E2=80=99s co= de (but not content) is free software; you can=0A;;; redistribute it and/or= modify it under the terms of the GNU=0A;;; General Public License as publi= shed by the Free Software=0A;;; Foundation; either version 3 of the License= , or (at your option)=0A;;; any later version.=0A;;;=0A;;; This website is = distributed in the hope that it will be useful,=0A;;; but WITHOUT ANY WARRA= NTY; without even the implied warranty of=0A;;; MERCHANTABILITY or FITNESS = FOR A PARTICULAR PURPOSE. See the GNU=0A;;; General Public License for mor= e details.=0A;;;=0A;;; You should have received a copy of the GNU General P= ublic License=0A;;; along with this website. If not, see=0A;;; .=0A=0A(define-module (ihvklweb workflows)=0A #:use-m= odule (gnu packages)=0A #:use-module (guix processes)=0A #:use-module (gu= ix utils) ; for pk=0A #:export (populate-server))=0A=0A(define (autodetect= -guix)=0A "Return the path of the profile of the active Guix."=0A (let ((= pw (getpwuid (geteuid))))=0A (string-append (passwd:dir pw) "/.config/gu= ix/current")))=0A=0A;;; See INSTRUCTIONS.md in the ihvklweb root directory.= =0A=0A;;; Developed along https://guix-hpc.bordeaux.inria.fr/blog/2017/10/u= sing-guix-without-being-root/=0A=0A(define populate-server=0A ;; Delete al= l files of the IHV from the specified TARGET-HOST (which=0A ;; is either a= virtual machine created from=0A ;; ihvkl-virtual-machine.scm or the RHRK= =E2=80=99s machine) before=0A ;; recreating them and copying them to it.= =0A (process=0A (name "populate-server")=0A (package-inputs (map speci= fication->package=0A '("bash" "openssh")))=0A (dat= a-inputs '((ihvkl-directory . ".")=0A (guix-build-args . (= "--system=3Dx86_64-linux"))=0A (guix-path . #f)=0A = (target-host . "172.28.112.243")))=0A (procedure=0A `(begin= =0A (use-modules (ice-9 popen)=0A (ice-9 rdelim)= =0A (ice-9 textual-ports))=0A=0A (define (run-guix= guix-path . args)=0A "Return a string containing the standard outp= ut of a Guix=0Ainvocation."=0A (let* ((port (open-pipe* OPEN_READ "= bash" "-c"=0A (string-join=0A = (cons*=0A "source"= =0A (string-append guix-path "/etc/profi= le")=0A "&& guix"=0A = args))))=0A (str (get-string-all port)))=0A = (begin=0A (close-pipe port)=0A str)))=0A= =0A (define (system*/print . args)=0A (begin=0A (di= splay (string-join (map (lambda (a)=0A = (string-append "'" a "'"))=0A args)= ))=0A (newline)=0A (apply system* args)))=0A=0A (= chdir ,(assoc-ref data-inputs 'ihvkl-directory))=0A (format #t "Chang= ed into directory: ~a~%" (getcwd))=0A (let* ((specified-guix ,(assoc-= ref data-inputs 'guix-path))=0A (guix (cond ((string? specifie= d-guix) specified-guix)=0A (else ,(autodetect-guix= )))))=0A (format #t "Using Guix version: ~a~%~%"=0A = (run-guix guix "describe"))=0A (let* ((pack-out (run-guix guix "pa= ck"=0A "--manifest=3Dguix-manifest.scm"= =0A "--symlink=3D/bin=3Dbin"=0A = ,@(assoc-ref data-inputs 'guix-build-args)))=0A = (pack (with-input-from-string pack-out read-line))=0A = (proot-out (run-guix=0A guix "build" "p= root-static"=0A ,@(assoc-ref data-inputs 'guix-b= uild-args)))=0A (proot (string-append=0A = (with-input-from-string proot-out read-line)=0A = "/bin/proot")))=0A (begin=0A (format #t "Created pack= : ~a~%" pack)=0A (format #t "Server: ~a~%" ,(assoc-ref data-inp= uts 'target-host))=0A (format #t "All files on the server are b= eing deleted. \=0AIs this OK? [j/n]~%")=0A (when (equal? (read= -line) "j")=0A (let ((ssh-host (string-append=0A = "www-ihvkl@"=0A ,(assoc-r= ef data-inputs 'target-host))))=0A (begin=0A = (system*/print=0A "ssh"=0A ssh-ho= st=0A "\=0Apkill shepherd ; sleep 10 ; pkill -KILL sheph= erd ; \=0Achmod -R +w ~ ; \=0Aunlink ihvkl ; \=0Arm -rf ~/* ; rm -rf ~/.* ;= \=0Arm -rf /srv/www/www-ihvkl/http/hochschulgruppen/ihvkl/* ; \=0Arm -rf /= srv/www/www-ihvkl/http/hochschulgruppen/ihvkl/.*")=0A (sy= stem*/print=0A "scp" pack=0A (string-= append ssh-host=0A ":/home/www-ihvkl/prog= ramme.tar.gz"))=0A (system*/print=0A "= scp" proot=0A (string-append ssh-host=0A = ":/home/www-ihvkl/"))=0A=0A ;; With ev= ery push, the website shall be=0A ;; automatically recrea= ted. To do so, a=0A ;; post-update-hook is uses.=0A = ;; Cf. https://stackoverflow.com/questions/4043609/getting-fa= tal-not-a-git-repository-when-using-post-update-hook-to-execut=0A = (system*/print=0A "ssh"=0A s= sh-host=0A "\=0Atar xvf programme.tar.gz > /dev/null && = \=0Arm programme.tar.gz && \=0Aln -s /srv/www/www-ihvkl/http/hochschulgrupp= en/ihvkl ihvkl && \=0Amkdir -p ihvkl/git/ihvklweb.git && \=0Acd ihvkl/git/i= hvklweb.git && \=0Agit init --bare && \=0Ahooks/post-update.sample && \=0Ah= ead -n 1 hooks/post-update.sample >> hooks/post-update && \=0Achmod +x hook= s/post-update && \=0Aecho 'cd ~/haunt-checkout' >> hooks/post-update && \= =0Aecho -n 'echo \"Building it using Haunt in: $' >> hooks/post-update && \= =0Aecho '(pwd)\"' >> hooks/post-update && \=0Aecho -n 'SAVED_GIT_DIR=3D$' >= > hooks/post-update && \=0Aecho 'GIT_DIR' >> hooks/post-update && \=0Aecho = 'unset GIT_DIR' >> hooks/post-update && \=0Aecho 'git fetch && git checkout= master' >> hooks/post-update && \=0Aecho -n 'LC_ALL=3Dde_DE.UTF-8 GUIX_LOC= PATH=3D/gnu/store/$' >> hooks/post-update && \=0Aecho '(basename /home/www-= ihvkl/gnu/store/*-glibc*locales-*)/lib/locale \=0APROOT_NO_SECCOMP=3D1 ~/pr= oot -w /haunt-checkout -r \=0A/home/www-ihvkl/ -b /proc /bin/haunt build' >= > hooks/post-update && \=0Aecho -n 'if [ -d site ]; then rsync -r \=0A--exc= lude=3D^git' >> hooks/post-update && \=0Aecho '$ site/ ~/ihvkl/; fi' >> hoo= ks/post-update && \=0Aecho -n 'export GIT_DIR=3D$' >> hooks/post-update && = \=0Aecho 'SAVED_GIT_DIR' >> hooks/post-update && \=0Aecho 'cd ~/ihvkl/git/i= hvklweb.git/' >> hooks/post-update && \=0Atail -n +2 hooks/post-update.samp= le >> hooks/post-update && \=0Agit clone ~/ihvkl/git/ihvklweb.git ~/haunt-c= heckout")))))))))))=0A --ehphvgle6fz5a5a3--