default = {};
type = attrsOf (submodule {
options = {
+ assetType = mkOption { type = enum ["tgz" "url" "googleFont"]; default = "url"; description = "Type of asset"; };
+ tgzRemoveComponents = mkOption { type = int; default = 0; description = "Remove components when extracting"; };
url = mkOption { type = str; description = "URL to fetch"; };
sha256 = mkOption { type = str; description = "Hash of the url"; };
};
{ lib, pkgs, config, ... }:
let
cfg = config.myServices.websites.tools.assets;
- assets_urls = lib.mapAttrs (k: v: pkgs.fetchurl v) config.myEnv.tools.assets;
+ fetchFont = v: pkgs.runCommand "fetch-font" {
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = v.sha256;
+ } ''
+ mkdir -p $out
+ ${pkgs.curl}/bin/curl -k --output $out/font.css -H "User-Agent: Firefox/100.0" "${v.url}"
+ cat $out/font.css | grep -o "https://[^ )]*" | while read url; do
+ filename=$(echo "$url" | sed -e "s@.*/@@g")
+ ${pkgs.curl}/bin/curl -k --output "$out/$filename" "$url"
+ sed -i -e "s@$url@./$filename@" "$out/font.css"
+ done
+ '';
+ fetchTgz = v: pkgs.runCommand "fetch-tgz" {
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = v.sha256;
+ } ''
+ mkdir -p $out
+ cd $out
+ ${pkgs.curl}/bin/curl -L -k "${v.url}" | tar -xz --strip-components=${builtins.toString v.tgzRemoveComponents}
+ '';
+ fetchAsset = v:
+ if v.assetType == "googleFont"
+ then fetchFont v
+ else if v.assetType == "tgz"
+ then fetchTgz v
+ else pkgs.fetchurl { url = v.url; sha256 = v.sha256; };
+ assets_urls = lib.mapAttrs (k: fetchAsset) config.myEnv.tools.assets;
assets = pkgs.runCommand "assets" {} (''
mkdir -p $out
cp -a ${./static}/* $out/
'' + builtins.concatStringsSep "\n"
(lib.mapAttrsToList (k: v: ''
- install -D -m644 -T ${v} $out/${k}
+ if [ -d "${v}" ]; then
+ mkdir -p "$out/$(dirname "${k}")"
+ cp -a "${v}" "$out/${k}"
+ chmod -R u+rwX "$out/${k}"
+ else
+ install -D -m644 -T "${v}" "$out/${k}"
+ fi
'') assets_urls));
in
{
--- /dev/null
+diff --git a/src/index.html b/src/index.html
+index 2559a37..84a0d64 100644
+--- a/src/index.html
++++ b/src/index.html
+@@ -6,8 +6,8 @@
+ <meta name="description" content="Online cooperative codenames game. Play with two or more players.">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
+ <meta name="theme-color" content="#ffffff">
+- <link href="https://fonts.googleapis.com/css?family=Exo+2&display=swap" rel="stylesheet">
+- <link href="https://unpkg.com/ionicons@4.5.10-0/dist/css/ionicons.min.css" rel="stylesheet">
++ <link href="https://assets.immae.eu/fonts/Exo2_swap/font.css" rel="stylesheet">
++ <link href="https://assets.immae.eu/ionicons/4.5.10-0/dist/css/ionicons.min.css" rel="stylesheet">
+ <link rel="manifest" href="/codenames.manifest">
+ <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
+ <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
chmod -R u+w $out
cd $out
patch -p1 < ${./codenames.patch}
+ patch -p1 < ${./immae-assets.patch}
'';
dependencies = [
sources."@babel/code-frame-7.0.0"
--- /dev/null
+diff --git a/assets/index.html b/assets/index.html
+index 220192834..d77a0fc80 100644
+--- a/assets/index.html
++++ b/assets/index.html
+@@ -2,7 +2,7 @@
+ <html>
+ <head>
+ <link
+- href="https://fonts.googleapis.com/css?family=Ubuntu&display=swap"
++ href="https://assets.immae.eu/fonts/Ubuntu_swap/font.css"
+ rel="stylesheet"
+ />
+ <link rel="stylesheet" type="text/css" media="all" href="/styles.css" />
cp -r ${source} ./source
chmod -R u+w source
cd source
+ patch -p1 < ${./immae-assets.patch}
ln -s ${packages.package}/lib/node_modules/terraforming-mars/node_modules .
npm run build
mkdir $out
Theme name: Apaxy
Theme author: @adamwhitcroft
\*------------------------------------*/
-@import url('//fonts.googleapis.com/css?family=Open+Sans');
+@import url('//assets.immae.eu/fonts/OpenSans/font.css');
/* Have to use @import for the font, as you can only specify a single stylesheet */
* {
margin:0;