Initial commit: minimal JavaScript template with Nix

Features:
- Nix + Flakes for reproducible environments
- Bun (fast JavaScript runtime)
- Vite (development server & build tool)
- ESLint + Prettier (linting & formatting)
- Devshell commands via just
- Modular structure using flake-parts
- Omnix template support for initialization
This commit is contained in:
♥ Minnie ♥ 2025-10-27 20:02:55 +08:00
commit 6f67a0dc1a
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
16 changed files with 385 additions and 0 deletions

43
nix/modules/devshell.nix Normal file
View file

@ -0,0 +1,43 @@
{inputs, lib, ...}: let
# FHS compatibility for NixOS (steam-run wrapper)
# Enable if bun-installed binaries fail to find system libraries
fhs = false;
in {
perSystem = {system, ...}: let
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = fhs;
};
fhsPackages = lib.optionals fhs [
pkgs.steam-run
];
fhsSetup = lib.optionalString fhs ''
alias bun="steam-run bun"
'';
in {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
bun
eslint
just
prettierd
]
++ fhsPackages;
shellHook = ''
${fhsSetup}
if [ -f package.json ]; then
echo "Installing dependencies..."
bun install
fi
echo ""
echo "💡 Run 'just' to see available commands"
'';
};
};
}

19
nix/modules/template.nix Normal file
View file

@ -0,0 +1,19 @@
{inputs, ...}: {
flake = rec {
templates.default = {
description = "A minimal JavaScript project template with Bun and Nix";
path = inputs.self;
};
om.templates.javascript-template = {
template = templates.default;
params = [
{
name = "package-name";
description = "Name of the JavaScript package";
placeholder = "javascript-template";
}
];
};
};
}