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 ( flake-utils.lib.eachDefaultSystem (
system: let system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
node-modules = pkgs.mkYarnPackage { frontend = pkgs.stdenv.mkDerivation (finalAttrs: {
name = "node-modules"; pname = "kucinako";
version = "0.1";
src = ./.; src = ./.;
packageJSON = ./package.json; yarnOfflineCache = pkgs.fetchYarnDeps {
yarnLock = ./yarn.lock; yarnLock = finalAttrs.src + "/yarn.lock";
hash = "sha256-g5g2xlwDxH8O8zaLJ4meO1+DQdJIomVPqd6RXTAhDuE=";
}; };
frontend = pkgs.stdenv.mkDerivation { nativeBuildInputs = with pkgs; [
name = "frontend"; yarnConfigHook
src = ./.; yarnBuildHook
buildInputs = [ # Needed for executing package.json scripts
pkgs.yarn nodejs
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
# Build the project
${pkgs.yarn}/bin/yarn build
'';
installPhase = '' installPhase = ''
mkdir -p $out mkdir $out
cp -r dist/* $out/ mv 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 { in {
packages = { packages = {
node-modules = node-modules;
default = frontend; default = frontend;
}; };
apps.default = {
type = "app";
program = "${frontend}/bin/frontend";
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.nodejs
pkgs.yarn
pkgs.nodePackages.typescript
];
};
} }
); );
} }