1
0
Fork 0
food-site/flake.nix

84 lines
1.9 KiB
Nix
Raw Normal View History

2023-09-30 14:37:01 +01:00
{
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;
2024-08-22 15:28:49 +01:00
nativeBuildInputs = with final; [ nodePackages.node-gyp ];
2023-09-30 14:37:01 +01:00
yarnPreBuild = ''
export npm_config_nodedir=${final.pkgs.nodejs}
'';
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 {
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
];
};
});
}