commit
3d76d810ed
|
@ -7,57 +7,35 @@ let
|
||||||
|
|
||||||
cfg = config.services.compton;
|
cfg = config.services.compton;
|
||||||
|
|
||||||
literalAttrs = v:
|
pairOf = x: with types; addCheck (listOf x) (y: length y == 2);
|
||||||
if isString v then toString v
|
|
||||||
else if isAttrs v then "{\n"
|
|
||||||
+ concatStringsSep "\n" (mapAttrsToList
|
|
||||||
(name: value: "${literalAttrs name} = ${literalAttrs value};")
|
|
||||||
v)
|
|
||||||
+ "\n}"
|
|
||||||
else generators.toPretty {} v;
|
|
||||||
|
|
||||||
floatBetween = a: b: with lib; with types;
|
floatBetween = a: b: with lib; with types;
|
||||||
addCheck str (x: versionAtLeast x a && versionOlder x b);
|
addCheck str (x: versionAtLeast x a && versionOlder x b);
|
||||||
|
|
||||||
pairOf = x: with types; addCheck (listOf x) (y: length y == 2);
|
toConf = attrs: concatStringsSep "\n"
|
||||||
|
(mapAttrsToList
|
||||||
|
(k: v: let
|
||||||
|
sep = if isAttrs v then ":" else "=";
|
||||||
|
# Basically a tinkered lib.generators.mkKeyValueDefault
|
||||||
|
mkValueString = v:
|
||||||
|
if isBool v then boolToString v
|
||||||
|
else if isInt v then toString v
|
||||||
|
else if isFloat v then toString v
|
||||||
|
else if isString v then ''"${escape [ ''"'' ] v}"''
|
||||||
|
else if isList v then "[ "
|
||||||
|
+ concatMapStringsSep " , " mkValueString v
|
||||||
|
+ " ]"
|
||||||
|
else if isAttrs v then "{ "
|
||||||
|
+ concatStringsSep " "
|
||||||
|
(mapAttrsToList
|
||||||
|
(key: value: "${toString key}=${mkValueString value};")
|
||||||
|
v)
|
||||||
|
+ " }"
|
||||||
|
else abort "compton.mkValueString: unexpected type (v = ${v})";
|
||||||
|
in "${escape [ sep ] k}${sep}${mkValueString v};")
|
||||||
|
attrs);
|
||||||
|
|
||||||
opacityRules = optionalString (length cfg.opacityRules != 0)
|
configFile = pkgs.writeText "compton.conf" (toConf cfg.settings);
|
||||||
(concatMapStringsSep ",\n" (rule: ''"${rule}"'') cfg.opacityRules);
|
|
||||||
|
|
||||||
configFile = pkgs.writeText "compton.conf"
|
|
||||||
(optionalString cfg.fade ''
|
|
||||||
# fading
|
|
||||||
fading = true;
|
|
||||||
fade-delta = ${toString cfg.fadeDelta};
|
|
||||||
fade-in-step = ${elemAt cfg.fadeSteps 0};
|
|
||||||
fade-out-step = ${elemAt cfg.fadeSteps 1};
|
|
||||||
fade-exclude = ${toJSON cfg.fadeExclude};
|
|
||||||
'' + optionalString cfg.shadow ''
|
|
||||||
|
|
||||||
# shadows
|
|
||||||
shadow = true;
|
|
||||||
shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)};
|
|
||||||
shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)};
|
|
||||||
shadow-opacity = ${cfg.shadowOpacity};
|
|
||||||
shadow-exclude = ${toJSON cfg.shadowExclude};
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
# opacity
|
|
||||||
active-opacity = ${cfg.activeOpacity};
|
|
||||||
inactive-opacity = ${cfg.inactiveOpacity};
|
|
||||||
|
|
||||||
wintypes:
|
|
||||||
${literalAttrs cfg.wintypes};
|
|
||||||
|
|
||||||
opacity-rule = [
|
|
||||||
${opacityRules}
|
|
||||||
];
|
|
||||||
|
|
||||||
# other options
|
|
||||||
backend = ${toJSON cfg.backend};
|
|
||||||
vsync = ${boolToString cfg.vSync};
|
|
||||||
refresh-rate = ${toString cfg.refreshRate};
|
|
||||||
'' + cfg.extraOptions);
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
|
@ -236,23 +214,13 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
settings = let
|
||||||
type = types.package;
|
configTypes = with types; either bool (either int (either float str));
|
||||||
default = pkgs.compton;
|
# types.loaOf converts lists to sets
|
||||||
defaultText = "pkgs.compton";
|
loaOf = t: with types; either (listOf t) (attrsOf t);
|
||||||
example = literalExample "pkgs.compton";
|
in mkOption {
|
||||||
description = ''
|
type = loaOf (types.either configTypes (loaOf (types.either configTypes (loaOf configTypes))));
|
||||||
Compton derivation to use.
|
default = {};
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extraOptions = mkOption {
|
|
||||||
type = types.lines;
|
|
||||||
default = "";
|
|
||||||
example = ''
|
|
||||||
unredir-if-possible = true;
|
|
||||||
dbe = true;
|
|
||||||
'';
|
|
||||||
description = ''
|
description = ''
|
||||||
Additional Compton configuration.
|
Additional Compton configuration.
|
||||||
'';
|
'';
|
||||||
|
@ -260,6 +228,42 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
services.compton.settings = let
|
||||||
|
# Hard conversion to float, literally lib.toInt but toFloat
|
||||||
|
toFloat = str: let
|
||||||
|
may_be_float = builtins.fromJSON str;
|
||||||
|
in if builtins.isFloat may_be_float
|
||||||
|
then may_be_float
|
||||||
|
else throw "Could not convert ${str} to float.";
|
||||||
|
in {
|
||||||
|
# fading
|
||||||
|
fading = mkDefault cfg.fade;
|
||||||
|
fade-delta = mkDefault cfg.fadeDelta;
|
||||||
|
fade-in-step = mkDefault (toFloat (elemAt cfg.fadeSteps 0));
|
||||||
|
fade-out-step = mkDefault (toFloat (elemAt cfg.fadeSteps 1));
|
||||||
|
fade-exclude = mkDefault cfg.fadeExclude;
|
||||||
|
|
||||||
|
# shadows
|
||||||
|
shadow = mkDefault cfg.shadow;
|
||||||
|
shadow-offset-x = mkDefault (elemAt cfg.shadowOffsets 0);
|
||||||
|
shadow-offset-y = mkDefault (elemAt cfg.shadowOffsets 1);
|
||||||
|
shadow-opacity = mkDefault (toFloat cfg.shadowOpacity);
|
||||||
|
shadow-exclude = mkDefault cfg.shadowExclude;
|
||||||
|
|
||||||
|
# opacity
|
||||||
|
active-opacity = mkDefault (toFloat cfg.activeOpacity);
|
||||||
|
inactive-opacity = mkDefault (toFloat cfg.inactiveOpacity);
|
||||||
|
|
||||||
|
wintypes = mkDefault cfg.wintypes;
|
||||||
|
|
||||||
|
opacity-rule = mkDefault cfg.opacityRules;
|
||||||
|
|
||||||
|
# other options
|
||||||
|
backend = mkDefault cfg.backend;
|
||||||
|
vsync = mkDefault cfg.vSync;
|
||||||
|
refresh-rate = mkDefault cfg.refreshRate;
|
||||||
|
};
|
||||||
|
|
||||||
systemd.user.services.compton = {
|
systemd.user.services.compton = {
|
||||||
description = "Compton composite manager";
|
description = "Compton composite manager";
|
||||||
wantedBy = [ "graphical-session.target" ];
|
wantedBy = [ "graphical-session.target" ];
|
||||||
|
@ -271,13 +275,13 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${cfg.package}/bin/compton --config ${configFile}";
|
ExecStart = "${pkgs.compton}/bin/compton --config ${configFile}";
|
||||||
RestartSec = 3;
|
RestartSec = 3;
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ pkgs.compton ];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{ stdenv, lib, fetchFromGitHub, pkgconfig, asciidoc, docbook_xml_dtd_45
|
{ stdenv, lib, fetchFromGitHub, pkgconfig, uthash, asciidoc, docbook_xml_dtd_45
|
||||||
, docbook_xsl, libxslt, libxml2, makeWrapper, meson, ninja
|
, docbook_xsl, libxslt, libxml2, makeWrapper, meson, ninja
|
||||||
, xorgproto, libxcb ,xcbutilrenderutil, xcbutilimage, pixman, libev
|
, xorgproto, libxcb ,xcbutilrenderutil, xcbutilimage, pixman, libev
|
||||||
, dbus, libconfig, libdrm, libGL, pcre, libX11
|
, dbus, libconfig, libdrm, libGL, pcre, libX11
|
||||||
, libXinerama, libXext, xwininfo, libxdg_basedir }:
|
, libXinerama, libXext, xwininfo, libxdg_basedir }:
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "compton";
|
pname = "compton";
|
||||||
version = "6.2";
|
version = "7";
|
||||||
|
|
||||||
COMPTON_VERSION = "v${version}";
|
COMPTON_VERSION = "v${version}";
|
||||||
|
|
||||||
|
@ -13,12 +13,14 @@ stdenv.mkDerivation rec {
|
||||||
owner = "yshui";
|
owner = "yshui";
|
||||||
repo = "compton";
|
repo = "compton";
|
||||||
rev = COMPTON_VERSION;
|
rev = COMPTON_VERSION;
|
||||||
sha256 = "03fi9q8zw2qrwpkmy1bnavgfh91ci9in5fdi17g4s5s0n2l7yil7";
|
sha256 = "0f23dv2p1snlpzc91v38q6896ncz4zqzmh2d97yf66j78g21awas";
|
||||||
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
meson ninja
|
meson ninja
|
||||||
pkgconfig
|
pkgconfig
|
||||||
|
uthash
|
||||||
asciidoc
|
asciidoc
|
||||||
docbook_xml_dtd_45
|
docbook_xml_dtd_45
|
||||||
docbook_xsl
|
docbook_xsl
|
||||||
|
@ -41,7 +43,7 @@ stdenv.mkDerivation rec {
|
||||||
];
|
];
|
||||||
|
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
git() { echo "v${version}"; }
|
git() { echo "$COMPTON_VERSION"; }
|
||||||
export -f git
|
export -f git
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue