feat: add Nix flake and handle Nix-store installs in upgrade (#764)

* feat: add Nix flake and stop self-upgrade of Nix-store installs

Add flake.nix with packages, overlays.default, checks and a formatter,
building nix/package.nix with the unit tests in the Nix sandbox. The
version comes from the Release Please manifest, so releases need no Nix
edit. A Nix workflow runs `nix flake check` on non-docs changes.

`skillshare upgrade` now detects binaries under /nix/store/ and prints
`nix profile upgrade skillshare` instead of replacing a read-only store
path; update notices and doctor suggest the same command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(upgrade): give Nix installs the right update path everywhere

The first flake commit sent every /nix/store binary to `nix profile
upgrade`, failed a plain `skillshare upgrade` with exit 1 even when the
CLI was current, and left the dashboard with a generic 500.

- Tell `nix profile` installs (the profile manifest lists the store path)
  from NixOS, Home Manager and overlay installs, which are told to update
  their configuration and rebuild. Detection lives in one helper shared by
  the update notice, doctor, upgrade and the dashboard.
- `upgrade` on Nix reports "already up to date" or prints the hint and
  exits 0; the built-in skill still updates.
- The dashboard runs the upgrade so the skill updates, then answers
  409 `upgrade.nix` with the command when a newer CLI waits on Nix. The
  UI shows localized text for it in all 11 locales.
- Installs skip the unit tests; the flake's checks enable them. postPatch
  lowers only the go directive's patch version and fails evaluation with
  a clear message when go.mod needs a newer Go minor. CI also builds the
  package on macOS.
- Docs, translations, the built-in skill reference and the release topic
  describe the new behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Charitarth Chugh
2026-11-04 15:53:57 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 83d4d0ac19
commit 64c8a3f34e
67 changed files with 864 additions and 59 deletions
+16 -1
View File
@@ -42,8 +42,23 @@ curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/install.sh
irm https://raw.githubusercontent.com/runkids/skillshare/main/install.ps1 | iex
```
**Nix (Linux / Apple Silicon macOS):**
```bash
nix profile add github:runkids/skillshare
```
Update with `nix profile upgrade skillshare`. Requires Nix 2.30+ with flakes enabled; on older Nix or Lix, use `nix profile install`. For NixOS or Home Manager, add the flake as an input and use its overlay:
```nix
# flake.nix
inputs.skillshare.url = "github:runkids/skillshare";
# NixOS or Home Manager module
nixpkgs.overlays = [ inputs.skillshare.overlays.default ];
environment.systemPackages = [ pkgs.skillshare ]; # or home.packages
```
:::tip Updating later
`skillshare upgrade` detects how you installed (Homebrew, script, manual) and updates the CLI in place.
`skillshare upgrade` detects how you installed (Homebrew, script, manual) and updates the CLI in place. For a Nix install, it leaves the CLI to Nix and says how to update it: `nix profile upgrade skillshare` for a `nix profile` install, or a rebuild of your NixOS or Home Manager configuration.
:::
## 2. Initialize
@@ -362,6 +362,8 @@ Next
brew upgrade skillshare update to v1.3.0
```
A `nix profile` install gets `nix profile upgrade skillshare` as its Next line. When NixOS or Home Manager provides skillshare, the Update row says to update your Nix configuration and rebuild, and there is no Next line for it.
## JSON Output
Use `--json` for machine-readable output in CI pipelines and automation:
+4 -2
View File
@@ -187,7 +187,7 @@ The web dashboard exposes a REST API at `/api/`. All endpoints return JSON.
| GET | `/api/doctor` | Run all health checks (JSON) |
| GET | `/api/health` | Liveness probe; returns `200` once the server is ready |
| GET | `/api/version` | Current/latest version + whether an upgrade is available |
| POST | `/api/upgrade` | Run `skillshare upgrade` in place (returns `devMode: true` when the binary is a dev build) |
| POST | `/api/upgrade` | Run `skillshare upgrade` in place (returns `devMode: true` when the binary is a dev build, and `409` with code `upgrade.nix` for a Nix install) |
| POST | `/api/restart` | Restart the local UI server; optional `{ "clearCache": true }` body clears cached UI assets first |
## In-place Upgrade
@@ -198,6 +198,8 @@ When the dashboard detects that a newer CLI release is available, the **Update**
2. Once the new binary is in place, the UI calls `POST /api/restart` to restart the local server.
3. The browser polls `GET /api/health` and reloads automatically once the new server is ready.
If skillshare is installed with Nix, the endpoint refuses with `409` (`upgrade.nix`) and the dialog shows how to update through Nix instead. See [upgrade](./upgrade.md#nix-users).
If the running binary is a development build (`version == "dev"`), the upgrade endpoint returns `devMode: true` and the UI simulates a restart without modifying anything on disk.
If the auto-reload doesn't complete, the dialog tells you to run `skillshare ui start` to bring the background server back up.
@@ -279,7 +281,7 @@ The dashboard reads and writes `.skillshare/config.yaml`, syncs to project-local
## Homebrew Note
All install methods (Homebrew, installer script, manual binary) use runtime UI download. When you run `skillshare ui`, it automatically downloads the UI assets from GitHub on first launch. After that, the cached assets are used offline.
All install methods (Homebrew, Nix, installer script, manual binary) use runtime UI download. When you run `skillshare ui`, it automatically downloads the UI assets from GitHub on first launch. After that, the cached assets are used offline.
To clear the downloaded UI cache:
@@ -60,6 +60,18 @@ You can also use Homebrew directly:
brew upgrade skillshare
```
## Nix Users {#nix-users}
If you installed with Nix, `skillshare upgrade` leaves the CLI alone, because replacing a file in the Nix store would corrupt it. When a newer version exists, it tells you how to get it instead. For `nix profile add`, that is:
```bash
nix profile upgrade skillshare
```
When a NixOS, Home Manager or overlay configuration provides skillshare, update skillshare in that configuration (for a flake input, `nix flake update skillshare`) and rebuild. The dashboard's upgrade button shows the same advice.
`skillshare upgrade --skill` still updates the built-in skill.
## Examples
```bash
+1 -1
View File
@@ -30,7 +30,7 @@ skillshare version 0.16.6
When a newer version is available, `skillshare` displays an update notification after commands that support it. The notification is **Homebrew-aware**: if skillshare was installed via Homebrew, it queries `brew info` for the latest formula version and suggests `brew upgrade skillshare`; otherwise it checks GitHub releases and suggests `skillshare upgrade`.
Detection is automatic — skillshare resolves its own executable path and checks whether it resides under a Homebrew Cellar prefix (e.g. `/opt/homebrew/Cellar/skillshare/`).
Detection is automatic — skillshare resolves its own executable path and checks whether it resides under a Homebrew Cellar prefix (e.g. `/opt/homebrew/Cellar/skillshare/`). A binary under `/nix/store/` checks GitHub releases. It suggests `nix profile upgrade skillshare` when the binary is in your `nix profile`, and otherwise tells you to update skillshare in your Nix configuration and rebuild.
Version checks are cached for 24 hours at `~/.cache/skillshare/version-check.json`.