about summary refs log tree commit diff
path: root/modules/common
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-08-02 13:41:53 +0300
committerAzat Bahawi <azat@bahawi.net>2023-08-02 13:41:53 +0300
commit17928bd2eabb2dca1c870c8af3f43eeac96e181b (patch)
treeaddb81d79b2511aa647349f63da376c296d711de /modules/common
parent2023-07-31 (diff)
2023-08-02
Diffstat (limited to 'modules/common')
-rw-r--r--modules/common/common/default.nix1
-rw-r--r--modules/common/common/nix/default.nix2
-rw-r--r--modules/common/common/xdg.nix53
-rw-r--r--modules/common/git.nix11
4 files changed, 60 insertions, 7 deletions
diff --git a/modules/common/common/default.nix b/modules/common/common/default.nix
index 8849ad9..a516ef3 100644
--- a/modules/common/common/default.nix
+++ b/modules/common/common/default.nix
@@ -8,5 +8,6 @@ _: {
     ./secrets.nix
     ./shell
     ./users.nix
+    ./xdg.nix
   ];
 }
diff --git a/modules/common/common/nix/default.nix b/modules/common/common/nix/default.nix
index e516500..29d6b2d 100644
--- a/modules/common/common/nix/default.nix
+++ b/modules/common/common/nix/default.nix
@@ -97,6 +97,8 @@ with lib; {
           patches = final.patches ++ [./patches/tdesktop-no-ads.patch];
         });
 
+        inherit (pkgsPr 246555 "sha256-GQJ0hFyQIKQXekdDX59v5y65AYxiU8W2y+dktXEsN/g=") qzdl;
+
         inherit (pkgsPr 245433 "sha256-7duAw2pGwXrX4cgUioNSypmuiNR/hCUVywhKL6jW3qE=") openmw;
       }
       // (let
diff --git a/modules/common/common/xdg.nix b/modules/common/common/xdg.nix
new file mode 100644
index 0000000..04ca544
--- /dev/null
+++ b/modules/common/common/xdg.nix
@@ -0,0 +1,53 @@
+{
+  config,
+  lib,
+  ...
+}:
+with lib; {
+  imports = let
+    withBase = a: ["nixfiles" "modules" "common" "xdg" a];
+  in [
+    (mkAliasOptionModule ["dirs" "cache"] (withBase "cacheHome"))
+    (mkAliasOptionModule ["dirs" "config"] (withBase "configHome"))
+    (mkAliasOptionModule ["dirs" "data"] (withBase "dataHome"))
+    (mkAliasOptionModule ["dirs" "state"] (withBase "stateHome"))
+    (mkAliasOptionModule ["userDirs"] (withBase "userDirs"))
+  ];
+
+  options.nixfiles.modules.common.xdg = {
+    cacheHome = mkOption {
+      type = types.str;
+      default = "${config.hm.home.homeDirectory}/.cache";
+    };
+    configHome = mkOption {
+      type = types.str;
+      default = "${config.hm.home.homeDirectory}/.config";
+    };
+    dataHome = mkOption {
+      type = types.str;
+      default = "${config.hm.home.homeDirectory}/.local/share";
+    };
+    stateHome = mkOption {
+      type = types.str;
+      default = "${config.hm.home.homeDirectory}/.local/state";
+    };
+    userDirs = mkOption {
+      type = types.attrs;
+      default = let
+        inherit (config.my) home;
+        tmp = home + "/tmp";
+      in {
+        enable = true;
+
+        desktop = tmp;
+        documents = "${home}/doc";
+        download = tmp;
+        music = tmp;
+        pictures = tmp;
+        publicShare = "${home}/share";
+        templates = tmp;
+        videos = tmp;
+      };
+    };
+  };
+}
diff --git a/modules/common/git.nix b/modules/common/git.nix
index 0bd7720..2e5c834 100644
--- a/modules/common/git.nix
+++ b/modules/common/git.nix
@@ -13,23 +13,20 @@ in {
     mkEnableOption "Git client";
 
   config = mkIf cfg.client.enable {
-    secrets = let
-      # HACK MacOS doesn't support XDG specifications.
-      configHome = "${config.my.home}/.config";
-    in {
+    secrets = {
       glab-cli-config = {
         file = "${inputs.self}/secrets/glab-cli-config";
-        path = "${configHome}/glab-cli/config.yml";
+        path = "${config.dirs.config}/glab-cli/config.yml";
         owner = localUsername;
       };
       gh-hosts = {
         file = "${inputs.self}/secrets/gh-hosts";
-        path = "${configHome}/gh/hosts.yml";
+        path = "${config.dirs.config}/gh/hosts.yml";
         owner = localUsername;
       };
       hut = {
         file = "${inputs.self}/secrets/hut";
-        path = "${configHome}/hut/config";
+        path = "${config.dirs.config}/hut/config";
         owner = localUsername;
       };
     };

Consider giving Nix/NixOS a try! <3