Still trying to fix the flake
This commit is contained in:
parent
91746f1520
commit
6811f3b3b8
63
flake.nix
63
flake.nix
@ -14,63 +14,36 @@
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
node-modules = pkgs.mkYarnPackage {
|
||||
name = "node-modules";
|
||||
in {
|
||||
packages.default = pkgs.mkYarnPackage {
|
||||
name = "kucinako";
|
||||
src = ./.;
|
||||
packageJSON = ./package.json;
|
||||
yarnLock = ./yarn.lock;
|
||||
};
|
||||
frontend = pkgs.stdenv.mkDerivation {
|
||||
name = "frontend";
|
||||
src = ./.;
|
||||
buildInputs = [
|
||||
pkgs.yarn
|
||||
node-modules
|
||||
pkgs.nodejs
|
||||
pkgs.nodePackages.typescript
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
# Set HOME to a writable directory
|
||||
export HOME=$TMPDIR
|
||||
|
||||
# Link the node_modules
|
||||
ln -sf ${node-modules}/libexec/kucinako/node_modules node_modules
|
||||
|
||||
# Add node_modules/.bin to PATH
|
||||
export PATH=$PWD/node_modules/.bin:$PATH
|
||||
|
||||
# Build the project
|
||||
yarn build
|
||||
export HOME=$(mktemp -d)
|
||||
yarn --offline build
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r dist/* $out/
|
||||
|
||||
# Create a bin directory with a wrapper script
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/frontend <<EOF
|
||||
#!/bin/sh
|
||||
${pkgs.python3}/bin/python -m http.server --directory $out 8000
|
||||
EOF
|
||||
chmod +x $out/bin/frontend
|
||||
cp -r deps/kucinako/dist/* $out/
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
node-modules = node-modules;
|
||||
default = frontend;
|
||||
};
|
||||
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${frontend}/bin/frontend";
|
||||
# Ensure Parcel and other build tools are available
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarn
|
||||
nodePackages.typescript
|
||||
];
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.nodejs
|
||||
pkgs.yarn
|
||||
pkgs.nodePackages.typescript
|
||||
buildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarn
|
||||
nodePackages.typescript
|
||||
];
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user