From 453e3d96d1b96d42c86044ac273d1b8a11dbb94a Mon Sep 17 00:00:00 2001
From: teutat3s <teutates@mailbox.org>
Date: Mon, 24 Feb 2025 22:30:40 +0100
Subject: [PATCH] nextcloud: initial skeleton directory derivation

for English and German
---
 modules/nextcloud/default.nix                 |   2 +-
 overlays/default.nix                          |   1 +
 .../de/Dokumente/Beispiel.odt                 | Bin
 .../nextcloud-skeleton/de/Fotos/pubsolar.png  | Bin
 .../nextcloud-skeleton/de/Fotos/pubsolar.svg  |   0
 .../pkgs/nextcloud-skeleton/de/Liesmich.md    |   0
 overlays/pkgs/nextcloud-skeleton/default.nix  |  33 ++++++++++++++++++
 .../en/Documents/Example.odt                  | Bin
 .../en/Pictures/pubsolar.png                  | Bin
 .../en/Pictures/pubsolar.svg                  |   0
 .../pkgs}/nextcloud-skeleton/en/Readme.md     |   0
 11 files changed, 35 insertions(+), 1 deletion(-)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/de/Dokumente/Beispiel.odt (100%)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/de/Fotos/pubsolar.png (100%)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/de/Fotos/pubsolar.svg (100%)
 rename modules/nextcloud/nextcloud-skeleton/de/Readme.md => overlays/pkgs/nextcloud-skeleton/de/Liesmich.md (100%)
 create mode 100644 overlays/pkgs/nextcloud-skeleton/default.nix
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/en/Documents/Example.odt (100%)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/en/Pictures/pubsolar.png (100%)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/en/Pictures/pubsolar.svg (100%)
 rename {modules/nextcloud => overlays/pkgs}/nextcloud-skeleton/en/Readme.md (100%)

diff --git a/modules/nextcloud/default.nix b/modules/nextcloud/default.nix
index 597495e..61da6ce 100644
--- a/modules/nextcloud/default.nix
+++ b/modules/nextcloud/default.nix
@@ -92,7 +92,7 @@
 
       auth.bruteforce.protection.enabled = true;
       trashbin_retention_obligation = "auto,7";
-      skeletondirectory = "/var/lib/nextcloud/skeleton/{lang}";
+      skeletondirectory = "${pkgs.nextcloud-skeleton}/{lang}";
       defaultapp = "file";
       activity_expire_days = "14";
       integrity.check.disabled = false;
diff --git a/overlays/default.nix b/overlays/default.nix
index 30e03e5..f9c3039 100644
--- a/overlays/default.nix
+++ b/overlays/default.nix
@@ -17,6 +17,7 @@
                 element-stickerpicker = prev.callPackage ./pkgs/element-stickerpicker {
                   inherit (inputs) element-stickers maunium-stickerpicker;
                 };
+                nextcloud-skeleton = prev.callPackage ./pkgs/nextcloud-skeleton { };
               }
             )
           ];
diff --git a/modules/nextcloud/nextcloud-skeleton/de/Dokumente/Beispiel.odt b/overlays/pkgs/nextcloud-skeleton/de/Dokumente/Beispiel.odt
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/de/Dokumente/Beispiel.odt
rename to overlays/pkgs/nextcloud-skeleton/de/Dokumente/Beispiel.odt
diff --git a/modules/nextcloud/nextcloud-skeleton/de/Fotos/pubsolar.png b/overlays/pkgs/nextcloud-skeleton/de/Fotos/pubsolar.png
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/de/Fotos/pubsolar.png
rename to overlays/pkgs/nextcloud-skeleton/de/Fotos/pubsolar.png
diff --git a/modules/nextcloud/nextcloud-skeleton/de/Fotos/pubsolar.svg b/overlays/pkgs/nextcloud-skeleton/de/Fotos/pubsolar.svg
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/de/Fotos/pubsolar.svg
rename to overlays/pkgs/nextcloud-skeleton/de/Fotos/pubsolar.svg
diff --git a/modules/nextcloud/nextcloud-skeleton/de/Readme.md b/overlays/pkgs/nextcloud-skeleton/de/Liesmich.md
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/de/Readme.md
rename to overlays/pkgs/nextcloud-skeleton/de/Liesmich.md
diff --git a/overlays/pkgs/nextcloud-skeleton/default.nix b/overlays/pkgs/nextcloud-skeleton/default.nix
new file mode 100644
index 0000000..7caf76c
--- /dev/null
+++ b/overlays/pkgs/nextcloud-skeleton/default.nix
@@ -0,0 +1,33 @@
+# Based on:
+# https://nix.dev/tutorials/working-with-local-files.html#union-explicitly-include-files
+{
+  stdenvNoCC,
+  lib,
+}:
+let
+  fs = lib.fileset;
+  sourceFiles = fs.unions [
+    ./en/Documents/Example.odt
+    ./en/Pictures/pubsolar.png
+    ./en/Pictures/pubsolar.svg
+    ./en/Readme.md
+    ./de/Dokumente/Beispiel.odt
+    ./de/Fotos/pubsolar.png
+    ./de/Fotos/pubsolar.svg
+    ./de/Liesmich.md
+  ];
+in
+
+fs.trace sourceFiles
+
+  stdenvNoCC.mkDerivation
+  {
+    name = "nextcloud-skeleton";
+    src = fs.toSource {
+      root = ./.;
+      fileset = sourceFiles;
+    };
+    postInstall = ''
+      cp -vr . $out
+    '';
+  }
diff --git a/modules/nextcloud/nextcloud-skeleton/en/Documents/Example.odt b/overlays/pkgs/nextcloud-skeleton/en/Documents/Example.odt
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/en/Documents/Example.odt
rename to overlays/pkgs/nextcloud-skeleton/en/Documents/Example.odt
diff --git a/modules/nextcloud/nextcloud-skeleton/en/Pictures/pubsolar.png b/overlays/pkgs/nextcloud-skeleton/en/Pictures/pubsolar.png
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/en/Pictures/pubsolar.png
rename to overlays/pkgs/nextcloud-skeleton/en/Pictures/pubsolar.png
diff --git a/modules/nextcloud/nextcloud-skeleton/en/Pictures/pubsolar.svg b/overlays/pkgs/nextcloud-skeleton/en/Pictures/pubsolar.svg
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/en/Pictures/pubsolar.svg
rename to overlays/pkgs/nextcloud-skeleton/en/Pictures/pubsolar.svg
diff --git a/modules/nextcloud/nextcloud-skeleton/en/Readme.md b/overlays/pkgs/nextcloud-skeleton/en/Readme.md
similarity index 100%
rename from modules/nextcloud/nextcloud-skeleton/en/Readme.md
rename to overlays/pkgs/nextcloud-skeleton/en/Readme.md