From b0724f79d26db51ddf3992b6f31712fa2c47c120 Mon Sep 17 00:00:00 2001 From: Alice Carroll Date: Sun, 1 Dec 2024 09:29:38 +0300 Subject: [PATCH] feat(nix): add fonts derivation --- flake.nix | 3 ++- nix/fonts.nix | 17 +++++++++++++++++ package.nix => nix/package.nix | 14 +++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 nix/fonts.nix rename package.nix => nix/package.nix (82%) diff --git a/flake.nix b/flake.nix index 8dd283b81..0d56d3df9 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,8 @@ craneLib = crane.mkLib pkgs; in { - packages.default = pkgs.callPackage ./package.nix { inherit craneLib; }; + packages.default = pkgs.callPackage ./nix/package.nix { inherit craneLib; }; + packages.fonts = pkgs.callPackage ./nix/fonts.nix {}; devShells.default = pkgs.mkShell { inputsFrom = builtins.attrValues self'.packages; packages = with pkgs; [ diff --git a/nix/fonts.nix b/nix/fonts.nix new file mode 100644 index 000000000..256397165 --- /dev/null +++ b/nix/fonts.nix @@ -0,0 +1,17 @@ +{ + lib, + runCommandLocal, +}: +runCommandLocal "uiua-fonts" + { + src = lib.fileset.toSource { + root = ../site; + fileset = lib.fileset.fileFilter ({ hasExt, ... }: hasExt "ttf") ../site; + }; + uiua386 = ../src/algorithm/Uiua386.ttf; + } + '' + mkdir -p "$out/share/fonts/truetype" + cp "$src"/* "$out/share/fonts/truetype/" + cp "$uiua386" "$out/share/fonts/truetype/Uiua386.ttf" + '' diff --git a/package.nix b/nix/package.nix similarity index 82% rename from package.nix rename to nix/package.nix index 3b2fa7675..cb084ca70 100644 --- a/package.nix +++ b/nix/package.nix @@ -13,17 +13,17 @@ let commonArgs = { src = lib.fileset.toSource { - root = ./.; + root = ../.; fileset = lib.fileset.unions ( [ - (lib.fileset.fromSource (craneLib.cleanCargoSource ./.)) - ./src/primitive/assets - ./src/algorithm/Uiua386.ttf + (lib.fileset.fromSource (craneLib.cleanCargoSource ../.)) + ../src/primitive/assets + ../src/algorithm/Uiua386.ttf ] ++ lib.optionals doCheck [ - ./site/favicon.ico - ./tests - ./tests_special + ../site/favicon.ico + ../tests + ../tests_special ] ); };