add basic deno flake

This commit is contained in:
EatThePooh 2025-08-02 00:07:09 +07:00
parent d35bd34a70
commit 701e5d138a
5 changed files with 162 additions and 0 deletions

56
flake.nix Normal file
View file

@ -0,0 +1,56 @@
{
description = "Deno development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
toDenoTarget = system:
let
arch = builtins.head (builtins.split "-" system);
os = builtins.elemAt (builtins.split "-" system) 1;
vendor = if os == "darwin" then "apple" else "unknown";
sys = if os == "darwin" then "darwin" else "linux-gnu";
in "${arch}-${vendor}-${sys}";
target = toDenoTarget system;
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
deno
];
shellHook = ''
echo "🦕 Deno development environment loaded!"
echo "Deno version: $(deno --version | head -n1)"
'';
DENO_DIR = "./.deno_cache";
};
# unfortunately this derivation is impure because
# managing deno's deps is HARD, so
# nix build --option sanbox relaxed
packages.default = import ./package.nix {
inherit pkgs;
inherit target;
name = "test-grimu-r-deno-app";
};
apps.default = {
type = "app";
program = toString (pkgs.writeShellScript "run-deno-app" ''
export DENO_DIR="./.deno_cache"
exec ${pkgs.deno}/bin/deno run main.ts "$@"
'');
};
});
}