nix flake

This commit is contained in:
Greg Shuflin 2025-02-14 22:47:39 -08:00
parent efed813a3f
commit defb80189f
4 changed files with 1955 additions and 0 deletions

61
flake.lock generated Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1739446958,
"narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2ff53fe64443980e139eaa286017f53f88336dd0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

110
flake.nix Normal file
View File

@ -0,0 +1,110 @@
{
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;
buildPhase = ''
echo "Current directory structure:"
ls -la
echo "Node modules location:"
ls -la node_modules/.bin || true
export HOME=$(mktemp -d)
export NODE_ENV=production
# Move to the package directory where the source is
cd deps/Spazer
# Ensure Parcel cache directory exists and is writable
mkdir -p .parcel-cache
chmod -R 755 .parcel-cache
# Add node_modules/.bin to PATH so parcel can be found
export PATH="$PATH:$(pwd)/../../node_modules/.bin"
# Run the build with explicit entry point for all HTML files
yarn parcel build src/index.html src/**/index.html --no-cache --public-url ./
# Move back to the root directory
cd ../..
'';
installPhase = ''
echo "Current directory for install phase:"
pwd
echo "Directory contents:"
ls -la deps/Spazer
mkdir -p $out/dist
if [ -d deps/Spazer/dist ]; then
cp -r deps/Spazer/dist/* $out/dist
else
echo "Error: dist directory not found after build"
echo "Current directory: $(pwd)"
echo "Contents of deps/Spazer:"
ls -la deps/Spazer
exit 1
fi
'';
distPhase = "true";
buildInputs = with pkgs; [
nodejs
];
nativeBuildInputs = with pkgs; [
yarn
python3 # Sometimes needed by node-gyp
];
# Prevent yarn from trying to download during the build
yarnPreBuild = ''
mkdir -p $HOME/.cache/yarn
mkdir -p $HOME/.config/yarn
chmod -R 755 $HOME/.cache
chmod -R 755 $HOME/.config
'';
# Don't attempt to do any post-build optimizations
dontFixup = true;
};
# 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}/dist 8080
'';
};
});
}

View File

@ -1,5 +1,6 @@
{
"name": "Spazer",
"version": "1.0.0",
"source": "src/index.html",
"scripts": {
"start": "parcel",

1783
yarn.lock Normal file

File diff suppressed because it is too large Load Diff