Skip to content

Instantly share code, notes, and snippets.

@perguth
Last active January 6, 2025 09:15
Show Gist options
  • Save perguth/93dead8fbb5e93069fe9826fd17828ba to your computer and use it in GitHub Desktop.
Save perguth/93dead8fbb5e93069fe9826fd17828ba to your computer and use it in GitHub Desktop.
Deno (Fresh) IDX starter, `.idx/dev.nix`
# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-24.05"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.nano
];
# Sets environment variables in the workspace
env = {};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
"denoland.vscode-deno"
"bradlc.vscode-tailwindcss"
];
# Enable previews
previews = {
enable = true;
previews = {
web = {
# Example: run "npm run dev" with PORT set to IDX's defined port for previews,
# and show it in IDX's web preview panel
command = ["/home/user/.deno/bin/deno" "run" "start"];
manager = "web";
env = {
# Environment variables to set for your server
PORT = "$PORT";
};
};
};
};
# Workspace lifecycle hooks
workspace = {
# Runs when a workspace is first created
onCreate = {
deno-install = ''
mkdir -p $HOME/.deno/bin
curl -fsSL -o $HOME/.deno/deno.zip "https://github.com/denoland/deno/releases/download/v2.0.0/deno-x86_64-unknown-linux-gnu.zip"
unzip -o $HOME/.deno/deno.zip -d $HOME/.deno/bin
chmod +x $HOME/.deno/bin/deno
echo 'export PATH="$PATH:$HOME/.deno/bin"' >> ~/.bashrc
rm $HOME/.deno/deno.zip
source ~/.bashrc
'';
};
# Runs when the workspace is (re)started
onStart = {
};
};
};
}
@perguth
Copy link
Author

perguth commented Jan 6, 2025

  1. Update the file and rebuild the workspace.
  2. Then press CTRL + Shift+ P and select:

image

  1. Then open a new terminal and eg. run:
deno run -A -r https://fresh.deno.dev .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment