build and upload in flake.nix

This commit is contained in:
Motiejus Jakštys 2024-10-09 21:51:36 -04:00
parent 14d3f73f27
commit ae8c3531e5
3 changed files with 16 additions and 14 deletions

View File

@ -17,22 +17,35 @@
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;}; pkgs = import nixpkgs {inherit system;};
devDeps = with pkgs; [hugo brotli zopfli parallel dart-sass]; devDeps = with pkgs; [hugo brotli zopfli parallel dart-sass];
in { in rec {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
packages = devDeps; packages = devDeps;
}; };
defaultPackage = pkgs.compressDrvWeb (pkgs.stdenv.mkDerivation { packages.default = pkgs.compressDrvWeb (pkgs.stdenv.mkDerivation {
pname = "jakstys.lt"; pname = "jakstys.lt";
version = "1.0.0"; version = "1.0.0";
src = pkgs.lib.cleanSource self; src = pkgs.lib.cleanSource self;
buildInputs = devDeps; buildInputs = devDeps;
buildPhase = "hugo --cleanDestinationDir --printPathWarnings --panicOnWarning"; buildPhase = "hugo --cleanDestinationDir --printPathWarnings --panicOnWarning";
installPhase = "mv public $out"; installPhase = "mv public $out";
}) {}; }) {};
apps.default = {
type = "app";
program = builtins.toString (pkgs.writeShellScript "upload" ''
${pkgs.rsync}/bin/rsync \
--info=progress2 \
--copy-links \
--archive \
--partial \
--delete \
${packages.default}/ \
jakstys.lt:/var/www/jakstys.lt/
'');
};
formatter = pkgs.alejandra; formatter = pkgs.alejandra;
}); });
} }

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)"
scripts/build
scripts/upload

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(git rev-parse --show-toplevel)"
rsync --info=progress2 -a --partial --delete public/ jakstys.lt:/var/www/jakstys.lt/