jueves, 13 de febrero de 2014

Guix tutorial, using, creating, contributing

GNU Guix is what they call a 'functional package manager'. Think as if git and apt-get had a child. It allows you to do transactional rollbacks or have multiple versions of the same app coexisting. Probably if you're here you already know what's GNU Guix, so I won't bother explaining it again. Visit the official page if you need more info.

To contribute to Guix, you'll have to have a few dependencies installed, and after that, follow a few steps which I'll try to explain in here, as the documentation that's now on the guix site is quite scarce (for newbies at least).

There are a few more steps than in most applications, so I'll put them here. 

- Install guix. Download the git version from git clone git://git.savannah.gnu.org/guix.git. Then, ./bootstrap && ./configure && make # make install is optional
- Create users. Follow these instructions to create some build users.
- Create the package store. mkdir /nix/store
- Create ~/.guix-profile. This should be created by guix-deamon itself.
- Put ~/.guix-profile in $PATH.

 

 Basic commands 

 

To run any guix command, you should have the guix server running. When you run guix commands, the client will connect to the daemon, and will run the command itself.

We'll try to install and run a test demo that guix users use as a minimal test. It's a helloworld app.

- Run server.  ./pre-inst-env guix-daemon --build-users-group=guix-builder
- Search package.  ./pre-inst-env scripts/guix package -s hello
- Install package. ./pre-inst-env scripts/guix package -i hello
- Run hello. The hello app should be in your $PATH.
- Remove package. ./pre-inst-env scripts/guix package -r hello

If you installed Guix system-wide (make install), ./pre-inst-env is not needed.

Guix Recipes


If you're trying to write a recipe for guix, here are the steps to follow, and good practices.

First, let's see what's in the 'hello' recipe, and try to understand it. then, we'll add a few things to make it build something more interesting. The file is in gnu/packages/base.scm, so when we open it we see something like this:

We can see a few interesting lines there. Even if you have no scheme knowledge, you can find out what's going on there.  The name and version of the package in some places, the url (mirror:// means "download from any gnu mirror", but could be just a normal URL), description of the package.

The hash code in the sexp (sha256 (base32   "19qy37gkasc4csb1d3bdiz9snn8mir2p3aj0jgzmfv0r2hi7mfzc")) is a checksum of the downloaded file. You can get that number using

./pre-inst-env scripts/guix download URL or
./pre-inst-env scripts/guix hash FILE.

 

 Example Recipe


As an example, we'll build a relatively simple package, luajit.

In guix, recipes are organized in files, but not necessarily one recipe per file.  When I wrote the luajit recipe, lua.scm already existed, so it made sense to put it in the same file.  If we add a new file, we should add the file in the file gnu-system.am .

Although having different presets for different build systems, many packages need some special tweaking.

here we added PREFIX variable in make phase, and we removed configure phase and test.

Guix installations happen in phases, usng alist-delete we can remove one of them.

We can try the build by using ./pre-inst-env scripts/guix build luajit.  If everything is ok, we can submit the patch.

 

 Sending the patch


If the recipe built correctly, and you can install the package, that's the time for sending the recipe.

Make a commit with the recipe. The commit message should start with 'gnu:', and follow the GNU commit guidelines.

$ git format-patch -1 HEAD #will make a patch for the latest commit.

Send the patch to the mail list.

 

Addendum: Comunity


The community is also important in Free software projects. And this one is really nice. It's small but very helpful. If you have questions, don't hesitate asking in #guix on freenode or in the guix mail list.  Here's an example of a recent conversation I had with Ludovic (the main author of the project)
Neat, no? :)

sábado, 25 de enero de 2014

ANN: erc-youtube.el

 This time is erc-image and erc-tweet's little brother: erc-youtube.

Sometimes, when someone posts a youtube link in an IRC channel, you feel like clicking, but from time to time it's some link you really wouldn't like to have clicked. And it's too late.

Erc-youtube will inline the video's title in the erc buffer so you can decide then if you want to click or not.


Supersimple plugin, but it may be useful for some of you.  Shortly it'll be in melpa.

miércoles, 15 de enero de 2014

ANN: Helm-dash, the documentation browser for emacs

This post is the official announcement of a minor mode Toni and myself have developed which allows you to browse documentation for many languages using helm machinery to drive the find-as-you-type. It's called helm-dash

Intro


Helm is gaining lots of traction lately in the emacs environment (there are over 50 helm-* packages is the melpa now). It's a find-as-yo-type helper which provides an easy way to act on the selections. 

Dash is a mac osX app which lets you browse what they call docsets. Docsets contain an sqlite db and some html with the documentation of a given topic.

helm-dash


The basic usage is pretty simple:
  • helm-dash-install-package will give you the available docsets in the official repo (we'll choose Redis for testing).
  • Add the docset to either the global variable helm-dash-common-docsets. 
     (setq helm-dash-common-docsets '("Redis")) 
  • execute the interactive command helm-dash
  • Type some letters that match a redis command you want to look for (push, for example)
  • Press RET when you are on the command you want. Your favourite browser should open pointing to the documentation.

buffer-local docsets


For further configuration, we allow per-buffer sets of docsets. Let's say you want the GoLang docset available, but just in go-mode buffers. Install Go docset, and evaluate the following elisp:

(defun go-doc ()
  (interactive)
  (setq-local helm-dash-docsets '("Go")))

(add-hook 'go-mode-hook 'go-doc)

Then, when you open a go buffer, helm-dash will search both Redis and Go.

Here's a demo of the basic usage. (Mind that the video is not setting the variables accordingly because they were already set)

Try it, patch it, or talk about it, we'd love to hear your comments and improve it. 

The package has been developed and tested under linux.It should work on Mac OSX but it hasn't been tested there.If you find any issue on Mac, please, Pull Request :)

sábado, 11 de enero de 2014

Evil: The exact amount of vim in emacs (but no more than that)

I love emacs, but I also love modal editing.  Evil was (and vimpulse before that), was a great finding.

What I want is to have a normal mode where most commands feel like vim, and an insert mode where most commands feel like emacs, so c-p would do previous-line in insert mode instead of autocomplete word. Here are some of my tricks (many of them gathered from other people's configs)

99% emacs insert mode

Although using lots of insert mode commands when I was using vim daily, now I hardly find the necessity for them.

(setcdr evil-insert-state-map nil)
(define-key evil-insert-state-map [escape] 'evil-normal-state)

And that's it. with this, you're mostly done. In insert mode, every key but escape will behave as in plain emacs.

Undo-tree? nah (99% of vim in normal mode)

I still prefer emacs' undo-redo schema than the undo-tree. In the docs (also in the code), evil states that undo-tree will be used if available, and regular undo-redo will be used in case it's not there. That sounds fine, but if you get evil from elpa, undo-tree will be downloaded and installed without asking.Uninstalling undo-tree afterwards is not an enough because when loading, evil will complain it has some unmet dependency.

To make evil forget about it I edited the evil-pkg.el in my ~/.emacs.d/elpa/evil-xxxxxxx/ dir deleting undo-tree as a requirementand leaving it like this:

(define-package "evil" "20140109.605" "Extensible Vi layer for Emacs." '((goto-chg "1.6")))

c-r tries to redo

Just remap the desired key in the chosen mode to your prefered function.

(define-key evil-normal-state-map (kbd "C-r") 'isearch-backward) 
With these few tricks you can hack further to fine tune your keybindings and submodes inside evil. If you dig deeper into its code, you'll see it's quite well organized and quite clear.

martes, 7 de enero de 2014

Emacs keybindings everywhere

If you're using conkeror or keysnail you know how nice it is to have the usual keybindings in your browser.

Just in case you aren't using them, or if you're using them but want to have c-a, c-e,etc... in many linux desktop apps, here's a little trick.

Open (or create) the file "~/.gtkrc-2.0" and put the following line

gtk-key-theme-name = "Emacs"
Save, and open plain firefox. Then in any text field, try c-a, c-e, c-k . Neat, right?

You're welcome :)