-
-
Notifications
You must be signed in to change notification settings - Fork 30
Nix #144
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
Open
arunavo4
wants to merge
4
commits into
main
Choose a base branch
from
nix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Nix #144
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Nix Build and Cache | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| tags: | ||
| - 'v*' | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: cachix/install-nix-action@v24 | ||
| with: | ||
| extra_nix_config: | | ||
| experimental-features = nix-command flakes | ||
|
|
||
| - uses: cachix/cachix-action@v12 | ||
| with: | ||
| name: gitea-mirror # Your cache name | ||
| authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | ||
|
|
||
| - name: Build package | ||
| run: nix build --print-build-logs | ||
|
|
||
| - name: Check flake | ||
| run: nix flake check | ||
|
|
||
| - name: Test run (dry run) | ||
| run: | | ||
| # Just verify the binary exists and is executable | ||
| test -x ./result/bin/gitea-mirror | ||
| ./result/bin/gitea-mirror --version || echo "Version check skipped" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,8 @@ certs/*.pem | |
| certs/*.cer | ||
| !certs/README.md | ||
|
|
||
| # Nix build artifacts | ||
| result | ||
| result-* | ||
| .direnv/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| # Nix Distribution - Ready to Use! 🎉 | ||
|
|
||
| ## Current Status: ✅ WORKS NOW | ||
|
|
||
| Your Nix package is **already distributable**! Users can run it directly from GitHub without any additional setup on your end. | ||
|
|
||
| ## How Users Will Use It | ||
|
|
||
| ### Simple: Just Run From GitHub | ||
|
|
||
| ```bash | ||
| nix run --extra-experimental-features 'nix-command flakes' github:RayLabsHQ/gitea-mirror | ||
| ``` | ||
|
|
||
| That's it! No releases, no CI, no infrastructure needed. It works right now. | ||
|
|
||
| --- | ||
|
|
||
| ## What Happens When They Run This? | ||
|
|
||
| 1. **Nix fetches** your repo from GitHub | ||
| 2. **Nix reads** `flake.nix` and `flake.lock` | ||
| 3. **Nix builds** the package on their machine | ||
| 4. **Nix runs** the application | ||
| 5. **Result cached** in `/nix/store` for reuse | ||
|
|
||
| --- | ||
|
|
||
| ## Do You Need CI or Releases? | ||
|
|
||
| ### For Basic Usage: **NO** | ||
| Users can already use it from GitHub. No CI or releases required. | ||
|
|
||
| ### For Better UX: **Recommended** | ||
| Set up binary caching so users don't compile from source. | ||
|
|
||
| --- | ||
|
|
||
| ## Next Steps (Optional but Recommended) | ||
|
|
||
| ### Option 1: Add Binary Cache (5 minutes) | ||
|
|
||
| **Why:** Users download pre-built binaries instead of compiling (much faster!) | ||
|
|
||
| **How:** | ||
| 1. Create free account at https://cachix.org/ | ||
| 2. Create cache named `gitea-mirror` | ||
| 3. Add GitHub secret: `CACHIX_AUTH_TOKEN` | ||
| 4. GitHub Actions workflow already created at `.github/workflows/nix-build.yml` | ||
| 5. Add to your docs: | ||
| ```bash | ||
| # Users run once | ||
| cachix use gitea-mirror | ||
|
|
||
| # Then they get fast binary downloads | ||
| nix run github:RayLabsHQ/gitea-mirror | ||
| ``` | ||
|
|
||
| ### Option 2: Release Versioning (2 minutes) | ||
|
|
||
| **Why:** Users can pin to specific versions | ||
|
|
||
| **How:** | ||
| ```bash | ||
| # When ready to release | ||
| git tag v3.8.11 | ||
| git push origin v3.8.11 | ||
|
|
||
| # Users can then pin to this version | ||
| nix run github:RayLabsHQ/gitea-mirror/v3.8.11 | ||
| ``` | ||
|
|
||
| No additional CI needed - tags work automatically with flakes! | ||
|
|
||
| ### Option 3: Submit to nixpkgs (Long Term) | ||
|
|
||
| **Why:** Maximum discoverability and trust | ||
|
|
||
| **When:** After package is stable and well-tested | ||
|
|
||
| **How:** Submit PR to https://github.com/NixOS/nixpkgs | ||
|
|
||
| --- | ||
|
|
||
| ## Files Created | ||
|
|
||
| ### Essential (Already Working) | ||
| - ✅ `flake.nix` - Package definition | ||
| - ✅ `flake.lock` - Dependency lock file | ||
| - ✅ `.envrc` - direnv integration | ||
|
|
||
| ### Documentation | ||
| - ✅ `NIX.md` - Quick reference for users | ||
| - ✅ `docs/NIX_DEPLOYMENT.md` - Complete deployment guide | ||
| - ✅ `docs/NIX_DISTRIBUTION.md` - Distribution guide for you (maintainer) | ||
| - ✅ `README.md` - Updated with Nix instructions | ||
|
|
||
| ### CI (Optional, Already Set Up) | ||
| - ✅ `.github/workflows/nix-build.yml` - Builds + caches to Cachix | ||
|
|
||
| ### Updated | ||
| - ✅ `.gitignore` - Added Nix artifacts | ||
|
|
||
| --- | ||
|
|
||
| ## Comparison: Your Distribution Options | ||
|
|
||
| | Setup | Time | User Experience | What You Need | | ||
| |-------|------|----------------|---------------| | ||
| | **Direct GitHub** | 0 min ✅ | Slow (build from source) | Nothing! Works now | | ||
| | **+ Cachix** | 5 min | Fast (binary download) | Cachix account + token | | ||
| | **+ Git Tags** | 2 min | Versionable | Just push tags | | ||
| | **+ nixpkgs** | Hours | Official/Trusted | PR review process | | ||
|
|
||
| **Recommendation:** Start with Direct GitHub (already works!), add Cachix this week for better UX. | ||
|
|
||
| --- | ||
|
|
||
| ## Testing Your Distribution | ||
|
|
||
| You can test it right now: | ||
|
|
||
| ```bash | ||
| # Test direct GitHub usage | ||
| nix run --extra-experimental-features 'nix-command flakes' github:RayLabsHQ/gitea-mirror | ||
|
|
||
| # Test with specific commit | ||
| nix run github:RayLabsHQ/gitea-mirror/$(git rev-parse HEAD) | ||
|
|
||
| # Validate flake | ||
| nix flake check | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## User Documentation Locations | ||
|
|
||
| Users will find instructions in: | ||
| 1. **README.md** - Installation section (already updated) | ||
| 2. **NIX.md** - Quick reference | ||
| 3. **docs/NIX_DEPLOYMENT.md** - Detailed guide | ||
|
|
||
| All docs include the correct commands with experimental features flags. | ||
|
|
||
| --- | ||
|
|
||
| ## When to Release New Versions | ||
|
|
||
| ### For Git Tag Releases: | ||
| ```bash | ||
| # 1. Update version in package.json | ||
| vim package.json | ||
|
|
||
| # 2. Update version in flake.nix (line 17) | ||
| vim flake.nix # version = "3.8.12"; | ||
|
|
||
| # 3. Commit and tag | ||
| git add package.json flake.nix | ||
| git commit -m "chore: bump version to v3.8.12" | ||
| git tag v3.8.12 | ||
| git push origin main | ||
| git push origin v3.8.12 | ||
| ``` | ||
|
|
||
| Users can then use: `nix run github:RayLabsHQ/gitea-mirror/v3.8.12` | ||
|
|
||
| ### No Release Needed For: | ||
| - Bug fixes | ||
| - Small changes | ||
| - Continuous updates | ||
|
|
||
| Users can always use latest from main: `nix run github:RayLabsHQ/gitea-mirror` | ||
|
|
||
| --- | ||
|
|
||
| ## Summary | ||
|
|
||
| **✅ Ready to distribute RIGHT NOW** | ||
| - Just commit and push your `flake.nix` | ||
| - Users can run directly from GitHub | ||
| - No CI, releases, or infrastructure required | ||
|
|
||
| **🚀 Recommended next: Add Cachix (5 minutes)** | ||
| - Much better user experience | ||
| - Workflow already created | ||
| - Free for public projects | ||
|
|
||
| **📦 Optional later: Submit to nixpkgs** | ||
| - Maximum discoverability | ||
| - Official Nix repository | ||
| - Do this once package is stable | ||
|
|
||
| See `docs/NIX_DISTRIBUTION.md` for complete details! |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.