Compare commits
3 Commits
a0f7ed045c
...
dc79b6f034
Author | SHA1 | Date | |
---|---|---|---|
|
dc79b6f034 | ||
|
6811f3b3b8 | ||
|
91746f1520 |
63
flake.nix
63
flake.nix
@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user