Skip to content

Commit cf2b58e

Browse files
authored
Merge branch 'main' into rvdp/clippy
2 parents d945d5e + 58da8c3 commit cf2b58e

File tree

11 files changed

+78
-27
lines changed

11 files changed

+78
-27
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
format:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- uses: DeterminateSystems/determinate-nix-action@main
1313
- uses: DeterminateSystems/flakehub-cache-action@main
1414
- name: Check rustfmt
@@ -17,7 +17,7 @@ jobs:
1717
build:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v5
2121
- uses: DeterminateSystems/determinate-nix-action@main
2222
- uses: DeterminateSystems/flakehub-cache-action@main
2323
- name: Build
@@ -26,15 +26,15 @@ jobs:
2626
NixFlakeCheck:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v4
29+
- uses: actions/checkout@v5
3030
- uses: DeterminateSystems/flake-checker-action@main
3131
with:
3232
fail-mode: false
3333

3434
NixFormatting:
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@v5
3838
with:
3939
fetch-depth: 0
4040
- uses: DeterminateSystems/determinate-nix-action@main
@@ -45,15 +45,15 @@ jobs:
4545
EditorConfig:
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v5
4949
with:
5050
fetch-depth: 0
5151
- uses: greut/eclint-action@v0
5252

5353
ValidateJsonSchema:
5454
runs-on: ubuntu-latest
5555
steps:
56-
- uses: actions/checkout@v4
56+
- uses: actions/checkout@v5
5757
with:
5858
fetch-depth: 0
5959
- uses: DeterminateSystems/determinate-nix-action@main
@@ -66,7 +66,7 @@ jobs:
6666
SynthesizeIntegration:
6767
runs-on: ubuntu-latest
6868
steps:
69-
- uses: actions/checkout@v4
69+
- uses: actions/checkout@v5
7070
with:
7171
fetch-depth: 0
7272
- uses: DeterminateSystems/determinate-nix-action@main

.github/workflows/json-schema.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
pages: write
1616
id-token: write
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
with:
2020
fetch-depth: 0
2121
- uses: DeterminateSystems/determinate-nix-action@main
@@ -28,7 +28,7 @@ jobs:
2828
mkdir -p dist
2929
nix develop --command generate-schema-doc --config expand_buttons=true schema.json dist/index.html
3030
- name: Upload docs
31-
uses: actions/upload-pages-artifact@v3
31+
uses: actions/upload-pages-artifact@v4
3232
with:
3333
path: ./dist
3434
- name: Publish docs to GitHub Pages

.github/workflows/update-flake-lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
lockfile:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v5
1313
- uses: DeterminateSystems/determinate-nix-action@main
1414
- uses: DeterminateSystems/flakehub-cache-action@main
1515
- uses: DeterminateSystems/update-flake-lock@main

.github/workflows/update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v5
1313
- name: Check flake
1414
uses: DeterminateSystems/flake-checker-action@main
1515
with:

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootspec/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ serde_json = "1.0.99"
1616
thiserror = "1.0.40"
1717

1818
[dev-dependencies]
19-
tempfile = "3.20.0"
19+
tempfile = "3.23.0"

bootspec/rfc0125_spec.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
},
2121
"org.nixos.specialisation.v1": {
2222
"<name>": {
23+
"org.nix-community.test": {
24+
"foo": "bar"
25+
},
2326
"org.nixos.bootspec.v1": {
2427
"system": "x86_64-linux",
2528
"init": "/nix/store/xxx-nixos-system-xxx/init",

bootspec/src/generation.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ mod tests {
8888
.map(ToOwned::to_owned)
8989
.collect::<Vec<_>>();
9090
assert!(keys.contains(&SpecialisationName(String::from("<name>"))));
91+
92+
assert_eq!(
93+
from_json
94+
.specialisations
95+
.get(&SpecialisationName("<name>".into()))
96+
.unwrap()
97+
.extensions
98+
.get("org.nix-community.test")
99+
.unwrap()
100+
.as_object()
101+
.unwrap()
102+
.get("foo")
103+
.unwrap()
104+
.as_str(),
105+
Some("bar")
106+
)
91107
}
92108

93109
#[test]

bootspec/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub const JSON_FILENAME: &str = "boot.json";
3434
/// The type for a collection of generic extensions.
3535
pub type Extensions = HashMap<String, serde_json::Value>;
3636

37-
// !!! IMPORTANT: KEEP `BootSpec`, `Specialisations`, and `SCHEMA_VERSION` IN SYNC !!!
37+
// !!! IMPORTANT: KEEP `BootSpec`, `Specialisations`, `Specialisation`, and `SCHEMA_VERSION` IN SYNC !!!
3838
/// The current bootspec generation type.
3939
pub type BootSpec = v1::GenerationV1;
4040
/// The current specialisations type.
4141
pub type Specialisations = v1::SpecialisationsV1;
42+
/// The current specialisations type.
43+
pub type Specialisation = v1::SpecialisationV1;
4244
/// The current bootspec schema version.
4345
pub const SCHEMA_VERSION: u64 = v1::SCHEMA_VERSION;
4446

bootspec/src/v1.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use std::path::{Path, PathBuf};
55

66
use serde::{Deserialize, Serialize};
77

8+
use crate::deser;
89
use crate::error::{BootspecError, SynthesizeError};
9-
use crate::{Result, SpecialisationName, SystemConfigurationRoot};
10+
use crate::{Extensions, Result, SpecialisationName, SystemConfigurationRoot};
1011

1112
/// The V1 bootspec schema version.
1213
pub const SCHEMA_VERSION: u64 = 1;
@@ -48,7 +49,7 @@ impl GenerationV1 {
4849

4950
specialisations.insert(
5051
SpecialisationName(name.to_string()),
51-
Self::synthesize(&toplevel)?,
52+
SpecialisationV1::synthesize(&toplevel)?,
5253
);
5354
}
5455
}
@@ -62,8 +63,37 @@ impl GenerationV1 {
6263

6364
/// A mapping of V1 bootspec specialisations.
6465
///
65-
/// This structure represents the contents of the `org.nixos.specialisations.v1` key.
66-
pub type SpecialisationsV1 = HashMap<SpecialisationName, GenerationV1>;
66+
/// This structure represents the contents of the `org.nixos.specialisation.v1` key.
67+
pub type SpecialisationsV1 = HashMap<SpecialisationName, SpecialisationV1>;
68+
69+
/// A V1 bootspec specialisation.
70+
///
71+
/// This structure represents a single specialisation contained in the `org.nixos.specialisation.v1` key.
72+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
73+
pub struct SpecialisationV1 {
74+
#[serde(flatten)]
75+
pub generation: GenerationV1,
76+
#[serde(
77+
default = "HashMap::new",
78+
skip_serializing_if = "HashMap::is_empty",
79+
deserialize_with = "deser::skip_generation_fields",
80+
flatten
81+
)]
82+
pub extensions: Extensions,
83+
}
84+
85+
impl SpecialisationV1 {
86+
/// Synthesize a [`SpecialisationV1`] struct from the path to a NixOS generation.
87+
///
88+
/// This is useful when used on generations that do not have a bootspec attached to it.
89+
pub fn synthesize(generation_path: &Path) -> Result<Self> {
90+
let generation = GenerationV1::synthesize(generation_path)?;
91+
Ok(Self {
92+
generation,
93+
extensions: HashMap::new(),
94+
})
95+
}
96+
}
6797

6898
/// A V1 bootspec toplevel.
6999
///

0 commit comments

Comments
 (0)