mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
61 lines
1.5 KiB
Nix
61 lines
1.5 KiB
Nix
{ config, lib, ... }:
|
|
let
|
|
inherit (lib) mkIf mkOption types;
|
|
|
|
cfg = config.programs.matplotlib;
|
|
|
|
formatLine =
|
|
o: n: v:
|
|
let
|
|
formatValue = v: if lib.isBool v then (if v then "True" else "False") else toString v;
|
|
in
|
|
if lib.isAttrs v then
|
|
lib.concatStringsSep "\n" (lib.mapAttrsToList (formatLine "${o}${n}.") v)
|
|
else
|
|
(if v == "" then "" else "${o}${n}: ${formatValue v}");
|
|
|
|
in
|
|
{
|
|
meta.maintainers = [ lib.maintainers.rprospero ];
|
|
|
|
options.programs.matplotlib = {
|
|
enable = lib.mkEnableOption "matplotlib, a plotting library for python";
|
|
|
|
config = mkOption {
|
|
default = { };
|
|
type = types.attrsOf types.anything;
|
|
description = ''
|
|
Add terms to the {file}`matplotlibrc` file to
|
|
control the default matplotlib behavior.
|
|
'';
|
|
example = {
|
|
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
|
|
{file}`matplotlibrc` file.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
xdg.configFile."matplotlib/matplotlibrc".text =
|
|
lib.concatStringsSep "\n" (
|
|
lib.mapAttrsToList (formatLine "") cfg.config
|
|
++ lib.optional (cfg.extraConfig != "") cfg.extraConfig
|
|
)
|
|
+ "\n";
|
|
};
|
|
}
|