fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Lily Fosterhyfetch: prevent writing config with default/empty settings (#3124)77648a07

master
982 B44 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.programs.hyfetch;
7
8  jsonFormat = pkgs.formats.json { };
9in {
10  meta.maintainers = [ maintainers.lilyinstarlight ];
11
12  options.programs.hyfetch = {
13    enable = mkEnableOption "hyfetch";
14
15    package = mkOption {
16      type = types.package;
17      default = pkgs.hyfetch;
18      defaultText = literalExpression "pkgs.hyfetch";
19      description = "The hyfetch package to use.";
20    };
21
22    settings = mkOption {
23      type = jsonFormat.type;
24      default = { };
25      example = literalExpression ''
26        {
27          preset = "rainbow";
28          mode = "rgb";
29          color_align = {
30            mode = "horizontal";
31          };
32        }
33      '';
34      description = "JSON config for HyFetch";
35    };
36  };
37
38  config = mkIf cfg.enable {
39    home.packages = [ cfg.package ];
40    xdg.configFile."hyfetch.json" = mkIf (cfg.settings != { }) {
41      source = jsonFormat.generate "hyfetch.json" cfg.settings;
42    };
43  };
44}