fork/home-manager

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

Robert HelgessonMerge PR #421575790441

master
2.5 KiB88 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.programs.joshuto;
7  tomlFormat = pkgs.formats.toml { };
8in {
9  meta.maintainers = [ hm.maintainers.rasmus-kirk ];
10
11  options.programs.joshuto = {
12    enable = mkEnableOption "joshuto file manager";
13
14    package = mkOption {
15      type = types.package;
16      default = pkgs.joshuto;
17      defaultText = literalExpression "pkgs.joshuto";
18      description = "The package to use for joshuto.";
19    };
20
21    settings = mkOption {
22      type = tomlFormat.type;
23      default = { };
24      description = ''
25        Configuration written to
26        {file}`$XDG_CONFIG_HOME/joshuto/joshuto.toml`.
27
28        See <https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/joshuto.toml.md>
29        for the full list of options.
30      '';
31    };
32
33    keymap = mkOption {
34      type = tomlFormat.type;
35      default = { };
36      description = ''
37        Configuration written to
38        {file}`$XDG_CONFIG_HOME/joshuto/keymap.toml`.
39
40        See <https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/keymap.toml.md>
41        for the full list of options. Note that this option will overwrite any existing keybinds.
42      '';
43    };
44
45    mimetype = mkOption {
46      type = tomlFormat.type;
47      default = { };
48      description = ''
49        Configuration written to
50        {file}`$XDG_CONFIG_HOME/joshuto/mimetype.toml`.
51
52        See <https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/mimetype.toml.md>
53        for the full list of options
54      '';
55    };
56
57    theme = mkOption {
58      type = tomlFormat.type;
59      default = { };
60      description = ''
61        Configuration written to
62        {file}`$XDG_CONFIG_HOME/joshuto/theme.toml`.
63
64        See <https://github.com/kamiyaa/joshuto/blob/main/docs/configuration/theme.toml.md>
65        for the full list of options
66      '';
67    };
68  };
69
70  config = mkIf cfg.enable {
71    home.packages = [ cfg.package ];
72
73    xdg.configFile = {
74      "joshuto/joshuto.toml" = mkIf (cfg.settings != { }) {
75        source = tomlFormat.generate "joshuto-settings" cfg.settings;
76      };
77      "joshuto/keymap.toml" = mkIf (cfg.keymap != { }) {
78        source = tomlFormat.generate "joshuto-keymap" cfg.keymap;
79      };
80      "joshuto/mimetype.toml" = mkIf (cfg.mimetype != { }) {
81        source = tomlFormat.generate "joshuto-mimetype" cfg.mimetype;
82      };
83      "joshuto/theme.toml" = mkIf (cfg.theme != { }) {
84        source = tomlFormat.generate "joshuto-theme" cfg.theme;
85      };
86    };
87  };
88}