nix: Add flake outputs for checks, packages and apps

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2023-08-12 18:27:55 +02:00
parent 0d6c4d1ef4
commit 4816a44a58
Signed by: c8h4
GPG key ID: 9C82009BEEDEA0FF

View file

@ -10,8 +10,57 @@
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
let
pkgs = import nixpkgs { inherit system; };
src = ./.;
c8h4-io = pkgs.stdenv.mkDerivation {
name = "c8h4-io-hugo";
inherit src;
buildInputs = with pkgs; [ hugo ];
buildPhase = ''
hugo --minify
'';
installPhase = ''
mkdir -p $out
cp -vr public/* $out/
'';
};
in {
checks = rec {
inherit c8h4-io;
default = c8h4-io;
c8h4-io-prettier = pkgs.stdenv.mkDerivation {
name = "c8h4-io-prettier";
inherit src;
buildInputs = with pkgs; [ nodePackages.prettier ];
buildPhase = ''
prettier --check .
'';
installPhase = ''
mkdir -p $out
'';
};
};
packages = rec {
inherit c8h4-io;
default = c8h4-io;
};
apps.devserver = let
drv = pkgs.writeShellScript "c8h4-io-hugo-devserver" ''
${pkgs.hugo}/bin/hugo server
'';
in {
type = "app";
program = "${drv}";
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
deadnix