gues-kucinako/flake.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

2023-08-29 22:49:16 -07:00
{
description = "Kucinako Wordbook of Arzhanai languages";
2023-08-29 22:49:16 -07:00
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
2025-04-07 19:34:09 -07:00
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
2023-08-29 22:49:16 -07:00
pkgs = nixpkgs.legacyPackages.${system};
node-modules = pkgs.mkYarnPackage {
name = "node-modules";
src = ./.;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
2023-08-29 22:49:16 -07:00
};
frontend = pkgs.stdenv.mkDerivation {
name = "frontend";
src = ./.;
buildInputs = [pkgs.yarn node-modules pkgs.nodejs];
2023-08-29 22:49:16 -07:00
buildPhase = ''
ln -sf ${node-modules}/libexec/kucinako/node_modules node_modules
2023-08-29 22:49:16 -07:00
${pkgs.yarn}/bin/yarn build
'';
installPhase = ''
mkdir -p $out
cp -r dist/* $out/
2025-04-07 19:34:09 -07:00
# 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
2023-08-29 22:49:16 -07:00
'';
};
2025-04-07 19:34:09 -07:00
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
];
};
}
2023-08-29 22:49:16 -07:00
);
}