2019-01-11 14:53:50 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.matplotlib;
|
|
|
|
|
|
|
|
formatLine = o: n: v:
|
|
|
|
let
|
|
|
|
formatValue = v:
|
2020-02-01 23:39:17 +00:00
|
|
|
if isBool v then (if v then "True" else "False") else toString v;
|
|
|
|
in if isAttrs v then
|
|
|
|
concatStringsSep "\n" (mapAttrsToList (formatLine "${o}${n}.") v)
|
|
|
|
else
|
|
|
|
(if v == "" then "" else "${o}${n}: ${formatValue v}");
|
2019-01-11 14:53:50 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2019-01-11 14:53:50 +00:00
|
|
|
meta.maintainers = [ maintainers.rprospero ];
|
|
|
|
|
|
|
|
options.programs.matplotlib = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "matplotlib, a plotting library for python";
|
2019-01-11 14:53:50 +00:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
default = { };
|
2020-11-30 02:54:55 +00:00
|
|
|
type = types.attrsOf types.anything;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Add terms to the {file}`matplotlibrc` file to
|
2019-01-11 14:53:50 +00:00
|
|
|
control the default matplotlib behavior.
|
|
|
|
'';
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2019-01-11 14:53:50 +00:00
|
|
|
{
|
|
|
|
backend = "Qt5Agg";
|
|
|
|
axes = {
|
|
|
|
grid = true;
|
|
|
|
facecolor = "black";
|
|
|
|
edgecolor = "FF9900";
|
|
|
|
};
|
|
|
|
grid.color = "FF9900";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2019-01-11 14:53:50 +00:00
|
|
|
Additional commands for matplotlib that will be added to the
|
2023-06-30 23:30:13 +00:00
|
|
|
{file}`matplotlibrc` file.
|
2019-01-11 14:53:50 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-02-01 23:39:17 +00:00
|
|
|
xdg.configFile."matplotlib/matplotlibrc".text = concatStringsSep "\n" ([ ]
|
|
|
|
++ mapAttrsToList (formatLine "") cfg.config
|
|
|
|
++ optional (cfg.extraConfig != "") cfg.extraConfig) + "\n";
|
2019-01-11 14:53:50 +00:00
|
|
|
};
|
|
|
|
}
|