Skip to content

Commit 1a97fb7

Browse files
authored
Merge pull request #17 from Profiidev/feat/action
2 parents a03b75b + 142112f commit 1a97fb7

15 files changed

Lines changed: 20334 additions & 8 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Auto Merge PR with Flake Lock Update
2+
3+
on:
4+
pull_request:
5+
types:
6+
- labeled
7+
8+
jobs:
9+
merge:
10+
if: ${{ github.event.label.name == 'flake-lock-update' && github.event.pull_request.user.login == 'Profiidev' }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v6
15+
- name: Enable auto-merge for PR
16+
run: gh pr merge ${{ github.event.pull_request.number }} --auto --squash
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
19+
GITHUB_REPOSITORY: ${{ github.repository }}

.github/workflows/create-release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@ jobs:
2929
run: |
3030
git tag -f latest
3131
git push origin -f latest
32+
33+
- name: Update major tag
34+
run: |
35+
VERSION=${{ github.event.pull_request.head.ref }}
36+
VERSION=${VERSION#chore/release-version-}
37+
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
38+
git tag -f "$MAJOR_VERSION"
39+
git push origin -f "$MAJOR_VERSION"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lock Update
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * 1" # Every Monday at midnight UTC
7+
8+
jobs:
9+
update-components:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v6
14+
- uses: cachix/install-nix-action@v31
15+
16+
- name: Update components
17+
run: |
18+
nix flake update
19+
20+
- name: Create PR
21+
uses: peter-evans/create-pull-request@v8
22+
with:
23+
token: ${{ secrets.PERSONAL_TOKEN }}
24+
commit-message: "chore: updated flake lock"
25+
branch: "chore/update-flake-lock-${{ github.run_id }}"
26+
title: "chore: update flake lock"
27+
body: "This PR updates the flake inputs to the latest versions."
28+
base: main
29+
sign-commits: true
30+
labels: flake-lock-update

.github/workflows/release-trigger.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
token: ${{ secrets.PERSONAL_TOKEN }}
1818
uses: actions/checkout@v6
1919
- uses: dtolnay/rust-toolchain@stable
20+
- uses: bahmutov/npm-install@v1
2021

2122
- name: Update version
2223
id: update_version
@@ -29,6 +30,7 @@ jobs:
2930
sed -i "s/version = \".*\"/version = \"$NEW_VERSION\"/" flake.nix
3031
cargo metadata -q
3132
cd frontend && npm version $NEW_VERSION --no-git-tag-version
33+
cd ../actions && npm version $NEW_VERSION --no-git-tag-version && npm run build
3234
3335
- name: Create PR
3436
uses: peter-evans/create-pull-request@v8

.github/workflows/test-action.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test Setup Action
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
test-setup:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os:
11+
- ubuntu-latest
12+
- ubuntu-24.04-arm
13+
- macos-latest
14+
version:
15+
- v0.1.0
16+
- latest
17+
name: Test Setup Action on ${{ matrix.os }} with version ${{ matrix.version }}
18+
steps:
19+
- uses: actions/checkout@v6
20+
- name: Setup Cli
21+
uses: ./
22+
with:
23+
version: ${{ matrix.version }}
24+
25+
- name: Verify Installation
26+
if: matrix.version != 'latest'
27+
run: |
28+
RAW_VERSION=${{ matrix.version }}
29+
VERSION="${RAW_VERSION#v}"
30+
hibernation --version | grep $VERSION
31+
32+
- name: Verify Latest Installation
33+
if: matrix.version == 'latest'
34+
run: |
35+
hibernation --version

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,33 @@ See `backend/src/config.rs` for all non-standard configuration options.
5353

5454
The CLI tool allows you to interact with the Hibernation server, primarily for authenticating and pushing Nix store paths.
5555

56-
You can install it from the binaries published to GitHub Releases or using Cargo:
56+
You can install it from the binaries published to GitHub Releases, using Cargo:
5757

5858
```bash
5959
cargo install --git https://github.com/ProfiiDev/hibernation hibernation
6060
```
6161

62+
Or in you nix config:
63+
64+
```nix
65+
{
66+
inputs = {
67+
...
68+
hibernation.url = "github:profiidev/hibernation/latest";
69+
}
70+
...
71+
}
72+
```
73+
74+
```nix
75+
{ inputs, pkgs, ... }:
76+
{
77+
environment.systemPackages = with pkgs; [
78+
inputs.hibernation.packages.${stdenv.hostPlatform.system}.default
79+
];
80+
}
81+
```
82+
6283
### Pushing Nix Store Paths
6384

6485
1. To push a Nix store path to the Hibernation server you first need a signing key pair. You can generate a new secret key using the following command:
@@ -77,7 +98,7 @@ cargo install --git https://github.com/ProfiiDev/hibernation hibernation
7798

7899
4. Use the following command from the cli to push paths (all missing configuration will be prompted for):
79100
```bash
80-
hibernation push /nix/store/your-store-path
101+
hibernation push <cache-name> /nix/store/your-store-path
81102
```
82103

83104
## Deployment
@@ -111,7 +132,9 @@ Once running, the services will be available at:
111132

112133
## TODO
113134

114-
- cli flake install docs
115-
- github action for cache and cli setup
135+
- nix api support byte range queries
136+
- move url setting from frontend to env var and document in readme
137+
- add support for virtual host based cache access (requires more restrictions on cache names)
138+
- document action usage in readme
116139
- add overview page in frontend
117140
- nix store watch mode in cli + auto push + example in cache page

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Hibernation setup
2+
description: Setup Hibernation CLI
3+
4+
inputs:
5+
version:
6+
description: The version of Hibernation CLI to install
7+
required: true
8+
default: latest
9+
10+
runs:
11+
using: node24
12+
main: action/dist/index.js

action/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/index.js.map

0 commit comments

Comments
 (0)