Skip to content

Commit

Permalink
move to a flake
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Sep 13, 2021
1 parent 6fdca53 commit ead45c4
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 65 deletions.
54 changes: 0 additions & 54 deletions default.nix

This file was deleted.

43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions flake.nix
@@ -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 ]; };
});
}
16 changes: 5 additions & 11 deletions shell.nix
@@ -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

0 comments on commit ead45c4

Please sign in to comment.