feat(nix): add derivation

This commit is contained in:
uku 2024-10-30 13:16:52 +01:00
parent 14e38cb573
commit 15a46e05c0
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
3 changed files with 66 additions and 0 deletions

1
.gitignore vendored
View file

@ -25,3 +25,4 @@ vite.config.ts.timestamp-*
# Nix # Nix
/.direnv /.direnv
result*

View file

@ -17,6 +17,8 @@
pkgs, pkgs,
... ...
}: { }: {
packages.default = pkgs.callPackage ./nix/derivation.nix {};
devShells.default = with pkgs; devShells.default = with pkgs;
mkShellNoCC { mkShellNoCC {
buildInputs = [bun wrangler]; buildInputs = [bun wrangler];

63
nix/derivation.nix Normal file
View file

@ -0,0 +1,63 @@
{
lib,
stdenvNoCC,
bun,
nodejs,
}: stdenvNoCC.mkDerivation (finalAttrs: {
pname = "tcl-guessr";
version = "0.0.1";
src = ../.;
nativeBuildInputs = [bun nodejs];
bunDeps = stdenvNoCC.mkDerivation {
pname = "${finalAttrs.pname}-bun-deps";
inherit (finalAttrs) version;
nativeBuildInputs = [bun];
src = lib.fileset.toSource {
root = finalAttrs.src;
fileset = lib.fileset.unions [
../package.json
../bun.lockb
../patches
];
};
dontConfigure = true;
dontBuild = true;
installPhase = ''
bun install \
--frozen-lockfile \
--ignore-scripts \
--backend copyfile \
--force
cp -r node_modules/ $out
'';
outputHashMode = "recursive";
outputHash = "sha256-cYbyVt2Hc96WRAIsNkgnG0vUB47m1ixbhYhHmXetaII=";
};
configurePhase = ''
cp -r $bunDeps node_modules
chmod -R +w node_modules
patchShebangs node_modules/{*,.*}
'';
buildPhase = ''
bun run build
'';
installPhase = ''
cp -r .svelte-kit/cloudflare $out
'';
passthru = {
inherit (finalAttrs) bunDeps;
};
})