diff --git a/nix/modules/template.nix b/nix/modules/template.nix index ea22107..c7373dd 100644 --- a/nix/modules/template.nix +++ b/nix/modules/template.nix @@ -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 = [ { diff --git a/templates/nextjs/.envrc b/templates/nextjs/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/nextjs/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/nextjs/flake.lock b/templates/nextjs/flake.lock new file mode 100644 index 0000000..395470a --- /dev/null +++ b/templates/nextjs/flake.lock @@ -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 +} diff --git a/templates/nextjs/flake.nix b/templates/nextjs/flake.nix new file mode 100644 index 0000000..3dde900 --- /dev/null +++ b/templates/nextjs/flake.nix @@ -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 + ]; + }; +} diff --git a/templates/nextjs/nix/modules/devshell.nix b/templates/nextjs/nix/modules/devshell.nix new file mode 100644 index 0000000..ca858e0 --- /dev/null +++ b/templates/nextjs/nix/modules/devshell.nix @@ -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" + ''; + }; + }; +} diff --git a/templates/nextjs/nix/modules/template.nix b/templates/nextjs/nix/modules/template.nix new file mode 100644 index 0000000..a167e16 --- /dev/null +++ b/templates/nextjs/nix/modules/template.nix @@ -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"; + } + ]; + }; + }; + }; +} diff --git a/templates/vanilla/.envrc b/templates/vanilla/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/vanilla/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/vanilla/flake.lock b/templates/vanilla/flake.lock new file mode 100644 index 0000000..395470a --- /dev/null +++ b/templates/vanilla/flake.lock @@ -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 +} diff --git a/templates/vanilla/flake.nix b/templates/vanilla/flake.nix new file mode 100644 index 0000000..3dde900 --- /dev/null +++ b/templates/vanilla/flake.nix @@ -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 + ]; + }; +} diff --git a/templates/vanilla/nix/modules/devshell.nix b/templates/vanilla/nix/modules/devshell.nix new file mode 100644 index 0000000..ca858e0 --- /dev/null +++ b/templates/vanilla/nix/modules/devshell.nix @@ -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" + ''; + }; + }; +} diff --git a/templates/vanilla/nix/modules/template.nix b/templates/vanilla/nix/modules/template.nix new file mode 100644 index 0000000..a167e16 --- /dev/null +++ b/templates/vanilla/nix/modules/template.nix @@ -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"; + } + ]; + }; + }; + }; +}