Compare commits

...

3 Commits

Author SHA1 Message Date
Greg Shuflin
dc79b6f034 Flake probably working now 2025-04-08 18:01:35 -07:00
Greg Shuflin
6811f3b3b8 Still trying to fix the flake 2025-04-08 00:27:32 -07:00
Greg Shuflin
91746f1520 Further flake fixes 2025-04-08 00:03:41 -07:00

View File

@ -14,62 +14,29 @@
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
node-modules = pkgs.mkYarnPackage {
name = "node-modules";
frontend = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "kucinako";
version = "0.1";
src = ./.;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
};
frontend = pkgs.stdenv.mkDerivation {
name = "frontend";
src = ./.;
buildInputs = [
pkgs.yarn
node-modules
pkgs.nodejs
pkgs.nodePackages.typescript
yarnOfflineCache = pkgs.fetchYarnDeps {
yarnLock = finalAttrs.src + "/yarn.lock";
hash = "sha256-g5g2xlwDxH8O8zaLJ4meO1+DQdJIomVPqd6RXTAhDuE=";
};
nativeBuildInputs = with pkgs; [
yarnConfigHook
yarnBuildHook
# Needed for executing package.json scripts
nodejs
];
buildPhase = ''
# Set HOME to a writable directory
export HOME=$TMPDIR
# Link the node_modules
ln -sf ${node-modules}/libexec/kucinako/node_modules node_modules
# Build the project
${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
mkdir $out
mv dist/* $out
'';
};
});
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
];
};
}
);
}