1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00
home-manager/modules/programs/matplotlib.nix

60 lines
1.5 KiB
Nix
Raw Permalink Normal View History

2019-01-11 15:53:50 +01:00
{ config, lib, ... }:
with lib;
let
cfg = config.programs.matplotlib;
formatLine = o: n: v:
let
formatValue = v:
2020-02-02 00:39:17 +01: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 15:53:50 +01:00
2020-02-02 00:39:17 +01:00
in {
2019-01-11 15:53:50 +01:00
meta.maintainers = [ maintainers.rprospero ];
options.programs.matplotlib = {
enable = mkEnableOption "matplotlib, a plotting library for python";
config = mkOption {
default = { };
type = types.attrsOf types.anything;
2019-01-11 15:53:50 +01:00
description = ''
Add terms to the <filename>matplotlibrc</filename> file to
control the default matplotlib behavior.
'';
example = literalExpression ''
2019-01-11 15:53:50 +01:00
{
backend = "Qt5Agg";
axes = {
grid = true;
facecolor = "black";
edgecolor = "FF9900";
};
grid.color = "FF9900";
}
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Additional commands for matplotlib that will be added to the
<filename>matplotlibrc</filename> file.
'';
};
};
config = mkIf cfg.enable {
2020-02-02 00:39:17 +01:00
xdg.configFile."matplotlib/matplotlibrc".text = concatStringsSep "\n" ([ ]
++ mapAttrsToList (formatLine "") cfg.config
++ optional (cfg.extraConfig != "") cfg.extraConfig) + "\n";
2019-01-11 15:53:50 +01:00
};
}