summaryrefslogtreecommitdiff
path: root/build-farm.el
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2018-07-12 17:11:46 +0300
committerAlex Kost <alezost@gmail.com>2018-07-16 21:37:19 +0300
commitc784acf46f8336d93844c2039e9010c5e1970310 (patch)
tree61b34e76905236b31b57a64ae535ceb1d079440f /build-farm.el
parentInitial commit (diff)
downloademacs-build-farm-c784acf46f8336d93844c2039e9010c5e1970310.tar.gz
Try to guess a package manager and a build farm url
* build-farm-utils.el (build-farm-preferred-package-manager): New variable. * build-farm.el (build-farm-urls): Rename variable to... (build-farm-url-alist): ... this. (build-farm-guess-url, build-farm-urls, build-farm-type-by-url): New procedures.
Diffstat (limited to 'build-farm.el')
-rw-r--r--build-farm.el37
1 files changed, 29 insertions, 8 deletions
diff --git a/build-farm.el b/build-farm.el
index 94d1a65..d0f9858 100644
--- a/build-farm.el
+++ b/build-farm.el
@@ -119,21 +119,42 @@
;;; Defining URLs
-(defvar build-farm-urls
- '("https://hydra.gnu.org"
- "https://berlin.guixsd.org"
- "https://hydra.nixos.org")
- "List of URLs of the available build farms.")
+(defvar build-farm-url-alist
+ '(("https://hydra.nixos.org" . hydra)
+ ("https://hydra.gnu.org" . hydra)
+ ("https://berlin.guixsd.org" . cuirass))
+ "Alist of URLs and their types of the available build farms.")
-(defcustom build-farm-url (car build-farm-urls)
+(defun build-farm-guess-url ()
+ "Return URL of a build farm that a user probably wants to use."
+ (if (eq 'guix build-farm-preferred-package-manager)
+ "https://hydra.gnu.org"
+ "https://hydra.nixos.org"))
+
+(defun build-farm-urls ()
+ "Return a list of available build farm URLs."
+ (mapcar #'car build-farm-url-alist))
+
+(defcustom build-farm-url (build-farm-guess-url)
"URL of the default build farm."
:type `(choice ,@(mapcar (lambda (url) (list 'const url))
- build-farm-urls)
+ (build-farm-urls))
(string :tag "Other URL"))
:group 'build-farm)
+(defun build-farm-type-by-url (url)
+ "Return build farm type by its URL."
+ (or (bui-assoc-value build-farm-url-alist url)
+ (progn
+ (message "Unknown URL: <%s>.
+Consider adding it to `build-farm-url-alist'.
+Arbitrarily choosing `hydra' type for this URL."
+ url)
+ 'hydra)))
+
(defun build-farm-url (&rest url-parts)
- "Return build farm URL-PARTS."
+ "Return build farm URL using URL-PARTS.
+URL-PARTS are added to `build-farm-url'."
(apply #'concat build-farm-url "/" url-parts))
(defun build-farm-api-url (type args)