summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--custom/luaPam.nix26
-rw-r--r--customized/prosody.nix69
-rw-r--r--ymir.nix13
3 files changed, 105 insertions, 3 deletions
diff --git a/custom/luaPam.nix b/custom/luaPam.nix
new file mode 100644
index 00000000..f0c93e4f
--- /dev/null
+++ b/custom/luaPam.nix
@@ -0,0 +1,26 @@
1{ stdenv
2, pkgs
3, fetchgit
4}:
5
6let
7 lua = pkgs.luaPackages.lua;
8in pkgs.luaPackages.buildLuaPackage {
9 name = "lua-pam";
10 buildInputs = (with pkgs; [ pam ]);
11 src = fetchgit {
12 url = "https://github.com/devurandom/lua-pam";
13 rev = "3818ee6346a976669d74a5cbc2a83ad2585c5953";
14 sha256 = "1aci3psyxwxbls93w5b4vdhnrrp3w94i97dl8qrmjgigzbjszwvr";
15 };
16 preBuild = ''
17 makeFlagsArray=(
18 LUA_CPPFLAGS="-I${lua}/include -L${lua}/lib"
19 LUA_LIBS="-L${lua}/lib -llua"
20 );
21 '';
22 installPhase = ''
23 mkdir -p $out/lib/lua/${lua.luaversion}
24 install pam.so $out/lib/lua/${lua.luaversion}/
25 '';
26}
diff --git a/customized/prosody.nix b/customized/prosody.nix
new file mode 100644
index 00000000..4a6da4fb
--- /dev/null
+++ b/customized/prosody.nix
@@ -0,0 +1,69 @@
1{ stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg
2, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null
3, withLibevent ? true, withZlib ? true
4, extraModules ? [], extraLibs ? []
5}:
6
7assert withLibevent -> luaevent != null;
8assert withZlib -> luazlib != null;
9
10with stdenv.lib;
11
12let
13 libs = [ luasocket luasec luaexpat luafilesystem luabitop ]
14 ++ optional withLibevent luaevent
15 ++ optional withZlib luazlib
16 ++ extraLibs;
17 getPath = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}";
18 getLuaPath = lib : getPath lib "lua";
19 getLuaCPath = lib : getPath lib "so";
20 copyModule = name : "cp -rv $communityModules/${name} $out/lib/prosody/modules/"
21 luaPath = concatStringsSep ";" (map getLuaPath libs);
22 luaCPath = concatStringsSep ";" (map getLuaCPath libs);
23 copyModules = concatStringsSep ";" (map copyModule (extraModules ++ ["mod_websocket"]));
24in
25
26stdenv.mkDerivation rec {
27 version = "0.9.8";
28 name = "prosody-${version}";
29
30 src = fetchurl {
31 url = "http://prosody.im/downloads/source/${name}.tar.gz";
32 sha256 = "0wbq4ps69l09fjb5dfjzab6i30hzpi4bvyj5kc44gf70arf42w4l";
33 };
34
35 communityModules = fetchhg {
36 url = "http://prosody-modules.googlecode.com/hg/";
37 rev = "4b55110b0aa8";
38 sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij";
39 };
40
41 buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ]
42 ++ optional withLibevent luaevent
43 ++ optional withZlib luazlib;
44
45 configureFlags = [
46 "--ostype=linux"
47 "--with-lua-include=${lua5}/include"
48 "--with-lua=${lua5}"
49 ];
50
51 postInstall = ''
52 ${copyModules}
53 wrapProgram $out/bin/prosody \
54 --set LUA_PATH '"${luaPath};"' \
55 --set LUA_CPATH '"${luaCPath};"'
56 wrapProgram $out/bin/prosodyctl \
57 --add-flags '--config "/etc/prosody/prosody.cfg.lua"' \
58 --set LUA_PATH '"${luaPath};"' \
59 --set LUA_CPATH '"${luaCPath};"'
60 '';
61
62 meta = {
63 description = "Open-source XMPP application server written in Lua";
64 license = licenses.mit;
65 homepage = http://www.prosody.im;
66 platforms = platforms.linux;
67 maintainers = [ maintainers.flosse ];
68 };
69}
diff --git a/ymir.nix b/ymir.nix
index 71f6a87b..a538f1eb 100644
--- a/ymir.nix
+++ b/ymir.nix
@@ -1,8 +1,7 @@
1{ config, pkgs, ... }: 1{ config, pkgs, ... }:
2 2
3let 3let
4 prosodyModules = pkgs.callPackage (import ./custom/prosody-modules.nix) { modules = [ "mod_auth_pam" 4 luaPam = pkgs.callPackage ./custom/luaPam.nix {};
5 ]; };
6in { 5in {
7 imports = 6 imports =
8 [ 7 [
@@ -17,6 +16,11 @@ in {
17 device = "/dev/vda"; 16 device = "/dev/vda";
18 }; 17 };
19 18
19 nixpkgs.config.packageOverrides = pkgs:
20 rec {
21 prosody = pkgs.callPackage ./customized/prosody.nix { extraModules = ["mod_auth_pam"]; extraLibs = [luaPam]; }
22 };
23
20 environment.systemPackages = with pkgs; [ 24 environment.systemPackages = with pkgs; [
21 git 25 git
22 mosh 26 mosh
@@ -78,11 +82,14 @@ in {
78 services.prosody = { 82 services.prosody = {
79 enable = true; 83 enable = true;
80 admins = [ 84 admins = [
81 "g@xmpp.li" 85 "gkleen@xmpp.li"
82 ]; 86 ];
83 allowRegistration = false; 87 allowRegistration = false;
84 extraModules = [ "private" 88 extraModules = [ "private"
85 ]; 89 ];
90 extraConfig = ''
91 authentication="pam"
92 '';
86 93
87 virtualHosts.default = { 94 virtualHosts.default = {
88 enabled = true; 95 enabled = true;