From 675752851d8bd165a83651d6af1440351d916a0e Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Thu, 11 Apr 2024 21:51:33 -0400 Subject: [PATCH] logo: Provide an easy path to optimized SVGs and exported PNGs The non-logo files are not part of the build, as they are files made for specific usage, and should not be part of the NixOS assets for general usage. --- default.nix | 1 + logo/README.md | 11 +++++++++++ logo/default.nix | 1 + logo/package.nix | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 logo/default.nix create mode 100644 logo/package.nix diff --git a/default.nix b/default.nix index a14cf97..bf27281 100644 --- a/default.nix +++ b/default.nix @@ -28,4 +28,5 @@ makeFlags = [ "prefix=$(out)" ]; } ) {}; + logo = pkgs.callPackage ./logo/package.nix {}; } diff --git a/logo/README.md b/logo/README.md index 8628712..6483789 100644 --- a/logo/README.md +++ b/logo/README.md @@ -56,6 +56,17 @@ white, keeping the spacing exact. This variant is monochrome, with the shadow gradients baked-in as opacity changes. +### Optimized version + +The SVG files in this directory are the authoring files. + +In other words, they are busy with inkscape-specific properties, used when +editing the files. + +If what is needed is a file optimized for size, and for using as an asset, +the Nix expression in this directory can be used to produce optimized SVGs. + + License ------- diff --git a/logo/default.nix b/logo/default.nix new file mode 100644 index 0000000..a7d6b49 --- /dev/null +++ b/logo/default.nix @@ -0,0 +1 @@ +(import ../. {}).logo diff --git a/logo/package.nix b/logo/package.nix new file mode 100644 index 0000000..1465f0b --- /dev/null +++ b/logo/package.nix @@ -0,0 +1,38 @@ +{ runCommand +, lib +, inkscape +, nodePackages +}: + +runCommand "nixos-artwork-logos" { + logos = [ + # The snowflake-only variants + "nix-snowflake-colours" + "nix-snowflake-white" + + # The horizontal variants + "nixos" + "nixos-white" + + # The vertical variant + "nixos-text-below" + ]; + src = lib.cleanSource ./.; + nativeBuildInputs = [ + inkscape + nodePackages.svgo + ]; +} '' + PS4=" $ " + for f in $logos; do + mkdir -p $out + printf ":: ⇒ %s\n" "$f" + (set -x + inkscape --export-background-opacity=0 --export-plain-svg --export-filename=$out/$f.svg "$src/$f.svg" + inkscape --export-background-opacity=0 --export-filename=$out/$f.png "$src/$f.svg" + ) + done + (set -x + svgo --pretty --multipass --folder "$out" + ) +''