From 87c1b02e31824acd5b21e8afed7c2a33d05cc5c0 Mon Sep 17 00:00:00 2001
From: 514fpv <koishi@514fpv.one>
Date: Sun, 28 Apr 2024 10:58:54 +0800
Subject: [PATCH] feat(jetbrains): add jetbrains products

---
 home/jetbrains/home.nix  | 11 +++++++++++
 home/jetbrains/nixos.nix | 26 ++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 home/jetbrains/home.nix
 create mode 100644 home/jetbrains/nixos.nix

diff --git a/home/jetbrains/home.nix b/home/jetbrains/home.nix
new file mode 100644
index 00000000..90f931d2
--- /dev/null
+++ b/home/jetbrains/home.nix
@@ -0,0 +1,11 @@
+{ pkgs
+, lib
+, config
+, ... }: with lib; let
+  cfg = config.passthrough.jetbrains;
+in mkIf cfg.enable {
+  home.packages = with pkgs.jetbrains; [ ] ++
+    optional cfg.idea idea-community ++
+    optional cfg.clion clion ++
+    optional cfg.goland goland;
+}
diff --git a/home/jetbrains/nixos.nix b/home/jetbrains/nixos.nix
new file mode 100644
index 00000000..e0a69550
--- /dev/null
+++ b/home/jetbrains/nixos.nix
@@ -0,0 +1,26 @@
+{ pkgs
+, lib
+, config
+, ... }: with lib; let
+  cfg = config.home.jetbrains;
+in {
+  options.home.jetbrains = {
+    enable = mkEnableOption "jetbrains text editor";
+    idea = mkEnableOption "intellij idea";
+    clion = mkEnableOption "clion ide";
+    goland = mkEnableOption "goland ide" // { default = true; };
+  };
+
+  config = {
+    users.homeModules = [
+      # this module passes jetbrains configuration to home-manager
+      { passthrough.jetbrains = cfg; }
+    ];
+
+    users.home.persist.directories = mkIf cfg.enable [
+      ".java/.userPrefs"
+      ".config/JetBrains"
+      ".local/share/JetBrains"
+    ];
+  };
+}