diff options
| author | Alex Kost <alezost@gmail.com> | 2018-07-12 17:11:46 +0300 |
|---|---|---|
| committer | Alex Kost <alezost@gmail.com> | 2018-07-16 21:37:19 +0300 |
| commit | c784acf46f8336d93844c2039e9010c5e1970310 (patch) | |
| tree | 61b34e76905236b31b57a64ae535ceb1d079440f | |
| parent | Initial commit (diff) | |
| download | emacs-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.
| -rw-r--r-- | build-farm-utils.el | 6 | ||||
| -rw-r--r-- | build-farm.el | 37 |
2 files changed, 35 insertions, 8 deletions
diff --git a/build-farm-utils.el b/build-farm-utils.el index d02ce39..5892406 100644 --- a/build-farm-utils.el +++ b/build-farm-utils.el @@ -23,6 +23,12 @@ (require 'bui) +(defvar build-farm-preferred-package-manager + (if (file-exists-p "/gnu") 'guix 'nix) + "Package manager that a user probably uses. +This variable influence what build farm is used by default. +It should be either `guix' or `nix' symbol.") + (defun build-farm-hexify (value) "Convert VALUE to string and hexify it." (url-hexify-string (bui-get-string value))) 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) |
