69 lines
1.7 KiB
Nix
69 lines
1.7 KiB
Nix
{
|
|
description = "Kristian's Website";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
nostyleplease = {
|
|
url = "github:Masellum/hugo-theme-nostyleplease";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
nostyleplease,
|
|
}: let
|
|
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
|
|
in {
|
|
formatter = forAllSystems (system: pkgs.${system}.alejandra);
|
|
|
|
packages = forAllSystems (system: {
|
|
default = pkgs.${system}.stdenv.mkDerivation {
|
|
name = "blog";
|
|
|
|
# Exclude themes and public folder from build sources
|
|
src = builtins.filterSource (path: type: !(type == "directory" && (baseNameOf path == "themes" || baseNameOf path == "public"))) ./.;
|
|
|
|
nativeBuildInputs = with pkgs.${system}; [
|
|
hugo
|
|
];
|
|
|
|
# Link theme to themes folder and build
|
|
buildPhase = ''
|
|
mkdir -p themes
|
|
ln -s ${nostyleplease} themes/nostyleplease
|
|
hugo --gc --minify
|
|
'';
|
|
|
|
installPhase = ''
|
|
cp -r public/. $out
|
|
'';
|
|
};
|
|
});
|
|
|
|
devShells = forAllSystems (system: {
|
|
default = pkgs.${system}.mkShellNoCC {
|
|
packages = with pkgs.${system}; [
|
|
hugo
|
|
];
|
|
|
|
# Link theme to themes folder
|
|
shellHook = ''
|
|
if [ ! -d ./themes ]; then
|
|
mkdir ./themes
|
|
fi
|
|
|
|
if [ ! -d ./themes/nostyleplease ]; then
|
|
ln -s ${nostyleplease} ./themes/nostyleplease
|
|
fi
|
|
|
|
hugo server --buildDrafts
|
|
'';
|
|
};
|
|
});
|
|
};
|
|
}
|