fork/home-manager

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

Otavio Salvadorprograms.rio: add module (#4118)f092a922

master
1.6 KiB52 linesraw
1{ lib, pkgs, config, ... }:
2let
3  cfg = config.programs.rio;
4
5  settingsFormat = pkgs.formats.toml { };
6
7  inherit (pkgs.stdenv.hostPlatform) isDarwin;
8in {
9  options.programs.rio = {
10    enable = lib.mkEnableOption null // {
11      description = lib.mdDoc ''
12        Enable Rio, a terminal built to run everywhere, as a native desktop applications by
13        Rust/WebGPU or even in the browsers powered by WebAssembly/WebGPU.
14      '';
15    };
16
17    package = lib.mkPackageOption pkgs "rio" { };
18
19    settings = lib.mkOption {
20      type = settingsFormat.type;
21      default = { };
22      description = ''
23        Configuration written to <filename>$XDG_CONFIG_HOME/rio/config.toml</filename> on Linux or
24        <filename>$HOME/Library/Application Support/rio/config.toml</filename> on Darwin. See
25        <link xlink:href="https://raphamorim.io/rio/docs/#configuration-file"/> for options.
26      '';
27    };
28  };
29  meta.maintainers = [ lib.maintainers.otavio ];
30
31  config = lib.mkIf cfg.enable (lib.mkMerge [
32    {
33      home.packages = [ cfg.package ];
34    }
35
36    # Only manage configuration if not empty
37    (lib.mkIf (cfg.settings != { } && !isDarwin) {
38      xdg.configFile."rio/config.toml".source = if lib.isPath cfg.settings then
39        cfg.settings
40      else
41        settingsFormat.generate "rio.toml" cfg.settings;
42    })
43
44    (lib.mkIf (cfg.settings != { } && isDarwin) {
45      home.file."Library/Application Support/rio/config.toml".source =
46        if lib.isPath cfg.settings then
47          cfg.settings
48        else
49          settingsFormat.generate "rio.toml" cfg.settings;
50    })
51  ]);
52}