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/${awesome.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 (lib.mdDoc "Awesome window manager");
25
26 luaModules = mkOption {
27 default = [];
28 type = types.listOf types.package;
29 description = lib.mdDoc "List of lua packages available for being used in the Awesome configuration.";
30 example = literalExpression "[ pkgs.luaPackages.vicious ]";
31 };
32
33 package = mkOption {
34 default = null;
35 type = types.nullOr types.package;
36 description = lib.mdDoc "Package to use for running the Awesome WM.";
37 apply = pkg: if pkg == null then pkgs.awesome else pkg;
38 };
39
40 noArgb = mkOption {
41 default = false;
42 type = types.bool;
43 description = lib.mdDoc "Disable client transparency support, which can be greatly detrimental to performance in some setups";
44 };
45 };
46
47 };
48
49
50 ###### implementation
51
52 config = mkIf cfg.enable {
53
54 services.xserver.windowManager.session = singleton
55 { name = "awesome";
56 start =
57 ''
58 ${awesome}/bin/awesome ${lib.optionalString cfg.noArgb "--no-argb"} ${makeSearchPath cfg.luaModules} &
59 waitPID=$!
60 '';
61 };
62
63 environment.systemPackages = [ awesome ];
64
65 };
66}