Initial commit.

jekyll
Joshua Potter 2023-12-13 15:32:55 -07:00
commit 0995870b95
12 changed files with 269 additions and 0 deletions

7
.envrc Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if command -v git > /dev/null && on_git_branch; then
git config --local core.hooksPath .githooks/
fi
use flake

21
.githooks/pre-commit Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
STAGED=$(
git --no-pager diff --name-only --no-color --cached --diff-filter=d |
# Remove quotations used to surrounding filenames with special characters.
sed -e "s/^\"//" -e "s/\"$//g"
)
TARGETS=()
while IFS= read -r FILENAME
do
if [[ "$FILENAME" =~ .*\.jsx?$ ]] || [[ "$FILENAME" == .*\.tsx?$ ]]; then
TARGETS+=("${FILENAME}")
fi
done <<< "$STAGED"
if (( ${#TARGETS[@]} )); then
prettier --write "${TARGETS[@]}"
git add "${TARGETS[@]}"
fi

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
# Directory used by `direnv` to hold `use flake`-generated profiles.
/.direnv/
# The directory containing all build outputs.
/dist/
# A symlink produced by default when running `nix build`.
/result
# The NodeJS dependency directory.
/node_modules/

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# NodeJS Flake Template
This is a template for constructing a working environment for
[Node.js](https://nodejs.org/en) development (version v18.18.2) with the [npm](https://www.npmjs.com/)
(version 9.8.1) packaging tool. [direnv](https://direnv.net/) can be used to
launch a dev shell upon entering this directory (refer to `.envrc`). Otherwise
run via:
```bash
$ nix develop
```
## Language Server
The [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
(version 4.1.2) is included in this flake.
## Formatting
Formatting depends on [prettier](https://prettier.io/) (version 3.1.0). A
`pre-commit` hook is included in `.githooks` that can be used to format all
`*.jsx?` and `*.tsx?` files prior to commit. Install via:
```bash
$ git config --local core.hooksPath .githooks/
```
If running [direnv](https://direnv.net/), this hook is installed automatically
when entering the directory.

76
flake.lock Normal file
View File

@ -0,0 +1,76 @@
{
"nodes": {
"flake-compat": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1701253981,
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"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
}

54
flake.nix Normal file
View File

@ -0,0 +1,54 @@
{
description = ''
An opinionated nodejs flake.
To generate a copy of this template elsewhere, install
[bootstrap](https://github.com/jrpotter/bootstrap) and run:
```bash
$ bootstrap nodejs
```
'';
inputs = {
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
lib = pkgs.buildNpmPackage {
pname = "portfolio";
version = "0.1.0";
src = ./.;
npmDepsHash = "sha256-eGfiDf/BKQcGhwGvmqpHTQNkAfiKSSPIfrmrPsGyOHw=";
# Needed to properly invoke npm run build.
nativeBuildInputs = [ pkgs.typescript ];
installPhase = ''
mkdir $out
cp src/index.html $out
cp dist/main.js $out
'';
};
default = self.packages.${system}.lib;
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
nodePackages.prettier
nodePackages.typescript-language-server
nodejs
prefetch-npm-deps
typescript
];
};
});
}

21
package-lock.json generated Normal file
View File

@ -0,0 +1,21 @@
{
"name": "portfolio",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portfolio",
"version": "0.1.0",
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}
}
}

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "portfolio",
"version": "0.1.0",
"description": "",
"main": "main.js",
"scripts": {
"build": "tsc",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
}
}

7
prettier.config.cjs Normal file
View File

@ -0,0 +1,7 @@
/** @type {import('prettier').Options} */
module.exports = {
arrowParens: "always",
semi: false,
tabWidth: 2,
trailingComma: "es5",
}

13
src/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="Joshua Potter portfolio" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script defer type="text/javascript" src="./main.js">
</script>
</head>
<body>
</body>
</html>

1
src/main.ts Normal file
View File

@ -0,0 +1 @@
console.log("Hello, world!");

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
// Visit https://aka.ms/tsconfig to read more about this file.
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
},
"include": ["src"],
"$schema": "https://json.schemastore.org/tsconfig"
}