1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 cfg = config.services.xserver.windowManager.awesome;
8 awesome = cfg.package;
9 getLuaPath = lib : dir : "${lib}/${dir}/lua/${pkgs.luaPackages.lua.luaversion}";
10 makeSearchPath = lib.concatMapStrings (path:
11 " --search " + (getLuaPath path "share") +
12 " --search " + (getLuaPath path "lib")
13 );
14in
15
16{
17
18 ###### interface
19
20 options = {
21
22 services.xserver.windowManager.awesome = {
23
24 enable = mkEnableOption "Awesome window manager";
25
26 luaModules = mkOption {
27 default = [];
28 type = types.listOf types.package;
29 description = "List of lua packages available for being used in the Awesome configuration.";
30 example = literalExample "[ luaPackages.oocairo ]";
31 };
32
33 package = mkOption {
34 default = null;
35 type = types.nullOr types.package;
36 description = "Package to use for running the Awesome WM.";
37 apply = pkg: if pkg == null then pkgs.awesome else pkg;
38 };
39
40 };
41
42 };
43
44
45 ###### implementation
46
47 config = mkIf cfg.enable {
48
49 services.xserver.windowManager.session = singleton
50 { name = "awesome";
51 start =
52 ''
53 ${awesome}/bin/awesome ${makeSearchPath cfg.luaModules} &
54 waitPID=$!
55 '';
56 };
57
58 environment.systemPackages = [ awesome ];
59
60 };
61}