File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ with lib.types;
21
21
shell = mkOption {
22
22
type = submodule [
23
23
( import ./shell.nix { projectConfig = config ; } )
24
- { _module . args = { inherit ( pkgs . haskell-nix ) haskellLib ; } ; }
24
+ { _module . args = { inherit pkgs ; inherit ( pkgs . haskell-nix ) haskellLib ; } ; }
25
25
] ;
26
26
default = { } ;
27
27
description = ''
Original file line number Diff line number Diff line change 63
63
} ;
64
64
shellHook = lib . mkOption {
65
65
type = lib . types . str ;
66
- default = "" ;
66
+ # Shell hook to set EM_CACHE to a writable temporary directory if not already set
67
+ default = lib . optionalString pkgs . stdenv . hostPlatform . isGhcjs ''
68
+ if [ -z "$EM_CACHE" ]; then
69
+ # Create a unique temporary directory using mktemp
70
+ EM_CACHE_DIR=$(mktemp -d -t emcache-ghcjs-XXXXXX)
71
+
72
+ # Copy the default Emscripten cache contents to the temporary directory
73
+ DEFAULT_EM_CACHE="${ pkgs . pkgsBuildBuild . emscripten } /share/emscripten/cache"
74
+ if [ -d "$DEFAULT_EM_CACHE" ]; then
75
+ cp -r "$DEFAULT_EM_CACHE"/* "$EM_CACHE_DIR" 2>/dev/null || true
76
+ chmod -R u+w "$EM_CACHE_DIR"
77
+ fi
78
+
79
+ export EM_CACHE="$EM_CACHE_DIR"
80
+ echo "Set EM_CACHE to $EM_CACHE"
81
+ else
82
+ echo "EM_CACHE already set to $EM_CACHE"
83
+ fi
84
+ '' ;
67
85
} ;
68
86
69
87
# mkDerivation args
You can’t perform that action at this time.
0 commit comments