mat.services/flake.nix

50 lines
1.6 KiB
Nix
Raw Normal View History

2022-08-08 04:31:56 +00:00
{
description = "personal site";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
apollo.url = "github:not-matthias/apollo";
apollo.flake = false;
};
outputs = { self, flake-parts, ... }@inputs:
let
theme = inputs.apollo;
themeName = ((builtins.fromTOML (builtins.readFile "${theme}/theme.toml")).name);
in
flake-parts.lib.mkFlake { inherit self; } {
imports = [ ];
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = { config, self', inputs', pkgs, system, ... }: {
packages.default = pkgs.stdenv.mkDerivation {
pname = "personal-site";
2022-08-13 23:50:20 +00:00
version = "2022-08-13";
2022-08-08 04:31:56 +00:00
src = ./.;
2022-08-21 21:29:06 +00:00
nativeBuildInputs = with pkgs; [ pngquant scour zola ];
2022-08-08 04:31:56 +00:00
configurePhase = ''
mkdir -p "themes/${themeName}"
cp -r ${theme}/* "themes/${themeName}"
2022-08-21 21:29:06 +00:00
scour -i static/image/_favicon.svg -o static/image/favicon.svg
for image in content/**/_*.png static/image/**.png; do
path=$(dirname $image)
file=$(basename $image)
pngquant --quality 90-99 -f -o "$path/''${file:1}"
done
2022-08-08 04:31:56 +00:00
'';
buildPhase = "zola build";
installPhase = "cp -r public $out";
};
devShells.default = pkgs.mkShell {
2022-08-13 23:47:29 +00:00
packages = with pkgs; [ zola ];
2022-08-08 04:31:56 +00:00
shellHook = ''
mkdir -p themes
ln -sn "${theme}" "themes/${themeName}"
'';
};
};
};
}