about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tools/eaglemode/default.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/eaglemode/default.nix b/tools/eaglemode/default.nix
index 32f117c9bf5f..5bab3155da1e 100644
--- a/tools/eaglemode/default.nix
+++ b/tools/eaglemode/default.nix
@@ -54,4 +54,21 @@ rec {
              then builtins.readFile code
              else throw "code must be a string (literal code) or path to file")}
     '');
+
+  # etcDir creates a directory layout suitable for use in the EM_USER_CONFIG_DIR
+  # environment variable.
+  #
+  # Note that Eagle Mode requires the value of that variable to be mutable at
+  # runtime (it is the same place where it persists all of its user-controlled
+  # state), so the results of this function can not be used directly.
+  etcDir =
+    { eaglemode ? pkgs.eaglemode
+    , extraPaths ? [ ]
+    }: pkgs.runCommand "eaglemode-config" { } ''
+      mkdir $out
+
+      ${
+        lib.concatMapStringsSep "\n" (s: "cp -rT ${s} $out/\nchmod -R u+rw $out/\n") ([ "${eaglemode}/etc"] ++ extraPaths)
+      }
+    '';
 }