Skip to content

Commit

Permalink
react js template
Browse files Browse the repository at this point in the history
  • Loading branch information
piq9117 committed Jan 23, 2024
1 parent 68e57bb commit 9a45c9e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ nix flake init -t "github:piq9117/nix-templates#ocaml"
nix flake init -t "github:piq9117/nix-templates#react-nextjs"
```

## React
## React TS
``` sh
nix flake init -t "github:piq9117/nix-templates#react"
nix flake init -t "github:piq9117/nix-templates#react-ts"
```

## React JS
``` sh
nix flake init -t "github:piq9117/nix-templates#react-js"
```
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
path = ./react-ts-template;
description = "React TS Template";
};

react-js = {
path = ./react-js-template;
description = "React JS Template";
};
};
};
}
25 changes: 25 additions & 0 deletions react-js-template/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions react-js-template/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "React JS Template";

inputs = {
nixpkgs.url = "nixpkgs";
};

outputs = {self, nixpkgs}:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);

nixpkgsFor = forAllSystems(system: import nixpkgs {
inherit system;
overlays = [self.overlay];
});

in {
overlay = final: prev: {
generate-vite-app = final.writeScriptBin "generate-vite-app" ''
${final.nodePackages_latest.pnpm}/bin/pnpm create vite . --template vanilla
'';
};
devShells = forAllSystems(system:
let pkgs = nixpkgsFor.${system};
in {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs_20
nodePackages_latest.npm
nodePackages_latest.pnpm
nodePackages.prettier
treefmt
generate-vite-app
];

shellHook = ''
export PS1='[$PWD]\n❄ '
#!/usr/bin/env bash
'';
};
});
};
}
4 changes: 4 additions & 0 deletions react-js-template/treefmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[formatter.typescript]
command = "prettier"
options = ["--write"]
includes = ["*.js", "*.ts", "*.tsx"]

0 comments on commit 9a45c9e

Please sign in to comment.