From b67b555e445d5373b5e63441cc05c32e6fb9f342 Mon Sep 17 00:00:00 2001 From: Alex Ameen Date: Sat, 22 Jul 2023 10:08:59 -0500 Subject: [PATCH] align registry template floco-cfg.nix with basic template (#61) --- templates/basic/foverrides.nix | 8 ++++++++ templates/registry/floco-cfg.nix | 22 +++++++++++++++++----- templates/registry/foverrides.nix | 7 +++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/templates/basic/foverrides.nix b/templates/basic/foverrides.nix index 4ed77c1..7800d4e 100644 --- a/templates/basic/foverrides.nix +++ b/templates/basic/foverrides.nix @@ -63,6 +63,14 @@ in { ##]; + # The `copyTree' which will cause the `node_modules/' directory to be copied + # and made writable at when `build' scripts are run. + # This can help resolve common issues with packages using tools like + # `angular' which modify the contents of their `node_modules/' directory + # at build time. + ##built.copyTree = true; + + # ---------------------------------------------------------------------------- # }; # End target package overrides diff --git a/templates/registry/floco-cfg.nix b/templates/registry/floco-cfg.nix index 306fe2d..6ddb0ff 100644 --- a/templates/registry/floco-cfg.nix +++ b/templates/registry/floco-cfg.nix @@ -7,11 +7,23 @@ { imports = let - ifExist = builtins.filter builtins.pathExists [ - ./pdefs.nix # Generated `pdefs.nix' - ./foverrides.nix # Explicit config - ]; - in ifExist ++ [ + maybePdefs = + if builtins.pathExists ./pdefs.nix then [./pdefs.nix] else + if builtins.pathExists ./pdefs.json then [{ + _file = ./pdefs.json; + config = let + c = builtins.fromJSON ( builtins.readFile ./pdefs.json ); + in c.config or c; + }] else []; + maybeFoverrides = + if builtins.pathExists ./foverrides.nix then [./foverrides.nix] else + if builtins.pathExists ./foverrides.json then [{ + _file = ./foverrides.json; + config = let + c = builtins.fromJSON ( builtins.readFile ./foverrides.json ); + in c.config or c; + }] else []; + in maybePdefs ++ maybeFoverrides ++ [ # CHANGEME: If you depend on other `floco' projects, you can import their # `floco-cfg.nix' files here to make those configs available. ]; diff --git a/templates/registry/foverrides.nix b/templates/registry/foverrides.nix index 684c624..f4718cf 100644 --- a/templates/registry/foverrides.nix +++ b/templates/registry/foverrides.nix @@ -26,11 +26,18 @@ in { # Nixpkgs to the "install" phase environment. # This is useful for linking against libraries when running `node-gyp' # and providing other utilities that may be required. + # + # Below that segment, you'll see an option to `copyTree' which will cause + # the `node_modules/' directory to be copied and made writable at when + # `install' scripts are run. + # This can help resolve issues with packages such as `esbuild' which + # modify the contents of their `node_modules/' directory at install time. ##installed = { pkgs, ... }: { ## extraBuildInputs = [ ## pkgs.pkgconfig ## ]; + ## copyTree = true; ##};