Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fdca53
commit ead45c4
Showing
4 changed files
with
117 additions
and
65 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
description = "bytes.zone website"; | ||
|
||
inputs = { | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/release-21.05"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let pkgs = nixpkgs.legacyPackages.${system}; | ||
in rec { | ||
# `nix build` | ||
packages.bytes-zone = pkgs.stdenv.mkDerivation { | ||
name = "bytes.zone"; | ||
src = ./.; | ||
|
||
buildInputs = [ | ||
pkgs.zola | ||
pkgs.nodePackages.html-minifier | ||
pkgs.nodePackages.clean-css-cli | ||
pkgs.nodePackages.uglify-js | ||
pkgs.pngcrush | ||
]; | ||
buildPhase = '' | ||
zola build | ||
echo "compressing CSS" | ||
find public \ | ||
-type f -name '*.css' \ | ||
-exec cleancss -O 1 -o {}.min {} \; \ | ||
-exec mv {}.min {} \; | ||
echo "compressing JS" | ||
find public \ | ||
-type f -name '*.js' \ | ||
-exec uglifyjs -o {}.min {} \; \ | ||
-exec mv {}.min {} \; | ||
echo "compressing HTML" | ||
html-minifier \ | ||
--collapse-whitespace \ | ||
--decode-entities \ | ||
--remove-comments \ | ||
--remove-attribute-quotes \ | ||
--remove-redundant-attributes \ | ||
--remove-optional-tags \ | ||
--remove-script-type-attributes \ | ||
--remove-style-link-type-attributes \ | ||
--file-ext html \ | ||
--input-dir public \ | ||
--output-dir public | ||
echo "compressing images" | ||
find public -type f -name '*.png' | xargs -n 1 pngcrush -ow -brute | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out/share | ||
mv public $out/share/bytes.zone | ||
''; | ||
}; | ||
defaultPackage = packages.bytes-zone; | ||
overlay = final: prev: { bytes-zone = packages.bytes-zone; }; | ||
|
||
# `nix develop` | ||
devShell = pkgs.mkShell { buildInputs = with pkgs; [ zola pngcrush ]; }; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
{ ... }: | ||
let | ||
sources = import ./nix/sources.nix; | ||
nixpkgs = import sources.nixpkgs { }; | ||
niv = import sources.niv { }; | ||
pa11y = import ./nix/pkgs/pa11y { pkgs = nixpkgs; }; | ||
in with nixpkgs; | ||
stdenv.mkDerivation { | ||
name = "bytes.zone"; | ||
buildInputs = [ niv.niv git zola pa11y.pa11y pngcrush ]; | ||
} | ||
(import (fetchTarball { | ||
url = | ||
"https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz"; | ||
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; | ||
}) { src = ./.; }).shellNix |