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 (
|
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 {
|
};
|
||||||
name = "frontend";
|
nativeBuildInputs = with pkgs; [
|
||||||
src = ./.;
|
yarnConfigHook
|
||||||
buildInputs = [
|
yarnBuildHook
|
||||||
pkgs.yarn
|
# Needed for executing package.json scripts
|
||||||
node-modules
|
nodejs
|
||||||
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
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user