From 8c8861cb3caaaed938675595dccb0cf88a654319 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 28 Aug 2024 03:04:39 +0300 Subject: [PATCH] feat(tools/eaglemode): add function for creating etc dir Adds an eaglemode.etcDir function which creates a directory structure suitable for use with EM_USER_CONFIG_DIR. The catch is that Eagle Mode requires this to be always writable, so it isn't possible to just point the environment variable at the Nix store and launch it from there. The idea of this function is to make it possible to reuse it in a wrapper script, a home manager module, a NixOS module or whatever that would make it possible to provide the result to Eagle Mode in a mutable location. Change-Id: I95c8b16c6c6fe8510ce9759c9d9b9e36e836e290 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12368 Tested-by: BuildkiteCI Reviewed-by: tazjin Reviewed-by: azahi --- tools/eaglemode/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/eaglemode/default.nix b/tools/eaglemode/default.nix index 32f117c9b..5bab3155d 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) + } + ''; }