{ 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; doDist = false; buildPhase = '' # Parcel needs a HOME directory export HOME=$(mktemp -d) yarn parcel build ''; installPhase = '' # Create output directory and copy files mkdir -p $out cp -r deps/Spazer/dist/. $out/ ''; 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" '' ${pkgs.python3}/bin/python3 -m http.server --directory ${self.packages.${system}.default} 8080 ''; }; }); }