From bdce2137e713944e77b3e35f758c757a43a99d3e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 17 Apr 2016 02:03:15 +0200 Subject: [PATCH] ma awesome: refactor into module --- makefu/1systems/vbob.nix | 1 + makefu/2configs/base-gui.nix | 10 +------- makefu/3modules/awesome-extra.nix | 40 +++++++++++++++++++++++++++++++ makefu/3modules/default.nix | 1 + makefu/5pkgs/awesomecfg/full.cfg | 12 ++++------ 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 makefu/3modules/awesome-extra.nix diff --git a/makefu/1systems/vbob.nix b/makefu/1systems/vbob.nix index ce866cc4b..36ae88d22 100644 --- a/makefu/1systems/vbob.nix +++ b/makefu/1systems/vbob.nix @@ -1,6 +1,7 @@ { lib, config, pkgs, ... }: { krebs.build.host = config.krebs.hosts.vbob; + makefu.awesome.modkey = "Mod1"; imports = [ # Include the results of the hardware scan. ../. diff --git a/makefu/2configs/base-gui.nix b/makefu/2configs/base-gui.nix index b807957ba..f7d6991c5 100644 --- a/makefu/2configs/base-gui.nix +++ b/makefu/2configs/base-gui.nix @@ -14,7 +14,6 @@ with config.krebs.lib; let mainUser = config.krebs.build.user.name; - awesomecfg = pkgs.awesomecfg.full; in { imports = [ ]; @@ -36,14 +35,7 @@ in }; # lid switch is handled via button presses services.logind.extraConfig = mkDefault "HandleLidSwitch=ignore"; - nixpkgs.config.packageOverrides = pkgs: rec { - awesome = pkgs.stdenv.lib.overrideDerivation pkgs.awesome (oldAttrs : { - postFixup = '' - cp ${awesomecfg} $out/etc/xdg/awesome/rc.lua - ''; - }); - }; - + makefu.awesome.enable = true; i18n.consoleFont = "Lat2-Terminus16"; fonts = { diff --git a/makefu/3modules/awesome-extra.nix b/makefu/3modules/awesome-extra.nix new file mode 100644 index 000000000..b12556486 --- /dev/null +++ b/makefu/3modules/awesome-extra.nix @@ -0,0 +1,40 @@ +{config, lib, pkgs, ... }: + +with config.krebs.lib; +let + cfg = config.makefu.awesome; + out = { + options.makefu.awesome = api; + config = lib.mkIf cfg.enable imp; + }; + api = { + enable = mkEnableOption "awesome custom config"; + modkey = mkOption { + type = types.str; + description = "Modkey to be used"; + default = "Mod4"; + }; + baseConfig = mkOption { + type = types.path; + description = '' + rc.lua file to be used as default + This module will use substituteAll to replace strings before writing to + /etc/xdg/awesome/rc.lua + ''; + default = pkgs.awesomecfg.full; + }; + }; + imp = { + # TODO: configure display manager as well + nixpkgs.config.packageOverrides = pkgs: rec { + awesome = pkgs.stdenv.lib.overrideDerivation pkgs.awesome (oldAttrs : { + postFixup = let + rclua = pkgs.substituteAll { + src = cfg.baseConfig; + inherit (cfg) modkey; + }; + in "cp ${rclua} $out/etc/xdg/awesome/rc.lua"; + }); + }; + }; +in out diff --git a/makefu/3modules/default.nix b/makefu/3modules/default.nix index 0a10b1532..853bdca04 100644 --- a/makefu/3modules/default.nix +++ b/makefu/3modules/default.nix @@ -5,6 +5,7 @@ _: ./snapraid.nix ./umts.nix ./taskserver.nix + ./awesome-extra.nix ]; } diff --git a/makefu/5pkgs/awesomecfg/full.cfg b/makefu/5pkgs/awesomecfg/full.cfg index c1b58aa90..f42aea003 100644 --- a/makefu/5pkgs/awesomecfg/full.cfg +++ b/makefu/5pkgs/awesomecfg/full.cfg @@ -83,13 +83,11 @@ vicious.register(batwidget, vicious.widgets.bat, "$2%", 61, "BAT0") -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers -- beautiful.init("/usr/share/awesome/themes/default/theme.lua") --- ./qbx8r72yzaxpz41zq00902zwajl31b5h-awesome-3.5.6/share/awesome/lib/beautiful.lua --- + +-- @awesome@/share/awesome/lib/beautiful.lua +-- beautiful.init("@awesome@/share/awesome/themes/default/theme.lua") + -- Find the default theme - --- --- beautiful.init("/nix/store/qbx8r72yzaxpz41zq00902zwajl31b5h-awesome-3.5.6/share/awesome/themes/default/theme.lua") - function find_default_theme() -- find the default lua theme in the package path for path in package.path:gmatch('([^;]+);') do @@ -115,7 +113,7 @@ browser = "firefox" -- If you do not like this or do not have such a key, -- I suggest you to remap Mod4 to another key using xmodmap or other tools. -- However, you can use another modifier like Mod1, but it may interact with others. -modkey = "Mod4" +modkey = "@modkey@" -- Table of layouts to cover with awful.layout.inc, order matters. local layouts =