jakstys.lt/flake.nix

59 lines
1.6 KiB
Nix
Raw Normal View History

2023-03-25 12:43:23 +02:00
{
2023-04-03 21:41:49 +03:00
nixConfig = {
trusted-substituters = "https://cache.nixos.org/";
trusted-public-keys = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=";
extra-experimental-features = "nix-command flakes";
};
2023-03-25 12:43:23 +02:00
inputs = {
2023-03-25 12:48:37 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11-small";
2023-03-25 12:43:23 +02:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
2023-04-03 21:41:49 +03:00
outputs = {
2023-04-03 22:03:11 +03:00
self,
2023-04-03 21:41:49 +03:00
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
2023-04-13 11:45:39 +03:00
devDeps = with pkgs; [hugo brotli zopfli parallel];
2023-04-03 21:41:49 +03:00
in {
devShells.default = pkgs.mkShell {
2023-07-25 09:38:54 +03:00
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
2023-04-03 21:41:49 +03:00
packages = devDeps;
};
2023-04-03 22:03:11 +03:00
# TODO: cache
defaultPackage = pkgs.stdenv.mkDerivation {
pname = "jakstys.lt";
version = "1.0.0";
src = pkgs.lib.cleanSource self;
buildInputs = [pkgs.hugo];
buildPhase = ''
${pkgs.hugo}/bin/hugo --cleanDestinationDir --printPathWarnings --panicOnWarning --log
2023-04-04 10:12:28 +03:00
find public \
2023-04-03 22:03:11 +03:00
-name '*.html' -or \
-name '*.xml' -or \
-name '*.txt' -or \
-name '*.css' -or \
-name '*.map' | \
${pkgs.parallel}/bin/parallel --eta \
"${pkgs.zopfli}/bin/zopfli {} && ${pkgs.brotli}/bin/brotli {}"
'';
installPhase = ''
2023-04-04 10:12:28 +03:00
mv public $out
2023-04-03 22:03:11 +03:00
'';
};
2023-04-03 21:41:49 +03:00
formatter = pkgs.alejandra;
});
2023-03-25 12:43:23 +02:00
}