javascript.nix (971B)
1 { pkgs }: 2 let 3 editor = import ./codemirror { inherit pkgs; }; 4 lock = builtins.fromJSON (builtins.readFile ./codemirror/sources.json); 5 paths = builtins.listToAttrs (map (row: { 6 name = row.name; 7 value = [ (if pkgs.lib.hasSuffix ".js" row.entry 8 then "${editor}/deps/${row.slug}/${pkgs.lib.removeSuffix ".js" row.entry}.d.ts" 9 else "${editor}/types/${row.slug}/${pkgs.lib.removeSuffix ".ts" row.entry}.d.ts") ]; 10 }) lock); 11 in pkgs.runCommand "arboricx-site-javascript" { nativeBuildInputs = [pkgs.typescript pkgs.python3]; } '' 12 cp -r ${./src} src 13 cp ${./tsconfig.json} tsconfig.json 14 cat > build.json <<'JSON' 15 {"extends":"./tsconfig.json","compilerOptions":{"paths":${builtins.toJSON paths},"skipLibCheck":true}} 16 JSON 17 tsc -p build.json 18 cp ${editor}/codemirror.js dist/ 19 for file in ${editor}/licenses/*.txt; do 20 printf '\n--- %s ---\n' "$(basename "$file")" 21 cat "$file" 22 done > dist/codemirror.LICENSE.txt 23 cp -r dist $out 24 ''