Spazer/flake.nix

68 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2025-02-14 22:47:39 -08:00
{
description = "Spazer - Web Graphics Project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
permittedInsecurePackages = [
"nodejs-16.20.2"
];
};
};
in
{
packages.default = pkgs.mkYarnPackage {
name = "spazer";
src = ./.;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
2025-02-15 02:35:21 -08:00
doDist = false;
2025-02-14 22:47:39 -08:00
buildPhase = ''
2025-02-15 02:35:21 -08:00
# Parcel needs a HOME directory
2025-02-14 22:47:39 -08:00
export HOME=$(mktemp -d)
2025-02-15 02:35:21 -08:00
yarn parcel build
2025-02-14 22:47:39 -08:00
'';
installPhase = ''
2025-02-15 02:35:21 -08:00
# Create output directory and copy files
mkdir -p $out
cp -r deps/Spazer/dist/. $out/
2025-02-14 22:47:39 -08:00
'';
buildInputs = with pkgs; [
nodejs
];
nativeBuildInputs = with pkgs; [
yarn
python3 # Sometimes needed by node-gyp
];
};
# Development shell with required dependencies
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs
yarn
python3
];
};
# Add a simple app that can serve the built files
apps.default = flake-utils.lib.mkApp {
drv = pkgs.writeShellScriptBin "serve-spazer" ''
2025-02-15 02:35:21 -08:00
${pkgs.python3}/bin/python3 -m http.server --directory ${self.packages.${system}.default} 8080
2025-02-14 22:47:39 -08:00
'';
};
});
}