Skip to content

Commit 2e886d0

Browse files
authored
Merge branch 'master' into fix-fish-nix-profiles-use-nix-link
2 parents d5f4653 + 324bfd8 commit 2e886d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1153
-227
lines changed

.github/actions/install-nix-action/action.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ inputs:
1616
install_url:
1717
description: "URL of the Nix installer"
1818
required: false
19-
default: "https://releases.nixos.org/nix/nix-2.30.2/install"
19+
default: "https://releases.nixos.org/nix/nix-2.32.1/install"
2020
tarball_url:
2121
description: "URL of the Nix tarball to use with the experimental installer"
2222
required: false
2323
github_token:
2424
description: "Github token"
2525
required: true
26+
use_cache:
27+
description: "Whether to setup magic-nix-cache"
28+
default: true
29+
required: false
2630
runs:
2731
using: "composite"
2832
steps:
@@ -118,3 +122,10 @@ runs:
118122
source-url: ${{ inputs.experimental-installer-version != 'latest' && 'https://artifacts.nixos.org/experimental-installer/tag/${{ inputs.experimental-installer-version }}/${{ env.EXPERIMENTAL_INSTALLER_ARTIFACT }}' || '' }}
119123
nix-package-url: ${{ inputs.dogfood == 'true' && steps.download-nix-installer.outputs.tarball-path || (inputs.tarball_url || '') }}
120124
extra-conf: ${{ inputs.extra_nix_config }}
125+
- uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13
126+
if: ${{ inputs.use_cache == 'true' }}
127+
with:
128+
diagnostic-endpoint: ''
129+
use-flakehub: false
130+
use-gha-cache: true
131+
source-revision: 92d9581367be2233c2d5714a2640e1339f4087d8 # main

.github/workflows/ci.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
extra_nix_config:
3030
experimental-features = nix-command flakes
3131
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
use_cache: false
3233
- run: nix flake show --all-systems --json
3334

3435
pre-commit-checks:
@@ -41,7 +42,6 @@ jobs:
4142
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
4243
extra_nix_config: experimental-features = nix-command flakes
4344
github_token: ${{ secrets.GITHUB_TOKEN }}
44-
- uses: DeterminateSystems/magic-nix-cache-action@main
4545
- run: ./ci/gha/tests/pre-commit-checks
4646

4747
basic-checks:
@@ -92,7 +92,6 @@ jobs:
9292
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
9393
# The sandbox would otherwise be disabled by default on Darwin
9494
extra_nix_config: "sandbox = true"
95-
- uses: DeterminateSystems/magic-nix-cache-action@main
9695
# Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user:
9796
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
9897
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
@@ -171,7 +170,7 @@ jobs:
171170
echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
172171
TARBALL_PATH="$(find "$GITHUB_WORKSPACE/out" -name 'nix*.tar.xz' -print | head -n 1)"
173172
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
174-
- uses: cachix/install-nix-action@v31
173+
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
175174
if: ${{ !matrix.experimental-installer }}
176175
with:
177176
install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
@@ -227,12 +226,13 @@ jobs:
227226
- uses: actions/checkout@v5
228227
with:
229228
fetch-depth: 0
230-
- uses: cachix/install-nix-action@v31
229+
- uses: ./.github/actions/install-nix-action
231230
with:
232-
install_url: https://releases.nixos.org/nix/nix-2.20.3/install
233-
- uses: DeterminateSystems/magic-nix-cache-action@main
234-
- run: echo NIX_VERSION="$(nix --experimental-features 'nix-command flakes' eval .\#nix.version | tr -d \")" >> $GITHUB_ENV
235-
- run: nix --experimental-features 'nix-command flakes' build .#dockerImage -L
231+
dogfood: false
232+
extra_nix_config: |
233+
experimental-features = flakes nix-command
234+
- run: echo NIX_VERSION="$(nix eval .\#nix.version | tr -d \")" >> $GITHUB_ENV
235+
- run: nix build .#dockerImage -L
236236
- run: docker load -i ./result/image.tar.gz
237237
- run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:$NIX_VERSION
238238
- run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:master
@@ -289,7 +289,6 @@ jobs:
289289
extra_nix_config:
290290
experimental-features = nix-command flakes
291291
github_token: ${{ secrets.GITHUB_TOKEN }}
292-
- uses: DeterminateSystems/magic-nix-cache-action@main
293292
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
294293

295294
profile_build:
@@ -310,7 +309,6 @@ jobs:
310309
extra_nix_config: |
311310
experimental-features = flakes nix-command ca-derivations impure-derivations
312311
max-jobs = 1
313-
- uses: DeterminateSystems/magic-nix-cache-action@main
314312
- run: |
315313
nix build -L --file ./ci/gha/profile-build buildTimeReport --out-link build-time-report.md
316314
cat build-time-report.md >> $GITHUB_STEP_SUMMARY

doc/manual/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ manual = custom_target(
8888
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
8989
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
9090
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
91-
@4@ -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
91+
@4@ -r -L --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
9292
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
9393
rm -rf @2@/manual
9494
mv @2@/html @2@/manual

doc/manual/package.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ mkMesonDerivation (finalAttrs: {
3333
fileset.difference
3434
(fileset.unions [
3535
../../.version
36+
# For example JSON
37+
../../src/libutil-tests/data/hash
3638
# Too many different types of files to filter for now
3739
../../doc/manual
3840
./.

doc/manual/source/protocols/json/hash.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
{{#include hash-v1-fixed.md}}
22

3+
## Examples
4+
5+
### SHA-256 with Base64 encoding
6+
7+
```json
8+
{{#include schema/hash-v1/sha256-base64.json}}
9+
```
10+
11+
### SHA-256 with Base16 (hexadecimal) encoding
12+
13+
```json
14+
{{#include schema/hash-v1/sha256-base16.json}}
15+
```
16+
17+
### SHA-256 with Nix32 encoding
18+
19+
```json
20+
{{#include schema/hash-v1/sha256-nix32.json}}
21+
```
22+
23+
### BLAKE3 with Base64 encoding
24+
25+
```json
26+
{{#include schema/hash-v1/blake3-base64.json}}
27+
```
28+
329
<!--
430
## Raw Schema
531
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../src/libutil-tests/data/hash/

doc/manual/source/protocols/json/schema/hash-v1.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,38 @@ description: |
55
A cryptographic hash value used throughout Nix for content addressing and integrity verification.
66
77
This schema describes the JSON representation of Nix's `Hash` type.
8-
9-
TODO Work in progress
108
type: object
119
properties:
1210
algorithm:
13-
title: Hash algorithm
1411
"$ref": "#/$defs/algorithm"
12+
format:
13+
type: string
14+
enum:
15+
- base64
16+
- nix32
17+
- base16
18+
- sri
19+
title: Hash format
20+
description: |
21+
The encoding format of the hash value.
22+
23+
- `base64` uses standard Base64 encoding [RFC 4648, section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4)
24+
- `nix32` is Nix-specific base-32 encoding
25+
- `base16` is lowercase hexadecimal
26+
- `sri` is the [Subresource Integrity format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
27+
hash:
28+
type: string
29+
title: Hash
30+
description: |
31+
The encoded hash value, itself.
32+
33+
It is specified in the format specified by the `format` field.
34+
It must be the right length for the hash algorithm specified in the `algorithm` field, also.
35+
The hash value does not include any algorithm prefix.
1536
required:
1637
- algorithm
38+
- format
39+
- hash
1740
additionalProperties: false
1841
"$defs":
1942
algorithm:
@@ -24,6 +47,7 @@ additionalProperties: false
2447
- sha1
2548
- sha256
2649
- sha512
50+
title: Hash algorithm
2751
description: |
2852
The hash algorithm used to compute the hash value.
2953

flake.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,27 @@
471471
}
472472
);
473473

474+
apps = forAllSystems (
475+
system:
476+
let
477+
pkgs = nixpkgsFor.${system}.native;
478+
opener = if pkgs.stdenv.isDarwin then "open" else "xdg-open";
479+
in
480+
{
481+
open-manual = {
482+
type = "app";
483+
program = "${pkgs.writeShellScript "open-nix-manual" ''
484+
manual_path="${self.packages.${system}.nix-manual}/share/doc/nix/manual/index.html"
485+
if ! ${opener} "$manual_path"; then
486+
echo "Failed to open manual with ${opener}. Manual is located at:"
487+
echo "$manual_path"
488+
fi
489+
''}";
490+
meta.description = "Open the Nix manual in your browser";
491+
};
492+
}
493+
);
494+
474495
devShells =
475496
let
476497
makeShell = import ./packaging/dev-shell.nix { inherit lib devFlake; };

src/json-schema-checks/hash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../src/libutil-tests/data/hash

src/json-schema-checks/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ schema_dir = meson.current_source_dir() / 'schema'
2020

2121
# Get all example files
2222
schemas = [
23+
{
24+
'stem' : 'hash',
25+
'schema' : schema_dir / 'hash-v1.yaml',
26+
'files' : [
27+
'sha256-base64.json',
28+
'sha256-base16.json',
29+
'sha256-nix32.json',
30+
'blake3-base64.json',
31+
],
32+
},
2333
{
2434
'stem' : 'derivation',
2535
'schema' : schema_dir / 'derivation-v3.yaml',

0 commit comments

Comments
 (0)