File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5555 },
5656 {
5757 "name" : " piped" ,
58+ "update_scripts" : [{
59+ "attr_path" : " piped-frontend.passthru.fonts"
60+ }],
5861 "tests" : [{
5962 "attr_path" : " piped-test" ,
6063 "disable_sandbox" : true
Original file line number Diff line number Diff line change 22, lib
33, buildNpmPackage
44, pnpm
5+ , fetchurl
6+ , writeScript
57} :
68
79let
1719
1820 pnpmDeps = doPnpmDeps ( builtins . fromJSON ( builtins . readFile ./npmDepsHash.json ) ) ;
1921
22+ fonts = builtins . mapAttrs ( url : hash : fetchurl { inherit url hash ; } ) ( builtins . fromJSON ( builtins . readFile ./fonts.json ) ) ;
23+ copyFonts = builtins . concatStringsSep "\n " ( lib . mapAttrsToList (
24+ url : font : let
25+ fontPath = "dist/fonts/" + ( builtins . substring ( builtins . stringLength "https://fonts.gstatic.com/" ) ( - 1 ) url ) ;
26+ in ''
27+ mkdir -p $(dirname ${ fontPath } )
28+ cp ${ font } ${ fontPath }
29+ ''
30+ )
31+ fonts ) ;
2032in
2133
2234buildNpmPackage {
@@ -27,11 +39,39 @@ buildNpmPackage {
2739
2840 npmDeps = pnpmDeps ;
2941
42+ postBuild = ''
43+ echo "postBuild"
44+ mkdir -p dist/fonts
45+
46+ ${ copyFonts }
47+
48+ sed -i "s#https://fonts.gstatic.com#/fonts#g" dist/assets/*
49+ ls -l dist/fonts/
50+ '' ;
51+
3052 installPhase = ''
3153 cp dist $out -r
3254 '' ;
3355
34- passthru . hashUpdate = doPnpmDeps "" ;
56+ passthru = {
57+ hashUpdate = doPnpmDeps "" ;
58+ fonts = writeScript "update-font-hashes" ''
59+ #!/usr/bin/env bash
60+
61+ tmp=$(mktemp -d)
62+ cp -r "${ src } " "$tmp/src"
63+ chmod -R 750 $tmp/src
64+ (
65+ cd "$tmp/src"
66+ ${ pnpm } /bin/pnpm install
67+ echo "extracting"
68+ bash ${ ./extract-font-hashes.sh } > fonts.json
69+ cat fonts.json
70+ )
71+ cp "$tmp/src/fonts.json" "piped-frontend/fonts.json"
72+ rm -fr "$tmp"
73+ '' ;
74+ } ;
3575
3676 meta = {
3777 homepage = "https://github.com/TeamPiped/piped" ;
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env nix-shell
2+ #! nix-shell -i bash -p curl nix
3+
4+ fonts=($( grep -hPo " https://fonts\.gstatic\.com/s[^)]*" -r node_modules/ | sort | uniq) )
5+ echo ' {'
6+ for font in " ${fonts[@]} " ; do
7+ hash=$( nix-hash --to-sri --type sha256 $( nix-prefetch-url " $font " 2> /dev/null) )
8+ if [ " $font " = " ${fonts[-1]} " ]; then
9+ echo ' "' " $font " ' "' : ' "' " $hash " ' "'
10+ else
11+ echo ' "' " $font " ' "' : ' "' " $hash " ' ",'
12+ fi
13+ done
14+ echo ' }'
Original file line number Diff line number Diff line change 1+ {
2+ "https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmM.otf" : " sha256-utheVFS2KIEEzgOAbDcyO82PFF4wlOcnhgFzrIyRBi4=" ,
3+ "https://fonts.gstatic.com/s/roboto/v48/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmUiA8.ttf" : " sha256-Z6CSYilO1dB4PF8qsg2Wc2VMLePQOHBHN+v+noJu1hM="
4+ }
You can’t perform that action at this time.
0 commit comments