1
Fork 0

nix build

main
Motiejus Jakštys 2023-04-03 22:03:11 +03:00
parent 0371aa5658
commit 7d22390609
3 changed files with 30 additions and 5 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/resources/_gen
/public
/result

View File

@ -13,6 +13,7 @@
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
...
@ -22,16 +23,42 @@
devDeps = with pkgs; [bash hugo zopfli brotli parallel];
in {
devShells.default = pkgs.mkShell {
name = "rules_nixpkgs_shell";
packages = devDeps;
};
# 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
cd public
find . \
-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 = ''
cd ..
mv public $out
'';
};
# TODO how to run scripts/build as a result of `nix run .`?
#packages = flake-utils.lib.mkApp {
# name = "build
#};
formatter = pkgs.alejandra;
});
}

View File

@ -3,9 +3,6 @@ set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)"
hugo --cleanDestinationDir --printPathWarnings --panicOnWarning --log
# https://github.com/gohugoio/hugo/issues/8734
#hugo --cleanDestinationDir --printPathWarnings --panicOnWarning --log \
# --buildDrafts --config config.yaml,debugconfig.yaml -d public/zz
cd public