1
0
Fork 0
food-site/flake.nix

95 lines
2.2 KiB
Nix

{
description = "Our website for describing what foods we like and dislike.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
utils,
...
}:
{
overlays.food-site = final: prev: {
food-site = final.mkYarnPackage rec {
pname = "food";
version = "latest";
src = ./.;
yarnLock = ./yarn.lock;
yarnNix = ./yarn.nix;
packageJSON = ./package.json;
doDist = false;
# required for using system libsass, or else it tries to fetch new node headers
yarnPreBuild = ''
export npm_config_nodedir=${final.pkgs.nodejs}
'';
pkgConfig = {
node-sass = {
nativeBuildInputs = with final.pkgs; [pkg-config];
buildInputs = with final.pkgs; [libsass python3];
postInstall = ''
LIBSASS_EXT=auto yarn --offline run build
rm build/config.gypi
'';
};
};
buildPhase = ''
runHook preBuild
yarn run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/share/food-site"
${final.rsync}/bin/rsync --recursive deps/food/dist/ "$out/share/food-site"
runHook postInstall
'';
};
};
overlays.default = self.overlays.food-site;
}
// utils.lib.eachSystem (utils.lib.defaultSystems) (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlays.default];
};
in {
defaultPackage = self.packages."${system}".food-site;
packages.food-site = pkgs.food-site;
devShell = pkgs.mkShell {
LIBSASS_EXT = "auto";
npm_config_nodedir = "${pkgs.nodejs}";
nativeBuildInputs = with pkgs; [
nodejs
nodePackages.yarn
yarn2nix
# So we don't need to manually build libsass
pkg-config
libsass
python3
];
};
});
}