summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pykhalov <go.wigust@gmail.com>2017-11-08 17:13:28 +0300
committerOleg Pykhalov <go.wigust@gmail.com>2017-11-08 17:13:28 +0300
commit09cccd1af6ad58ffbdb0ee69f1567a4b20dcf13e (patch)
treeebbf8a5e60073cd4c02ac5043bc9093de83fcabe
parentwigust: Add emacs-download-region. (diff)
downloadguix-wigust-origin/python-hosts.tar.gz
wigust: Add python-hosts.origin/python-hostspython-hosts
* wigust/packages/python.scm (python-hosts): New variable.
-rw-r--r--wigust/packages/python.scm57
1 files changed, 57 insertions, 0 deletions
diff --git a/wigust/packages/python.scm b/wigust/packages/python.scm
index 6c63890..a23fdb6 100644
--- a/wigust/packages/python.scm
+++ b/wigust/packages/python.scm
@@ -249,3 +249,60 @@ Integration")
(description "A Supercharged Git/Shell Autocompleter with GitHub Integration.")
(license license:gpl3+)))
+(define-public python-hosts
+ (let ((commit "b42c9ea692ab36a96fb0f2804a7440eca406e36c")
+ (revision "1"))
+ (package
+ (name "python-hosts")
+ (version "0.1.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/StevenBlack/hosts.git")
+ (commit commit)))
+ (file-name (string-append name "-" version "-checkout"))
+ (sha256
+ (base32
+ "04hanv6cwp23wvaz1hd1niz2wk2vrr3z0nsa9wiqp5fpxch5rmiz"))))
+ (build-system trivial-build-system)
+ (inputs `(("python" ,python)))
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils))
+ (let ((bin (string-append %output "/bin"))
+ (share-hosts (string-append %output "/share/hosts")))
+ (copy-recursively (assoc-ref %build-inputs "source") ".")
+ (let ((python-files (find-files "." "\\.py"))
+ (wrapper (string-append bin "/updateHostsFile")))
+ ;; Patch Python shebangs
+ (substitute* python-files
+ (("/usr/bin/env python")
+ (string-append (assoc-ref %build-inputs "python")
+ "/bin/python3"))
+ (("/etc/hosts") "/tmp/hosts"))
+ ;; Install
+ (copy-recursively "data" (string-append share-hosts "/data"))
+ (for-each (lambda (file) (install-file file share-hosts))
+ python-files)
+ ;; Wrapper
+ (mkdir-p bin)
+ (with-output-to-file wrapper
+ (lambda ()
+ (display
+ (string-join `("#!/bin/sh"
+ ,(string-join `("cd" ,share-hosts))
+ ,(string-join '("exec"
+ "-a" "updateHostsFile"
+ "./updateHostsFile.py"
+ "\"$@\"")))
+ "\n"))))
+ (for-each (lambda (file) (chmod file #o555))
+ (append (list wrapper)
+ (find-files share-hosts "\\.py")))))
+ #t)))
+ (home-page "https://github.com/StevenBlack/hosts.git")
+ (synopsis "Extending @code{hosts} file from several sources")
+ (description "Extending @code{hosts} file from several sources")
+ (license license:expat))))