-
Notifications
You must be signed in to change notification settings - Fork 7
Pin the toolchain with Nix and automate dependency bumps #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Automatically load the Nix development shell when entering this directory | ||
| # Requires direnv: https://direnv.net/ | ||
| # | ||
| # To enable: | ||
| # 1. Install direnv | ||
| # 2. Run: direnv allow | ||
| # | ||
| # This will automatically install all required dependencies for the project. | ||
| if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then | ||
| source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM=" | ||
| fi | ||
| use_flake | ||
|
|
||
| # Reclaim stale Nix store paths in the background, at most once per week. | ||
| # nix-direnv pins the current dev shell, so only older versions are freed. | ||
| if has nix-collect-garbage; then | ||
| _gc_stamp="$PWD/.direnv/nix-gc-stamp" | ||
| if [ ! -f "$_gc_stamp" ] || [ -n "$(find "$_gc_stamp" -mtime +7 2>/dev/null)" ]; then | ||
| touch "$_gc_stamp" | ||
| (nix-collect-garbage --delete-older-than 7d >/dev/null 2>&1 &) | ||
| fi | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # To get started with Dependabot version updates, you'll need to specify which | ||
| # package ecosystems to update and where the package manifests are located. | ||
| # Please see the documentation for all configuration options: | ||
| # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
| # | ||
| # cooldown.default-days holds back any newly published version until it is at | ||
| # least N days old. This buys time for a compromised release (supply-chain | ||
| # attack) to be noticed and yanked before we pull it in. Security updates | ||
| # bypass the cooldown. It only gates Dependabot-driven updates, not a manual | ||
| # `bun update`. | ||
| # | ||
| # Nix has no Dependabot ecosystem, so flake.lock is bumped by the monthly | ||
| # update-flake.yml workflow instead. | ||
|
|
||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
| groups: | ||
| github-actions: | ||
| patterns: | ||
| - "*" | ||
|
|
||
| - package-ecosystem: "bun" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
| groups: | ||
| bun: | ||
| patterns: | ||
| - "*" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Update Flake | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| workflow_dispatch: # Allow manual triggering | ||
| schedule: | ||
| - cron: '0 12 1 * *' # Run monthly on the 1st at noon UTC | ||
|
|
||
| jobs: | ||
| update-flake: | ||
| name: Update flake.lock | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - name: Install Nix | ||
| uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main | ||
| with: | ||
| determinate: false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 741 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/update-flake.yml
printf '%s\n' '--- related workflows ---'
rg -n -C 4 'update-flake|pull_request|workflow_dispatch|contents:|pull-requests:|nix-installer|determinate' .github/workflows
printf '%s\n' '--- repository files related to the action ---'
rg -n -C 3 'nix-installer-action|determinate-nix-action|update-flake-lock' .github README.md 2>/dev/null || trueRepository: moq-dev/moq.dev Length of output: 4464 🌐 Web query:
💡 Result: The option to set Citations:
Replace the retired upstream-Nix mode.
🤖 Prompt for AI Agents |
||
|
|
||
| - name: Update flake.lock | ||
| uses: DeterminateSystems/update-flake-lock@f21d5f4a9e57815a4941a2e7c3860f4664cb3a96 # main | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 748 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/update-flake.yml
printf '%s\n' '--- related workflow files ---'
git ls-files '.github/workflows'
printf '%s\n' '--- pull request workflow references ---'
rg -n -C 4 'pull_request|workflow_dispatch|repository_dispatch|update-flake|GITHUB_TOKEN|permissions:|nix-installer' .github/workflows .github 2>/dev/null
printf '%s\n' '--- action metadata references ---'
rg -n -C 3 'DeterminateSystems/update-flake-lock|nix-installer-action|determinate:|token:|pull-request|workflow' .github README.md 2>/dev/nullRepository: moq-dev/moq.dev Length of output: 8213 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- workflow file list ---'
git ls-files '.github/workflows/*'
printf '%s\n' '--- update workflow ---'
cat -n .github/workflows/update-flake.yml
printf '%s\n' '--- PR workflow ---'
if [ -f .github/workflows/pr.yml ]; then cat -n .github/workflows/pr.yml; fi
printf '%s\n' '--- action references and workflow triggers ---'
rg -n -C 5 'DeterminateSystems/update-flake-lock|nix-installer-action|determinate:|pull_request|pull_request_target|workflow_dispatch|repository_dispatch|GITHUB_TOKEN|permissions:' .github/workflows .github 2>/dev/nullRepository: moq-dev/moq.dev Length of output: 6818 🏁 Script executed: #!/bin/bash
set -e
cat -n .github/workflows/update-flake.yml
printf '\n--- workflows ---\n'
git ls-files '.github/workflows'
printf '\n--- relevant references ---\n'
rg -n -C 4 'update-flake-lock|nix-installer-action|determinate:|pull_request|pull_request_target|workflow_dispatch|repository_dispatch|GITHUB_TOKEN|permissions:' .github/workflows .github 2>/dev/null || trueRepository: moq-dev/moq.dev Length of output: 5284 🌐 Web query:
💡 Result: The issue where pull requests (PRs) created by the Determinate Systems Citations:
🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- update-flake workflow ---'
sed -n '1,180p' .github/workflows/update-flake.yml
printf '%s\n' '--- workflow files ---'
git ls-files .github/workflows
printf '%s\n' '--- references ---'
rg -n -C 3 'update-flake-lock|pull_request|workflow_dispatch|repository_dispatch|permissions:|GITHUB_TOKEN|nix-installer-action|determinate:' .github/workflows .github 2>/dev/null || trueRepository: moq-dev/moq.dev Length of output: 4676 🏁 Script executed: #!/bin/bash
set -e
sha='f21d5f4a9e57815a4941a2e7c3860f4664cb3a96'
base="https://raw.githubusercontent.com/DeterminateSystems/update-flake-lock/$sha"
printf '%s\n' '--- action metadata at pinned SHA ---'
curl -fsSL "$base/action.yml" | sed -n '1,220p'
printf '%s\n' '--- README references ---'
curl -fsSL "$base/README.md" | rg -n -C 5 'GITHUB_TOKEN|token:|not trigger|trigger|pull request|workflow'Repository: moq-dev/moq.dev Length of output: 15004 Ensure generated flake update PRs run CI.
🤖 Prompt for AI Agents |
||
| with: | ||
| pr-title: "Update flake.lock" | ||
| pr-labels: | | ||
| dependencies | ||
| automated | ||
|
Comment on lines
+27
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Keep the Bun versions synchronized. The monthly or manual updater can change 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,11 @@ dist/ | |
| .astro/ | ||
| tsconfig.tsbuildinfo | ||
|
|
||
| # Nix / direnv | ||
| .direnv/ | ||
| result | ||
| result-* | ||
|
|
||
| # Mac shit | ||
| .DS_Store | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,17 @@ Join the [Discord](https://discord.moq.dev) for updates and discussion. | |||||||||
|
|
||||||||||
| ## Setup | ||||||||||
|
|
||||||||||
| Install the dependencies with `bun`: | ||||||||||
| The toolchain (`bun`, `node`, `just`) is pinned in `flake.nix`: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| nix develop -c just dev | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| With [direnv](https://direnv.net/) installed, `direnv allow` loads that shell | ||||||||||
| automatically on every `cd` into the repo. | ||||||||||
|
|
||||||||||
| Don't have Nix? Install `bun` and `just` yourself, matching the `bun` version in | ||||||||||
| `packageManager`. Either way, the dependencies come from `bun`: | ||||||||||
|
Comment on lines
+36
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Document Node.js in the non-Nix setup. The Proposed documentation fix-Don't have Nix? Install `bun` and `just` yourself, matching the `bun` version in
-`packageManager`. Either way, the dependencies come from `bun`:
+Don't have Nix? Install `bun`, Node.js 24, and `just` yourself. Match the `bun`
+version in `packageManager`. Either way, the dependencies come from `bun`:📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| bun i | ||||||||||
|
|
||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| { | ||
| description = "moq.dev - the blog, moq.pub, and moq.watch"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
| }; | ||
|
|
||
| outputs = | ||
| { | ||
| nixpkgs, | ||
| flake-utils, | ||
| ... | ||
| }: | ||
| flake-utils.lib.eachSystem | ||
| [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| "aarch64-darwin" | ||
| ] | ||
|
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On an Intel Mac, both the newly documented Useful? React with 👍 / 👎. |
||
| ( | ||
| system: | ||
| let | ||
| pkgs = import nixpkgs { inherit system; }; | ||
| in | ||
| { | ||
| devShells.default = pkgs.mkShell { | ||
| packages = with pkgs; [ | ||
| # Everything in the justfile runs through bun: astro, vite, biome, | ||
| # tsc, and wrangler are all `bun run` or `bunx`. | ||
| # | ||
| # This is the version `packageManager` and pr.yml pin to. A bare | ||
| # `bun i` on a newer bun rewrites bun.lock, which is noise in a | ||
| # diff, so the three pins are kept in step. `nix flake update` | ||
| # moving bun is the signal to move the other two. | ||
| bun | ||
|
|
||
| # Astro and Vite target node, and parts of their toolchains shell | ||
| # out to it rather than to bun. | ||
| nodejs_24 | ||
|
|
||
| # The task runner every recipe in the justfile is written for. | ||
| just | ||
| ]; | ||
| }; | ||
|
|
||
| formatter = pkgs.nixfmt-tree; | ||
| } | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,5 +38,5 @@ | |
| "vite-plugin-static-copy": "^2.3.2", | ||
| "wrangler": "^4.100.0" | ||
| }, | ||
| "packageManager": "bun@1.3.4" | ||
| "packageManager": "bun@1.3.13" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this repository is built through its existing Useful? React with 👍 / 👎. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: moq-dev/moq.dev
Length of output: 2488
🌐 Web query:
site:github.com/DeterminateSystems/nix-installer-action github-token default github.token update-flake-lock permissions💡 Result:
When using the Determinate Nix Installer Action, the
github-tokeninput defaults to${{ github.token }}[1][2]. This token is used to make authenticated requests to GitHub, which provides a higher rate-limit quota than unauthenticated requests [1][2]. If you provide agithub-token, the action automatically includesaccess-tokenswith the provided token in the/etc/nix/nix.confconfiguration file to facilitate authenticated access [1][2]. Regarding permissions: If you need to fetch private flakes or use specific FlakeHub features, the recommended approach is to use thedeterminate-nix-actioninstead ofnix-installer-action[3][4]. When doing so, you must explicitly configure thepermissionsblock in your workflow job [3][4]. For operations requiring identity tokens, ensure your job permissions includeid-token: write[5]. Be aware of security considerations regarding token persistence: in non-ephemeral runner environments (such as self-hosted runners), a token written to/etc/nix/nix.confby an initial run may persist and be used by subsequent workflow runs [6]. To ensure security and avoid stale credentials, ephemeral runner environments are recommended [6].Citations:
Security Misconfiguration (CWE-250)
Reachability: Internal · Exploitability: Difficult
Limit write permissions to the updater.
contents: writeandpull-requests: writeapply to the job that runs both actions.nix-installer-actiondefaults itsgithub-tokeninput togithub.token. A compromised installer action could therefore modify repository contents or open pull requests. Run the installer with read-only permissions, then give write access only toupdate-flake-lock, or pass that action a narrowly scoped App or PAT token from a separate job.🤖 Prompt for AI Agents