nix: initial tooling; add NixOS module
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I5ff8dfa450ec405e2ead5d16e0de90856a6a6964
This commit is contained in:
parent
978cddb862
commit
05b3dea1c6
4 changed files with 217 additions and 0 deletions
71
nix/package.nix
Normal file
71
nix/package.nix
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
nodejs,
|
||||
pnpmConfigHook,
|
||||
fetchPnpmDeps,
|
||||
pnpm,
|
||||
makeBinaryWrapper,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "troutbot";
|
||||
version = "0-unstable-2026-01-30";
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.unions [
|
||||
../src
|
||||
../config.example.ts
|
||||
../package.json
|
||||
../pnpm-lock.yaml
|
||||
../tsconfig.json
|
||||
];
|
||||
};
|
||||
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = [
|
||||
nodejs # in case scripts are run outside of a pnpm call
|
||||
pnpmConfigHook
|
||||
pnpm # at least required by pnpmConfigHook, if not other (custom) phases
|
||||
|
||||
makeBinaryWrapper
|
||||
];
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
inherit (finalAttrs) pname version src;
|
||||
fetcherVersion = 3;
|
||||
hash = "sha256-y8LV1D+EgGcZ79lmxS20dqYBPEfk4atma+RWf7pJI30=";
|
||||
};
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
pnpm run build --outDir dist
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{bin,share}
|
||||
|
||||
# Copy transpiled result
|
||||
cp -rv dist/* $out/share
|
||||
|
||||
# Copy the example config
|
||||
install -Dm755 config.example.ts $out/share
|
||||
|
||||
makeWrapper ${lib.getExe nodejs} $out/bin/troutbot \
|
||||
--set-default NODE_ENV production \
|
||||
--add-flags "$out/share/index.js"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "The ultimate trout population helper";
|
||||
license = lib.licenses.eupl12;
|
||||
maintainers = with lib.maintainers; [NotAShelf];
|
||||
};
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue