Restructure templates to include Nix development environment

Moved template directories into templates/ subdirectory (templates/vanilla/
and templates/nextjs/) with complete Nix configuration in each. This ensures
initialized projects have the full development environment with Nix, Bun,
and all tooling out of the box.

Changes:
- Created templates/vanilla/ with flake.nix, nix/, .envrc, and all files
- Created templates/nextjs/ with flake.nix, nix/, .envrc, and all files
- Updated template paths in nix/modules/template.nix
This commit is contained in:
♥ Minnie ♥ 2025-11-14 11:56:46 +08:00
parent 304367cde5
commit 2b228ebd52
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
11 changed files with 367 additions and 3 deletions

View file

@ -9,13 +9,13 @@ in {
};
nextjs = {
description = "Next.js TypeScript template with App Router for Vercel";
description = "Next.js TypeScript template with App Router";
path = "${root}/templates/nextjs";
};
};
om.templates = {
javascript-vanilla = {
default = {
template = templates.default;
params = [
{
@ -26,7 +26,7 @@ in {
];
};
javascript-nextjs = {
nextjs = {
template = templates.nextjs;
params = [
{

1
templates/nextjs/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

77
templates/nextjs/flake.lock generated Normal file
View file

@ -0,0 +1,77 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1760948891,
"narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1751274312,
"narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1754788789,
"narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "a73b9c743612e4244d865a2fdee11865283c04e6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,18 @@
{
description = "Nix templates for JavaScript projects, powered by Bun";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = import inputs.systems;
imports = [
./nix/modules/devshell.nix
./nix/modules/template.nix
];
};
}

View file

@ -0,0 +1,45 @@
{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
nodejs
typescript
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"
'';
};
};
}

View file

@ -0,0 +1,41 @@
{inputs, ...}: let
root = inputs.self;
in {
flake = rec {
templates = {
default = {
description = "Minimal JavaScript template with Vite and Bun";
path = "${root}/vanilla";
};
nextjs = {
description = "Next.js TypeScript template with App Router";
path = "${root}/nextjs";
};
};
om.templates = {
default = {
template = templates.default;
params = [
{
name = "package-name";
description = "Name of the JavaScript package";
placeholder = "my-project";
}
];
};
nextjs = {
template = templates.nextjs;
params = [
{
name = "package-name";
description = "Name of the Next.js project";
placeholder = "my-nextjs-app";
}
];
};
};
};
}

1
templates/vanilla/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

77
templates/vanilla/flake.lock generated Normal file
View file

@ -0,0 +1,77 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1760948891,
"narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1751274312,
"narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1754788789,
"narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "a73b9c743612e4244d865a2fdee11865283c04e6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,18 @@
{
description = "Nix templates for JavaScript projects, powered by Bun";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = import inputs.systems;
imports = [
./nix/modules/devshell.nix
./nix/modules/template.nix
];
};
}

View file

@ -0,0 +1,45 @@
{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
nodejs
typescript
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"
'';
};
};
}

View file

@ -0,0 +1,41 @@
{inputs, ...}: let
root = inputs.self;
in {
flake = rec {
templates = {
default = {
description = "Minimal JavaScript template with Vite and Bun";
path = "${root}/vanilla";
};
nextjs = {
description = "Next.js TypeScript template with App Router";
path = "${root}/nextjs";
};
};
om.templates = {
default = {
template = templates.default;
params = [
{
name = "package-name";
description = "Name of the JavaScript package";
placeholder = "my-project";
}
];
};
nextjs = {
template = templates.nextjs;
params = [
{
name = "package-name";
description = "Name of the Next.js project";
placeholder = "my-nextjs-app";
}
];
};
};
};
}