diff --git a/flake.nix b/flake.nix index e8fb8ca..6902b9d 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,31 @@ let pkgs = import inputs.nixpkgs { inherit system; }; + mkWOFF2From = + name: pkg: ext: + pkgs.stdenvNoCC.mkDerivation { + name = "${name}-woff2"; + nativeBuildInputs = [ + pkgs.fontforge + pkg + ]; + dontInstall = true; + unpackPhase = '' + WOFF2_DIR="$out/share/fonts/woff2/" + mkdir -p "$WOFF2_DIR" + for file in ${pkg}/share/fonts/truetype/*.${ext}; do + NAME="$(basename $file .${ext})" + fontforge --lang=ff \ + -c 'Open($1); Generate($2);' \ + "$file" \ + "$WOFF2_DIR/$NAME.woff2" & + done + wait + ''; + }; + + iosevka-comfy-woff2 = mkWOFF2From "iosevka-comfy-fixed" pkgs.iosevka-comfy.comfy-fixed "ttf"; + rundev = pkgs.writeShellApplication { name = "rundev"; runtimeInputs = [ @@ -19,15 +44,16 @@ (pkgs.writeShellApplication { name = "buildapp"; text = '' - tailwindcss -i static/style.css -o static/generated.css && \ - templ generate && \ - go build && \ - ./app + function buildapp() { + ${self.defaultPackage.${system}.preBuild} + go build + } + buildapp && ./app ''; }) ]; text = '' - if [ -z "$1" ]; then + if [ $# -eq 0 ]; then buildapp elif [ "$1" = "--watch" ]; then fd | entr -c -r buildapp @@ -58,6 +84,8 @@ makeWrapper ]; preBuild = '' + install -D ${iosevka-comfy-woff2}/share/fonts/woff2/iosevka-comfy-fixed-regular.woff2 static/ + install -D ${iosevka-comfy-woff2}/share/fonts/woff2/iosevka-comfy-fixed-bold.woff2 static/ templ generate tailwindcss -i static/style.css -o static/generated.css ''; diff --git a/pkg/app/template.templ b/pkg/app/template.templ index 8c57083..b564c4e 100644 --- a/pkg/app/template.templ +++ b/pkg/app/template.templ @@ -18,7 +18,6 @@ templ (app *Server) Template(body templ.Component) {