blog/flake.nix

112 lines
2.9 KiB
Nix
Raw Normal View History

2024-05-22 22:17:41 -07:00
{
2024-10-31 17:51:52 -07:00
description = "gradient ascent";
2024-05-22 22:17:41 -07:00
nixConfig = {
allow-import-from-derivation = "true";
bash-prompt = "[hakyll-nix]λ ";
extra-substituters = [
"https://cache.iog.io"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
2024-10-31 17:51:52 -07:00
outputs =
{
self,
nixpkgs,
flake-utils,
haskellNix,
}:
flake-utils.lib.eachDefaultSystem (
system:
2024-05-22 22:17:41 -07:00
let
2024-05-23 23:14:18 -07:00
hls = pkgs.haskell-language-server;
2024-10-31 17:51:52 -07:00
overlays = [
haskellNix.overlay
2024-05-22 22:17:41 -07:00
(final: prev: {
hakyllProject = final.haskell-nix.project' {
src = ./ssg;
compiler-nix-name = "ghc948";
2024-10-31 17:51:52 -07:00
modules = [ { doHaddock = false; } ];
2024-05-22 22:17:41 -07:00
shell.buildInputs = [
hakyll-site
2024-05-23 23:14:18 -07:00
hls
pkgs.nodePackages.pnpm
pkgs.nodePackages.nodejs
2024-05-22 22:17:41 -07:00
];
shell.tools = {
cabal = "latest";
hlint = "latest";
haskell-language-server = "latest";
};
};
})
];
pkgs = import nixpkgs {
inherit overlays system;
inherit (haskellNix) config;
};
2024-10-31 17:51:52 -07:00
flake = pkgs.hakyllProject.flake { };
2024-05-22 22:17:41 -07:00
executable = "ssg:exe:hakyll-site";
hakyll-site = flake.packages.${executable};
website = pkgs.stdenv.mkDerivation {
name = "website";
buildInputs =
[
];
2024-05-22 22:17:41 -07:00
src = pkgs.nix-gitignore.gitignoreSourcePure [
./.gitignore
".git"
".github"
] ./.;
# LANG and LOCALE_ARCHIVE are fixes pulled from the community:
# https://github.com/jaspervdj/hakyll/issues/614#issuecomment-411520691
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
LANG = "en_US.UTF-8";
2024-10-31 17:51:52 -07:00
LOCALE_ARCHIVE = pkgs.lib.optionalString (
pkgs.buildPlatform.libc == "glibc"
) "${pkgs.glibcLocales}/lib/locale/locale-archive";
2024-05-22 22:17:41 -07:00
buildPhase = ''
${flake.packages.${executable}}/bin/hakyll-site build --verbose
'';
installPhase = ''
mkdir -p "$out/dist"
cp -a dist/. "$out/dist"
'';
};
2024-10-31 17:51:52 -07:00
in
flake
// {
2024-05-22 22:17:41 -07:00
apps = {
default = flake-utils.lib.mkApp {
drv = hakyll-site;
exePath = "/bin/hakyll-site";
};
};
packages = {
inherit hakyll-site website;
default = website;
};
2024-10-31 17:51:52 -07:00
formatter = pkgs.nixfmt-rfc-style;
2024-05-22 22:17:41 -07:00
}
);
}