blog/flake.nix

95 lines
2.4 KiB
Nix
Raw Normal View History

2024-05-22 22:17:41 -07:00
{
2025-02-15 13:17:19 -08:00
description = "the involution";
2024-05-22 22:17:41 -07:00
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2024-05-22 22:17:41 -07:00
inputs.flake-utils.url = "github:numtide/flake-utils";
2024-10-31 17:51:52 -07:00
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
2024-05-22 22:17:41 -07:00
let
pkgs = import nixpkgs { inherit system; };
2024-05-22 22:17:41 -07:00
2024-10-31 22:41:33 -07:00
nodejs = pkgs.nodejs;
hakyll-site = pkgs.haskellPackages.callCabal2nix "hakyll-site" ./ssg { };
2024-05-22 22:17:41 -07:00
nodeDeps = pkgs.importNpmLock.buildNodeModules {
inherit nodejs;
npmRoot = ./.;
};
2024-05-22 22:17:41 -07:00
website = pkgs.stdenv.mkDerivation {
pname = "website";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ pkgs.nodePackages.npm ];
2024-05-22 22:17:41 -07:00
# 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 = ''
ln -s ${nodeDeps}/node_modules node_modules
${self.packages.${system}.hakyll-site}/bin/hakyll-site build
2024-10-31 22:41:33 -07:00
npm run build
2024-05-22 22:17:41 -07:00
'';
installPhase = ''
mkdir -p "$out/dist"
cp -a dist/. "$out/dist"
'';
};
2024-10-31 17:51:52 -07:00
in
{
2024-05-22 22:17:41 -07:00
apps = {
default = flake-utils.lib.mkApp {
drv = hakyll-site;
exePath = "/bin/hakyll-site";
};
};
packages = {
2024-10-31 22:41:33 -07:00
inherit hakyll-site website nodeDeps;
2024-05-22 22:17:41 -07:00
default = website;
};
2024-10-31 17:51:52 -07:00
devShells.default = pkgs.haskellPackages.shellFor {
packages = hsPkgs: [
hsPkgs.distribution-nixpkgs
self.packages.${system}.hakyll-site
];
npmDeps = nodeDeps;
withHoogle = true;
nativeBuildInputs = with pkgs; [
cabal-install
haskellPackages.cabal-gild
haskellPackages.haskell-language-server
pkgs.importNpmLock.hooks.linkNodeModulesHook
nodejs
pkgs.nodePackages.npm
];
};
2024-10-31 17:51:52 -07:00
formatter = pkgs.nixfmt-rfc-style;
2024-05-22 22:17:41 -07:00
}
);
}