Skip to content

Commit 68fc9d4

Browse files
authored
Merge pull request #172 from DeterminateSystems/determinate-nix-example
Use Determinate Nix in examples
2 parents f258f6b + 8df4e70 commit 68fc9d4

File tree

4 files changed

+104
-56
lines changed

4 files changed

+104
-56
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI
2+
23
on:
34
pull_request:
45
push:
@@ -11,8 +12,14 @@ jobs:
1112
- uses: actions/checkout@v4
1213
with:
1314
fetch-depth: 0
14-
- name: Install Nix
15+
- name: Check Nixpkgs
16+
uses: DeterminateSystems/flake-checker-action@main
17+
with:
18+
fail-mode: true
19+
- name: Install Determinate Nix
1520
uses: DeterminateSystems/nix-installer-action@main
21+
with:
22+
determinate: true
1623
- name: Enable FlakeHub Cache
1724
uses: DeterminateSystems/flakehub-cache-action@main
1825
- name: Install pnpm dependencies

.github/workflows/update.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: update-flake-lock
2+
23
on:
34
workflow_dispatch:
45
schedule:
@@ -10,10 +11,10 @@ jobs:
1011
steps:
1112
- name: Checkout
1213
uses: actions/checkout@v4
13-
- name: Check flake
14-
uses: DeterminateSystems/flake-checker-action@main
15-
- name: Install Nix
14+
- name: Install Determinate Nix
1615
uses: DeterminateSystems/nix-installer-action@main
16+
with:
17+
determinate: true
1718
- name: Enable FlakeHub Cache
1819
uses: DeterminateSystems/flakehub-cache-action@main
1920
- name: Update flake.lock

.github/workflows/validate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI
2+
23
on:
34
pull_request:
45
push:

README.md

Lines changed: 91 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# update-flake-lock
22

3-
This is a GitHub Action that will update your flake.lock file whenever it is run.
3+
This is a GitHub Action that updates the [`flake.lock`][lockfile] file for your [Nix flake][flakes] whenever it is run.
44

5-
> **NOTE:** As of v3, this action will no longer automatically install Nix to the action runner. You **MUST** set up a Nix with flakes support enabled prior to running this action, or your workflow will not function as expected.
5+
> [!NOTE]
6+
> As of v3, this action no longer automatically installs [Determinate Nix][det-nix] to the action runner.
7+
> You **must** set up Nix with flakes support enabled prior to running this action or your workflow will not function as expected.
68
79
## Example
810

9-
An example GitHub Action workflow using this action would look like the following:
11+
Here's an example GitHub Action workflow using this Action:
1012

1113
```yaml
1214
name: update-flake-lock
15+
1316
on:
1417
workflow_dispatch: # allows manual triggering
1518
schedule:
@@ -21,8 +24,10 @@ jobs:
2124
steps:
2225
- name: Checkout repository
2326
uses: actions/checkout@v4
24-
- name: Install Nix
27+
- name: Install Determinate Nix
2528
uses: DeterminateSystems/nix-installer-action@main
29+
with:
30+
determinate: true
2631
- name: Update flake.lock
2732
uses: DeterminateSystems/update-flake-lock@main
2833
with:
@@ -34,12 +39,14 @@ jobs:
3439
3540
## Example updating specific input(s)
3641
37-
> **NOTE**: If any inputs have a stale reference (e.g. the lockfile thinks a git input wants its "ref" to be "nixos-unstable", but the flake.nix specifies "nixos-unstable-small"), they will also be updated. At this time, there is no known workaround.
42+
> [!NOTE]
43+
> If any inputs have a stale reference (e.g. the lockfile thinks a git input wants its "ref" to be "nixos-unstable", but the flake.nix specifies "nixos-unstable-small"), they are also updated. At this time, there is no known workaround.
3844
39-
It is also possible to update specific inputs by specifying them in a space-separated list:
45+
It's also possible to update specific [flake inputs][inputs] by specifying them in a space-separated list:
4046
4147
```yaml
4248
name: update-flake-lock
49+
4350
on:
4451
workflow_dispatch: # allows manual triggering
4552
schedule:
@@ -51,17 +58,19 @@ jobs:
5158
steps:
5259
- name: Checkout repository
5360
uses: actions/checkout@v4
54-
- name: Install Nix
55-
uses: DeterminateSystems/nix-installer-action@v1
61+
- name: Install Determinate Nix
62+
uses: DeterminateSystems/nix-installer-action@main
63+
with:
64+
determinate: true
5665
- name: Update flake.lock
57-
uses: DeterminateSystems/update-flake-lock@vX
66+
uses: DeterminateSystems/update-flake-lock@main
5867
with:
5968
inputs: input1 input2 input3
6069
```
6170
6271
## Example adding options to nix command
6372
64-
It is also possible to use specific options to the nix command in a space separated list:
73+
It's also possible to use specific options to the `nix` command in a space-separated list:
6574

6675
```yaml
6776
name: update-flake-lock
@@ -76,10 +85,12 @@ jobs:
7685
steps:
7786
- name: Checkout repository
7887
uses: actions/checkout@v4
79-
- name: Install Nix
80-
uses: DeterminateSystems/nix-installer-action@v1
88+
- name: Install Determinate Nix
89+
uses: DeterminateSystems/nix-installer-action@main
90+
with:
91+
determinate: true
8192
- name: Update flake.lock
82-
uses: DeterminateSystems/update-flake-lock@vX
93+
uses: DeterminateSystems/update-flake-lock@main
8394
with:
8495
nix-options: --debug --log-format raw
8596
```
@@ -99,11 +110,13 @@ jobs:
99110
steps:
100111
- name: Checkout repository
101112
uses: actions/checkout@v4
102-
- name: Install Nix
103-
uses: DeterminateSystems/nix-installer-action@v1
113+
- name: Install Determinate Nix
114+
uses: DeterminateSystems/nix-installer-action@main
115+
with:
116+
determinate: true
104117
- name: Update flake.lock
105118
id: update
106-
uses: DeterminateSystems/update-flake-lock@vX
119+
uses: DeterminateSystems/update-flake-lock@main
107120
with:
108121
inputs: input1 input2 input3
109122
- name: Print PR number
@@ -128,11 +141,13 @@ jobs:
128141
steps:
129142
- name: Checkout repository
130143
uses: actions/checkout@v4
131-
- name: Install Nix
132-
uses: DeterminateSystems/nix-installer-action@v1
144+
- name: Install Determinate Nix
145+
uses: DeterminateSystems/nix-installer-action@main
146+
with:
147+
determinate: true
133148
- name: Update flake.lock
134149
if: ${{ github.event_name != 'pull_request' }}
135-
uses: DeterminateSystems/update-flake-lock@vX
150+
uses: DeterminateSystems/update-flake-lock@main
136151
with:
137152
inputs: input1 input2 input3
138153
path-to-flake-dir: 'nix/' # in this example our flake doesn't sit at the root of the repository, it sits under 'nix/flake.nix'
@@ -155,28 +170,31 @@ jobs:
155170
steps:
156171
- name: Checkout repository
157172
uses: actions/checkout@v4
158-
- name: Install Nix
159-
uses: DeterminateSystems/nix-installer-action@v1
173+
- name: Install Determinate Nix
174+
uses: DeterminateSystems/nix-installer-action@main
175+
with:
176+
determinate: true
160177
- name: Update flake.lock
161-
uses: DeterminateSystems/update-flake-lock@vX
178+
uses: DeterminateSystems/update-flake-lock@main
162179
with:
163-
git-author-name: 'Jane Author'
164-
git-author-email: 'github-actions[bot]@users.noreply.github.com'
165-
git-committer-name: 'John Committer'
166-
git-committer-email: 'github-actions[bot]@users.noreply.github.com'
180+
git-author-name: Jane Author
181+
git-author-email: github-actions[bot]@users.noreply.github.com
182+
git-committer-name: John Committer
183+
git-committer-email: github-actions[bot]@users.noreply.github.com
167184
```
168185

169186
## Running GitHub Actions CI
170187

171-
GitHub Actions will not run workflows when a branch is pushed by or a PR is opened by a GitHub Action. There are two ways to have GitHub Actions CI run on a PR submitted by this action.
188+
GitHub Actions doesn't run workflows when a branch is pushed by or a PR is opened by a GitHub Action.
189+
There are two ways to have GitHub Actions CI run on a PR submitted by this action.
172190

173191
### Without a Personal Authentication Token
174192

175193
Without using a Personal Authentication Token, close and reopen the pull request manually to kick off CI.
176194

177195
### With a Personal Authentication Token
178196

179-
By providing a Personal Authentication Token, the PR will be submitted in a way that bypasses this limitation (GitHub will essentially think it is the owner of the PAT submitting the PR, and not an Action).
197+
By providing a Personal Authentication Token, the PR is submitted in a way that bypasses this limitation (GitHub essentially thinks it's the owner of the PAT submitting the PR, and not an Action).
180198
You can create a token by visiting https://github.com/settings/tokens and select at least the `repo` scope. For the new fine-grained tokens, you need to enable read and write access for "Contents" and "Pull Requests" permissions. Then, store this token in your repository secrets (i.e. `https://github.com/<USER>/<REPO>/settings/secrets/actions`) as `GH_TOKEN_FOR_UPDATES` and set up your workflow file like the following:
181199

182200
```yaml
@@ -192,30 +210,36 @@ jobs:
192210
steps:
193211
- name: Checkout repository
194212
uses: actions/checkout@v4
195-
- name: Install Nix
196-
uses: DeterminateSystems/nix-installer-action@v1
213+
- name: Install Determinate Nix
214+
uses: DeterminateSystems/nix-installer-action@main
215+
with:
216+
determinate: true
197217
- name: Update flake.lock
198-
uses: DeterminateSystems/update-flake-lock@vX
218+
uses: DeterminateSystems/update-flake-lock@main
199219
with:
200220
token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
201221
```
202222

203223
## With GPG commit signing
204224

205-
It's possible for the bot to produce GPG signed commits. Associating a GPG public key to a github user account is not required but it is necessary if you want the signed commits to appear as verified in Github. This can be a compliance requirement in some cases.
225+
It's possible for the bot to produce GPG-signed commits.
226+
Associating a GPG public key to a GitHub user account isn't required but it *is* necessary if you want the signed commits to appear as verified in Github.
227+
This can be a compliance requirement in some cases.
206228

207-
You can follow [Github's guide on creating and/or adding a new GPG key to an user account](https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account). Using a specific github user account for the bot can be a good security measure to dissociate this bot's actions and commits from your personal github account.
229+
You can follow [GitHub's guide to creating and/or adding a new GPG key to an user account](https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account).
230+
Using a specific GitHub user account for the bot can be a good security measure to dissociate this bot's actions and commits from your personal GitHub account.
208231

209-
For the bot to produce signed commits, you will have to provide the GPG private keys to this action's input parameters. You can safely do that with [Github secrets as explained here](https://github.com/crazy-max/ghaction-import-gpg#prerequisites).
232+
For the bot to produce signed commits, you need to provide the GPG private keys to this action's input parameters. You can safely do that with [Github secrets as explained here](https://github.com/crazy-max/ghaction-import-gpg#prerequisites).
210233

211234
When using commit signing, the commit author name and email for the commits produced by this bot would correspond to the ones associated to the GPG Public Key.
212235

213236
If you want to sign using a subkey, you must specify the subkey fingerprint using the `gpg-fingerprint` input parameter.
214237

215-
You can find an example of how to using this action with commit signing below:
238+
Here's an example of how to using this action with commit signing:
216239

217240
```yaml
218241
name: update-flake-lock
242+
219243
on:
220244
workflow_dispatch: # allows manual triggering
221245
schedule:
@@ -227,10 +251,12 @@ jobs:
227251
steps:
228252
- name: Checkout repository
229253
uses: actions/checkout@v4
230-
- name: Install Nix
231-
uses: DeterminateSystems/nix-installer-action@v1
254+
- name: Install Determinate Nix
255+
uses: DeterminateSystems/nix-installer-action@main
256+
with:
257+
determinate: true
232258
- name: Update flake.lock
233-
uses: DeterminateSystems/update-flake-lock@vX
259+
uses: DeterminateSystems/update-flake-lock@main
234260
with:
235261
sign-commits: true
236262
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
@@ -240,18 +266,19 @@ jobs:
240266

241267
## Custom PR Body
242268

243-
By default the generated PR body is set to be the following template:
269+
By default, the generated PR body uses this template:
244270

245271
````handlebars
246272
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
247273

248-
```
274+
````
249275
{{ env.GIT_COMMIT_MESSAGE }}
276+
````
250277
```
251278

252279
### Running GitHub Actions on this PR
253280

254-
GitHub Actions will not run workflows on pull requests which are opened by a GitHub Action.
281+
GitHub Actions doesn't run workflows on pull requests that are opened by a GitHub Action.
255282

256283
To run GitHub Actions workflows on this PR, run:
257284

@@ -264,12 +291,14 @@ git push origin update_flake_lock_action --force
264291
```
265292
````
266293
267-
However you can customize it, with variable interpolation performed with [Handlebars](https://handlebarsjs.com/). This allows you to customize the template with the following variables:
268-
- env.GIT_AUTHOR_NAME
269-
- env.GIT_AUTHOR_EMAIL
270-
- env.GIT_COMMITTER_NAME
271-
- env.GIT_COMMITTER_EMAIL
272-
- env.GIT_COMMIT_MESSAGE
294+
You can customize it, however, using variable interpolation performed with [Handlebars].
295+
This enables you to customize the template with these variables:
296+
297+
- `env.GIT_AUTHOR_NAME`
298+
- `env.GIT_AUTHOR_EMAIL`
299+
- `env.GIT_COMMITTER_NAME`
300+
- `env.GIT_COMMITTER_EMAIL`
301+
- `env.GIT_COMMIT_MESSAGE`
273302
274303
## Add assignees or reviewers
275304
@@ -289,19 +318,29 @@ jobs:
289318
steps:
290319
- name: Checkout repository
291320
uses: actions/checkout@v4
292-
- name: Install Nix
293-
uses: DeterminateSystems/nix-installer-action@v1
321+
- name: Install Determinate Nix
322+
uses: DeterminateSystems/nix-installer-action@main
323+
with:
324+
determinate: true
294325
- name: Update flake.lock
295-
uses: DeterminateSystems/update-flake-lock@vX
326+
uses: DeterminateSystems/update-flake-lock@main
296327
with:
297328
pr-assignees: SomeGitHubUsername
298329
pr-reviewers: SomeOtherGitHubUsername,SomeThirdGitHubUsername
299330
```
300331
301332
## Contributing
302333
303-
Feel free to send a PR or open an issue if you find something functions unexpectedly! Please make sure to test your changes and update any related documentation before submitting your PR.
334+
Feel free to send a PR or open an issue if you find that something functions unexpectedly!
335+
Please make sure to test your changes and update any related documentation before submitting your PR.
304336
305337
### How to test changes
306338
307-
In order to more easily test your changes to this action, we have created a template repository that should point you in the right direction: https://github.com/DeterminateSystems/update-flake-lock-test-template. Please see the README in that repository for instructions on testing your changes.
339+
In order to more easily test your changes to this action, we have created a template repository that should point you in the right direction: https://github.com/DeterminateSystems/update-flake-lock-test-template.
340+
Please see the README in that repository for instructions on testing your changes.
341+
342+
[det-nix]: https://docs.determinate.systems/determinate-nix
343+
[flakes]: https://zero-to-nix.com/concepts/flakes
344+
[handlebars]: https://handlebarsjs.com
345+
[inputs]: https://zero-to-nix.com/concepts/flakes/#inputs
346+
[lockfile]: https://zero-to-nix.com/concepts/flakes/#lockfile

0 commit comments

Comments
 (0)