r-raymond / nixos-mailserver

A complete and Simple Nixos Mailserver
GNU General Public License v3.0
181 stars 27 forks source link

dovecot: read dovecot version into nix variable #76

Closed eqyiel closed 6 years ago

eqyiel commented 6 years ago

This adds a file dovecot-version.nix which is a derivation that produces a JSON blob like this:

❯ nix-build --expr 'with import <nixpkgs> {}; callPackage ./mail-server/dovecot-version.nix {}' && cat result
/nix/store/8srvh6d7d7c4n9jj83jz3fpdn0na4986-dovecot-version
{
  "major": 2,
  "minor": 3,
  "patch": 0
}

It can be used like this to check the current dovecot version:

nix-repl> builtins.fromJSON (builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}))
{ major = 2; minor = 2; patch = 33; }
r-raymond commented 6 years ago

Wow awesome solution! Thanks a lot!

eqyiel commented 6 years ago

I realised that I forgot to put gawk in the buildInputs. It's not a huge deal because it appears to be in stdenv, but it probably should go in there at some point or be removed from the function arguments.