summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-09-07 22:57:22 +0200
committerGitHub <noreply@github.com>2023-09-07 22:57:22 +0200
commit4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6 (patch)
treeb5171737273932590649f397b9cff9ab1fd494ca /nixos/modules/programs
parenteb1c3455121fe24c3785dfa9aa0a1875a34dc1a6 (diff)
parent6b2934d6e906a53634085a0cd636f2f0d110a6ed (diff)
downloadnixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar.gz
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar.bz2
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar.lz
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar.xz
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.tar.zst
nixpkgs-4fbea0f80b512fdb35dcffd0b272b0e4688c2cc6.zip
Merge pull request #253071 from linsui/yazi
nixos/yazi: init
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/yazi.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/nixos/modules/programs/yazi.nix b/nixos/modules/programs/yazi.nix
new file mode 100644
index 00000000000..3416bca0667
--- /dev/null
+++ b/nixos/modules/programs/yazi.nix
@@ -0,0 +1,49 @@
+{ config, lib, pkgs, ... }:
+
+let
+  cfg = config.programs.yazi;
+
+  settingsFormat = pkgs.formats.toml { };
+
+  names = [ "yazi" "theme" "keymap" ];
+in
+{
+  options.programs.yazi = {
+    enable = lib.mkEnableOption (lib.mdDoc "yazi terminal file manager");
+
+    package = lib.mkPackageOptionMD pkgs "yazi" { };
+
+    settings = lib.mkOption {
+      type = with lib.types; submodule {
+        options = lib.listToAttrs (map
+          (name: lib.nameValuePair name (lib.mkOption {
+            inherit (settingsFormat) type;
+            default = { };
+            description = lib.mdDoc ''
+              Configuration included in `${name}.toml`.
+
+              See https://github.com/sxyazi/yazi/blob/v${cfg.package.version}/config/docs/${name}.md for documentation.
+            '';
+          }))
+          names);
+      };
+      default = { };
+      description = lib.mdDoc ''
+        Configuration included in `$YAZI_CONFIG_HOME`.
+      '';
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    environment = {
+      systemPackages = [ cfg.package ];
+      variables.YAZI_CONFIG_HOME = "/etc/yazi/";
+      etc = lib.attrsets.mergeAttrsList (map
+        (name: lib.optionalAttrs (cfg.settings.${name} != { }) {
+          "yazi/${name}.toml".source = settingsFormat.generate "${name}.toml" cfg.settings.${name};
+        })
+        names);
+    };
+  };
+  meta.maintainers = with lib.maintainers; [ linsui ];
+}