Howto configure irc in doom emacs with circe and pass

If you read the documentation of the circe
module of doom emacs there is a whole paragraph on how to set it up with pass (there is a pass module in doom emacs), but it doesn't mention anything about howto setup up pass itself (of course the doom emacs documentation doesn't, because that isn't the scope of the documentation, to explain how every UNIX tool is set up), but alas! I will try to explain it here.
Installing pass
First of we need pass
. Because i use NixOS
i will try to explain how i installed it through configuration.nix
(you also need gnugpg
). This is a sample configuration.nix
file
{ pkgs, ... }: {
environment.systemPackages = with pkgs; [
pass
gnupg
];
programs.gnupg.agent = {
enable = true;
pinentryFlavor = "gnome3";
enableSSHSupport = true;
};
}
build and switch your configuration, and you are good to go.
Configuring pass and a gpg key
First you need to generate a gpg key by running gpg --gen-key
, then you need to setup pass
by running pass init <your_email>
, fill out the form. Easy!
Adding an username and a password
Now to the fun part: inserting a username and a password to be used in your circe configuration. To do this, we need to insert a multiline entry into pass, with the following structure
mysecretpassword
username: myusername
to do so, use: pass insert -m irc/myircserver
, then you will drop into a simple editor, when done: type CTRL+D
, and pass
will save it. The path is up to you, i just chose irc/myircserver
but it could be anything.
Now you can use this when configuring circe
.
Configuring circe
You need to do the configuration after circe
is loaded
(after! circe
(set-irc-server! "irc.libera.chat"
`(:tls t
:port 6697
:nick "doom"
:sasl-username ,(+pass-get-user "irc/myircserver")
:sasl-password (lambda (&rest _) (+pass-get-secret "irc/myircserver"))
:channels ("#emacs")))
if the server you are connecting to, doesn't use SASL
then you can use :pass
and :user
instead of :sasl-username
and :sasl-password
.
And that's it!! You can now connect to IRC from doom emacs and don't be afraid that you ever expose your credentials when sharing your emacs config. Yay! Evil!!