Skip to content

Commit 8a9e844

Browse files
Added template files (#77)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent de0ecce commit 8a9e844

40 files changed

+23203
-2
lines changed

.copier-answers.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_commit: 63688a3
3+
_src_path: ./
4+
accountname: quickplates
5+
description: Generic project example 👤
6+
docs: true
7+
docsurl: https://quickplates.github.io/generic-example
8+
projectname: generic-example
9+
releases: true
10+
reponame: generic-example
11+
repourl: https://github.com/quickplates/generic-example

.devcontainer/devcontainer.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"build": {
3+
"context": "image/",
4+
"dockerfile": "image/Dockerfile",
5+
"options": ["--network=host"]
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"jnoortheen.nix-ide",
11+
"mkhl.direnv",
12+
"task.vscode-task",
13+
"Trunk.io"
14+
],
15+
"settings": {
16+
"[nix]": {
17+
"editor.defaultFormatter": "jnoortheen.nix-ide"
18+
},
19+
"editor.defaultFormatter": "trunk.io",
20+
"nix.enableLanguageServer": true,
21+
"nix.serverPath": "nil",
22+
"nix.serverSettings": {
23+
"nil": {
24+
"formatting": {
25+
"command": ["nix", "fmt", "--", "-"]
26+
}
27+
}
28+
},
29+
"remote.autoForwardPorts": false
30+
}
31+
}
32+
},
33+
"features": {
34+
"ghcr.io/devcontainers-extra/features/direnv:1.0.3": {
35+
"version": "2.37.1"
36+
},
37+
"ghcr.io/devcontainers-extra/features/starship:1.0.10": {
38+
"version": "1.24.0"
39+
},
40+
"ghcr.io/devcontainers/features/nix:1.2.0": {
41+
"extraNixConfig": "experimental-features = nix-command flakes",
42+
"version": "2.28.5"
43+
}
44+
},
45+
"mounts": [
46+
"source=devcontainer-shared-secrets,target=/secrets/,type=volume",
47+
"source=devcontainer-${devcontainerId}-nix,target=/nix/,type=volume",
48+
"source=devcontainer-${devcontainerId}-shellhistory-persist,target=/persist/shellhistory/,type=volume",
49+
"source=devcontainer-shared-trunk-cache,target=/cache/trunk/,type=volume",
50+
"source=devcontainer-shared-npm-cache,target=/cache/npm/,type=volume"
51+
],
52+
"onCreateCommand": "/hooks/create.sh",
53+
"remoteEnv": {
54+
"WORKSPACE": "${containerWorkspaceFolder}"
55+
},
56+
"runArgs": [
57+
"--uts=host",
58+
"--ipc=host",
59+
"--network=host",
60+
"--userns=host",
61+
"--cgroupns=host",
62+
"--privileged"
63+
]
64+
}

.devcontainer/image/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Using one of the offical dev container images as base
2+
# Going with Ubuntu, because it has glibc, which some tools might need
3+
# It also has git, zsh and a bunch of other stuff preinstalled
4+
# Also, it includes a non-root 'vscode' user with sudo access
5+
# The version is pinned to ensure reproducibility
6+
FROM mcr.microsoft.com/devcontainers/base:1.2.6-ubuntu-24.04
7+
8+
ENV REMOTE_USER=vscode
9+
10+
# Setup script
11+
COPY setup.sh /tmp/setup.sh
12+
13+
RUN /tmp/setup.sh && \
14+
rm /tmp/setup.sh
15+
16+
# Lifecycle hooks
17+
COPY hooks/ /hooks/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Create shell history cache files if they don't exist for some reason
4+
touch /persist/shellhistory/.bash_history
5+
touch /persist/shellhistory/.zsh_history
6+
7+
# Use GitHub token secret if it exists
8+
if [[ -s /secrets/.ghtoken && -r /secrets/.ghtoken ]]; then
9+
token="$(cat /secrets/.ghtoken)"
10+
confighome="${XDG_CONFIG_HOME:-${HOME}/.config/}"
11+
12+
# Add GitHub token to Nix config
13+
configfile="${confighome}/nix/nix.conf"
14+
tmpfile="$(mktemp)"
15+
16+
mkdir --parents "$(dirname "${configfile}")"
17+
touch "${configfile}"
18+
19+
if grep --quiet extra-access-tokens "${configfile}"; then
20+
sed "s|extra-access-tokens.*|extra-access-tokens = github.com=${token}|" "${configfile}" >"${tmpfile}"
21+
cat "${tmpfile}" >"${configfile}"
22+
rm "${tmpfile}"
23+
else
24+
echo "extra-access-tokens = github.com=${token}" >>"${configfile}"
25+
fi
26+
fi

.devcontainer/image/setup.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
REMOTE_USER="${REMOTE_USER:?}"
4+
REMOTE_USER_PASSWD="$(getent passwd "${REMOTE_USER}")"
5+
REMOTE_USER_HOME="$(echo "${REMOTE_USER_PASSWD}" | cut --delimiter ':' --fields 6)"
6+
7+
# Setup default shell
8+
chsh --shell /usr/bin/zsh "${REMOTE_USER}"
9+
10+
# Setup direnv
11+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
12+
eval "\$(direnv hook bash)"
13+
EOF
14+
15+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
16+
eval "\$(direnv hook zsh)"
17+
EOF
18+
19+
# Setup starship
20+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
21+
eval "\$(starship init bash)"
22+
EOF
23+
24+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
25+
eval "\$(starship init zsh)"
26+
EOF
27+
28+
# Setup secrets directory
29+
mkdir --parents /secrets/
30+
31+
chown --recursive "${REMOTE_USER}:" /secrets/
32+
33+
# Setup shell history cache
34+
mkdir --parents /persist/shellhistory/
35+
36+
touch /persist/shellhistory/.bash_history
37+
touch /persist/shellhistory/.zsh_history
38+
39+
chown --recursive "${REMOTE_USER}:" /persist/shellhistory/
40+
41+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
42+
export HISTFILE=/persist/shellhistory/.bash_history
43+
EOF
44+
45+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
46+
export HISTFILE=/persist/shellhistory/.zsh_history
47+
EOF
48+
49+
# Setup trunk cache
50+
mkdir --parents /cache/trunk/
51+
52+
chown --recursive "${REMOTE_USER}:" /cache/trunk/
53+
54+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
55+
export TRUNK_CACHE=/cache/trunk/
56+
EOF
57+
58+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
59+
export TRUNK_CACHE=/cache/trunk/
60+
EOF
61+
62+
# Setup npm cache
63+
mkdir --parents /cache/npm/
64+
65+
chown --recursive "${REMOTE_USER}:" /cache/npm/
66+
67+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
68+
export NPM_CONFIG_CACHE=/cache/npm/
69+
EOF
70+
71+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
72+
export NPM_CONFIG_CACHE=/cache/npm/
73+
EOF

.envrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# reload when these files change
4+
watch_file flake.lock ./*.nix
5+
6+
# activate the default development shell in the current shell
7+
# --accept-flake-config will accept the nix configuration from the flake without prompting
8+
eval "$(nix print-dev-env path:./ --accept-flake-config)" || true

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Mark everything as vendored
2+
* linguist-vendored
3+
# Treat docs as documentation
4+
/docs/** -linguist-vendored linguist-documentation
5+
# Unmark files in src, so that they are included in language stats
6+
/src/** -linguist-vendored

.github/release.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
changelog:
2+
exclude:
3+
# Exclude PRs with the following labels from the changelog
4+
labels:
5+
- skip-changelog
6+
# Categories are used make sections in the changelog based on PR labels
7+
categories:
8+
- title: 🚀 Features
9+
labels:
10+
- feature
11+
- title: 🐛 Bug Fixes
12+
labels:
13+
- bug
14+
- title: 🧽 Cleanup
15+
labels:
16+
- cleanup

.github/workflows/docs.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Docs
2+
3+
# Only one workflow can run at a time
4+
# If there is newer workflow in progress, cancel older ones
5+
concurrency:
6+
group: docs
7+
cancel-in-progress: true
8+
9+
# Put 'on' in quotes to avoid YAML parsing error
10+
"on":
11+
# Enable manual triggering
12+
workflow_dispatch: {}
13+
# Run on commits to main branch
14+
push:
15+
branches:
16+
- main
17+
# Run only on changes to relevant files
18+
paths:
19+
- .github/workflows/docs.yaml
20+
- docs/**
21+
- flake.lock
22+
- "*.nix"
23+
- Taskfile.dist.yaml
24+
25+
jobs:
26+
build:
27+
name: Build docs
28+
# Pin version of Ubuntu to avoid breaking changes
29+
runs-on: ubuntu-24.04
30+
# Use reasonable timeout to avoid stuck workflows
31+
timeout-minutes: 10
32+
env:
33+
NIX_CACHE_DIR: /home/runner/.nixcache/
34+
permissions:
35+
# Needed to checkout code
36+
contents: read
37+
# Needed to upload page artifact
38+
pages: write
39+
steps:
40+
- name: Checkout code
41+
uses: actions/[email protected]
42+
- name: Setup Nix cache
43+
uses: actions/[email protected]
44+
id: cache-nix
45+
with:
46+
path: ${{ env.NIX_CACHE_DIR }}
47+
key: docs-nix
48+
- name: Setup docs modules cache
49+
uses: actions/[email protected]
50+
with:
51+
path: docs/node_modules/
52+
key: docs-modules
53+
- name: Install Nix
54+
uses: cachix/[email protected]
55+
with:
56+
github_access_token: ${{ github.token }}
57+
install_url: https://releases.nixos.org/nix/nix-2.28.5/install
58+
# See: https://github.com/cachix/install-nix-action/issues/56
59+
- name: Import Nix store cache
60+
if: steps.cache-nix.outputs.cache-hit == 'true'
61+
run: >-
62+
nix-store
63+
--import
64+
< ${{ env.NIX_CACHE_DIR }}/archive.nar
65+
- name: Build docs
66+
run: >-
67+
nix
68+
develop
69+
./#docs
70+
--command
71+
--
72+
task
73+
docs
74+
--
75+
build
76+
--out-dir
77+
build/
78+
- name: Setup Pages
79+
uses: actions/[email protected]
80+
- name: Upload artifact
81+
uses: actions/[email protected]
82+
with:
83+
path: docs/build/
84+
# See: https://github.com/cachix/install-nix-action/issues/56
85+
- name: Export Nix store cache
86+
if: "!cancelled()"
87+
run: >-
88+
mkdir
89+
--parents
90+
${{ env.NIX_CACHE_DIR }}
91+
&&
92+
nix-store
93+
--export $(find /nix/store/ -maxdepth 1 -name '*-*')
94+
> ${{ env.NIX_CACHE_DIR }}/archive.nar
95+
deploy:
96+
name: Deploy docs
97+
# Run only if build job succeeded
98+
needs: build
99+
# Pin version of Ubuntu to avoid breaking changes
100+
runs-on: ubuntu-24.04
101+
# Use reasonable timeout to avoid stuck workflows
102+
timeout-minutes: 10
103+
# Use Pages environment
104+
environment:
105+
name: github-pages
106+
url: ${{ steps.deployment.outputs.page_url }}
107+
permissions:
108+
# Needed to to deploy to Pages
109+
pages: write
110+
# Also needed to deploy to Pages
111+
id-token: write
112+
steps:
113+
- name: Deploy to GitHub Pages
114+
id: deployment
115+
uses: actions/[email protected]

0 commit comments

Comments
 (0)