65 lines
1.6 KiB
Nix
65 lines
1.6 KiB
Nix
{
|
|
description = "Kucinako - Wordbook of Arzhanai languages";
|
|
|
|
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 = nixpkgs.legacyPackages.${system};
|
|
node-modules = pkgs.mkYarnPackage {
|
|
name = "node-modules";
|
|
src = ./.;
|
|
packageJSON = ./package.json;
|
|
yarnLock = ./yarn.lock;
|
|
};
|
|
frontend = pkgs.stdenv.mkDerivation {
|
|
name = "frontend";
|
|
src = ./.;
|
|
buildInputs = [pkgs.yarn node-modules pkgs.nodejs];
|
|
buildPhase = ''
|
|
ln -sf ${node-modules}/libexec/kucinako/node_modules node_modules
|
|
${pkgs.yarn}/bin/yarn 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
|
|
'';
|
|
};
|
|
in {
|
|
packages = {
|
|
node-modules = node-modules;
|
|
default = frontend;
|
|
};
|
|
|
|
apps.default = {
|
|
type = "app";
|
|
program = "${frontend}/bin/frontend";
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = [
|
|
pkgs.nodejs
|
|
pkgs.yarn
|
|
pkgs.nodePackages.typescript
|
|
];
|
|
};
|
|
}
|
|
);
|
|
}
|