1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-15 17:50:53 +00:00
home-manager/modules/programs/matplotlib.nix

60 lines
1.4 KiB
Nix
Raw Normal View History

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 = {
enable = mkEnableOption "matplotlib, a plotting library for python";
2019-01-11 14:53:50 +00:00
config = mkOption {
default = { };
type = types.attrsOf types.anything;
description = ''
Add terms to the {file}`matplotlibrc` file to
2019-01-11 14:53:50 +00:00
control the default matplotlib behavior.
'';
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 = "";
description = ''
2019-01-11 14:53:50 +00:00
Additional commands for matplotlib that will be added to the
{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
};
}