Merge pull request #148 from nix-community/rfc0125-post-merge

bootspec: RFC-0125 final changes
This commit is contained in:
Ryan Lahfa 2023-04-29 16:01:40 +02:00 committed by GitHub
commit 484b2c2fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 110 additions and 120 deletions

View File

@ -16,11 +16,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1680584903, "lastModified": 1681177078,
"narHash": "sha256-uraq+D3jcLzw/UVk0xMHcnfILfIMa0DLrtAEq2nNlxU=", "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "65d3f6a3970cd46bef5eedfd458300f72c56b3c5", "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -66,12 +66,15 @@
} }
}, },
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1678901627, "lastModified": 1681202837,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -103,11 +106,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1682347030, "lastModified": 1682741954,
"narHash": "sha256-HYpAMGhF82mEaozCPz7FrHRCMJK5rOGA9Ed/kyszgmY=", "narHash": "sha256-RPZxzRu8XU0YD2WeYUFYzJy5yAvWUsxkuK+zWw+6WVk=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8dd0f0a459b206fc4209570f6b7ce44ae66f264e", "rev": "373e9eb4c42b2fc0611d794de5ea715a35d72393",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -148,11 +151,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1680981441, "lastModified": 1681413034,
"narHash": "sha256-Tqr2mCVssUVp1ZXXMpgYs9+ZonaWrZGPGltJz94FYi4=", "narHash": "sha256-/t7OjNQcNkeWeSq/CFLYVBfm+IEnkjoSm9iKvArnUUI=",
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "2144d9ddcb550d6dce64a2b44facdc8c5ea2e28a", "rev": "d3de8f69ca88fb6f8b09e5b598be5ac98d28ede5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -194,6 +197,21 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -54,7 +54,7 @@ let
return f'/boot/EFI/nixos/{store_dir}-{filename}.efi' return f'/boot/EFI/nixos/{store_dir}-{filename}.efi'
machine.start() machine.start()
bootspec = json.loads(machine.succeed("cat /run/current-system/boot.json")).get('v1') bootspec = json.loads(machine.succeed("cat /run/current-system/boot.json")).get('org.nixos.bootspec.v1')
assert bootspec is not None, "Unsupported bootspec version!" assert bootspec is not None, "Unsupported bootspec version!"
src_path = ${path.src} src_path = ${path.src}
dst_path = ${path.dst} dst_path = ${path.dst}

147
rust/tool/Cargo.lock generated
View File

@ -17,7 +17,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371"
dependencies = [ dependencies = [
"anstyle 1.0.0", "anstyle",
"anstyle-parse", "anstyle-parse",
"anstyle-query", "anstyle-query",
"anstyle-wincon", "anstyle-wincon",
@ -26,12 +26,6 @@ dependencies = [
"utf8parse", "utf8parse",
] ]
[[package]]
name = "anstyle"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2"
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.0" version = "1.0.0"
@ -62,7 +56,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd"
dependencies = [ dependencies = [
"anstyle 1.0.0", "anstyle",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@ -78,7 +72,7 @@ version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151"
dependencies = [ dependencies = [
"anstyle 1.0.0", "anstyle",
"bstr", "bstr",
"doc-comment", "doc-comment",
"predicates", "predicates",
@ -122,7 +116,8 @@ dependencies = [
[[package]] [[package]]
name = "bootspec" name = "bootspec"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/DeterminateSystems/bootspec#cc4a01a1589d9bc80059854e0f44b69b836a3fe2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92fa1287819c2a8fbfd14c066941f41dc529fcd2b59b3a3aaced1650e88d1d44"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@ -190,7 +185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle 1.0.0", "anstyle",
"bitflags", "bitflags",
"clap_lex", "clap_lex",
"strsim", "strsim",
@ -205,7 +200,7 @@ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.13", "syn 2.0.15",
] ]
[[package]] [[package]]
@ -232,15 +227,15 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.5" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -257,9 +252,9 @@ dependencies = [
[[package]] [[package]]
name = "cxx" name = "cxx"
version = "1.0.93" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
dependencies = [ dependencies = [
"cc", "cc",
"cxxbridge-flags", "cxxbridge-flags",
@ -269,9 +264,9 @@ dependencies = [
[[package]] [[package]]
name = "cxx-build" name = "cxx-build"
version = "1.0.93" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
dependencies = [ dependencies = [
"cc", "cc",
"codespan-reporting", "codespan-reporting",
@ -279,24 +274,24 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"scratch", "scratch",
"syn 2.0.13", "syn 2.0.15",
] ]
[[package]] [[package]]
name = "cxxbridge-flags" name = "cxxbridge-flags"
version = "1.0.93" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
[[package]] [[package]]
name = "cxxbridge-macro" name = "cxxbridge-macro"
version = "1.0.93" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.13", "syn 2.0.15",
] ]
[[package]] [[package]]
@ -333,17 +328,6 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.1" version = "0.3.1"
@ -398,9 +382,9 @@ dependencies = [
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.6" version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [ dependencies = [
"typenum", "typenum",
"version_check", "version_check",
@ -408,9 +392,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.8" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -451,16 +435,16 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.53" version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"core-foundation-sys", "core-foundation-sys",
"iana-time-zone-haiku", "iana-time-zone-haiku",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"winapi", "windows",
] ]
[[package]] [[package]]
@ -490,25 +474,25 @@ dependencies = [
[[package]] [[package]]
name = "io-lifetimes" name = "io-lifetimes"
version = "1.0.8" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155" checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
dependencies = [ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"libc", "libc",
"windows-sys 0.45.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.5" version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
dependencies = [ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"io-lifetimes", "io-lifetimes",
"rustix 0.36.10", "rustix",
"windows-sys 0.45.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -562,9 +546,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.140" version = "0.2.142"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
[[package]] [[package]]
name = "link-cplusplus" name = "link-cplusplus"
@ -577,15 +561,9 @@ dependencies = [
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.1.4" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c"
[[package]]
name = "linux-raw-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f"
[[package]] [[package]]
name = "log" name = "log"
@ -653,11 +631,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]] [[package]]
name = "predicates" name = "predicates"
version = "3.0.1" version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ba7d6ead3e3966038f68caa9fc1f860185d95a793180bbcfe0d0da47b3961ed" checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9"
dependencies = [ dependencies = [
"anstyle 0.3.5", "anstyle",
"difflib", "difflib",
"itertools", "itertools",
"predicates-core", "predicates-core",
@ -753,30 +731,16 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.36.10" version = "0.37.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778" checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"errno 0.2.8", "errno",
"io-lifetimes", "io-lifetimes",
"libc", "libc",
"linux-raw-sys 0.1.4", "linux-raw-sys",
"windows-sys 0.45.0", "windows-sys 0.48.0",
]
[[package]]
name = "rustix"
version = "0.37.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d"
dependencies = [
"bitflags",
"errno 0.3.1",
"io-lifetimes",
"libc",
"linux-raw-sys 0.3.1",
"windows-sys 0.45.0",
] ]
[[package]] [[package]]
@ -837,7 +801,7 @@ checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.13", "syn 2.0.15",
] ]
[[package]] [[package]]
@ -900,9 +864,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.13" version = "2.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -918,7 +882,7 @@ dependencies = [
"cfg-if", "cfg-if",
"fastrand", "fastrand",
"redox_syscall 0.3.5", "redox_syscall 0.3.5",
"rustix 0.37.7", "rustix",
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
@ -1103,6 +1067,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets 0.48.0",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.45.0"

View File

@ -17,8 +17,7 @@ nix = { version = "0.26.2", default-features = false, features = [ "fs" ] }
serde = { version = "1.0.160", features = ["derive"] } serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96" serde_json = "1.0.96"
tempfile = "3.5.0" tempfile = "3.5.0"
# TODO: wait for a upstream release and pin it. bootspec = "0.1.0"
bootspec = { git = "https://github.com/DeterminateSystems/bootspec" }
walkdir = "2.3.3" walkdir = "2.3.3"
time = "0.3.20" time = "0.3.20"
sha2 = "0.10.6" sha2 = "0.10.6"

View File

@ -71,7 +71,7 @@ pub struct EspGenerationPaths {
impl EspGenerationPaths { impl EspGenerationPaths {
pub fn new(esp_paths: &EspPaths, generation: &Generation) -> Result<Self> { pub fn new(esp_paths: &EspPaths, generation: &Generation) -> Result<Self> {
let bootspec = &generation.spec.bootspec; let bootspec = &generation.spec.bootspec.bootspec;
Ok(Self { Ok(Self {
kernel: esp_paths kernel: esp_paths

View File

@ -4,8 +4,9 @@ use std::os::unix::fs::MetadataExt;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use bootspec::generation::Generation as BootspecGeneration; use bootspec::BootSpec;
use bootspec::BootJson; use bootspec::BootJson;
use bootspec::generation::Generation as BootspecGeneration;
use bootspec::SpecialisationName; use bootspec::SpecialisationName;
use time::Date; use time::Date;
@ -15,7 +16,7 @@ use time::Date;
/// easy if/when we have to do it. /// easy if/when we have to do it.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ExtendedBootJson { pub struct ExtendedBootJson {
pub bootspec: BootJson, pub bootspec: BootSpec,
} }
/// A system configuration. /// A system configuration.
@ -41,14 +42,16 @@ pub struct Generation {
impl Generation { impl Generation {
pub fn from_link(link: &GenerationLink) -> Result<Self> { pub fn from_link(link: &GenerationLink) -> Result<Self> {
let bootspec_path = link.path.join("boot.json"); let bootspec_path = link.path.join("boot.json");
let generation: BootspecGeneration = serde_json::from_slice( let boot_json: BootJson = serde_json::from_slice(
&fs::read(bootspec_path).context("Failed to read bootspec file")?, &fs::read(bootspec_path).context("Failed to read bootspec file")?,
) )
.context("Failed to parse bootspec json")?; .context("Failed to parse bootspec json")?;
let bootspec: BootJson = generation // TODO: replace me when https://github.com/DeterminateSystems/bootspec/pull/109 lands.
.try_into() let bootspec: BootSpec = match boot_json.generation {
.map_err(|err: &'static str| anyhow!(err))?; BootspecGeneration::V1(bootspec) => bootspec,
_ => return Err(anyhow!("Unsupported bootspec schema"))
};
Ok(Self { Ok(Self {
version: link.version, version: link.version,
@ -58,7 +61,7 @@ impl Generation {
}) })
} }
pub fn specialise(&self, name: &SpecialisationName, bootspec: &BootJson) -> Result<Self> { pub fn specialise(&self, name: &SpecialisationName, bootspec: &BootSpec) -> Result<Self> {
Ok(Self { Ok(Self {
version: self.version, version: self.version,
build_time: self.build_time, build_time: self.build_time,

View File

@ -208,7 +208,7 @@ impl Installer {
build_generation_artifacts(self, &generation, generation_artifacts) build_generation_artifacts(self, &generation, generation_artifacts)
.context("Failed to build generation artifacts.")?; .context("Failed to build generation artifacts.")?;
for (name, bootspec) in &generation.spec.bootspec.specialisation { for (name, bootspec) in &generation.spec.bootspec.specialisations {
let specialised_generation = generation.specialise(name, bootspec)?; let specialised_generation = generation.specialise(name, bootspec)?;
build_generation_artifacts(self, &specialised_generation, generation_artifacts) build_generation_artifacts(self, &specialised_generation, generation_artifacts)
@ -233,7 +233,7 @@ impl Installer {
) -> Result<()> { ) -> Result<()> {
let tempdir = &generation_artifacts.tempdir; let tempdir = &generation_artifacts.tempdir;
let bootspec = &generation.spec.bootspec; let bootspec = &generation.spec.bootspec.bootspec;
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?; let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?;
self.gc_roots.extend(esp_gen_paths.to_iter()); self.gc_roots.extend(esp_gen_paths.to_iter());
@ -279,7 +279,7 @@ impl Installer {
) -> Result<()> { ) -> Result<()> {
let tempdir = &generation_artifacts.tempdir; let tempdir = &generation_artifacts.tempdir;
let bootspec = &generation.spec.bootspec; let bootspec = &generation.spec.bootspec.bootspec;
let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?; let esp_gen_paths = EspGenerationPaths::new(&self.esp_paths, generation)?;

View File

@ -26,7 +26,7 @@ impl OsRelease {
// Because the ID field here does not have the same meaning as in a real os-release file, // Because the ID field here does not have the same meaning as in a real os-release file,
// it is fine to use a dummy value. // it is fine to use a dummy value.
map.insert("ID".into(), String::from("lanza")); map.insert("ID".into(), String::from("lanza"));
map.insert("PRETTY_NAME".into(), generation.spec.bootspec.label.clone()); map.insert("PRETTY_NAME".into(), generation.spec.bootspec.bootspec.label.clone());
map.insert("VERSION_ID".into(), generation.describe()); map.insert("VERSION_ID".into(), generation.describe());
Ok(Self(map)) Ok(Self(map))

View File

@ -39,7 +39,7 @@ pub fn setup_generation_link_from_toplevel(
version: u64, version: u64,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let bootspec = json!({ let bootspec = json!({
"v1": { "org.nixos.bootspec.v1": {
"init": format!("init-v{}", version), "init": format!("init-v{}", version),
"initrd": toplevel.join("initrd"), "initrd": toplevel.join("initrd"),
"kernel": toplevel.join("kernel"), "kernel": toplevel.join("kernel"),
@ -56,11 +56,8 @@ pub fn setup_generation_link_from_toplevel(
"label": "LanzaOS", "label": "LanzaOS",
"toplevel": toplevel, "toplevel": toplevel,
"system": "x86_64-linux", "system": "x86_64-linux",
"specialisation": {}, },
"extensions": { "org.nixos-community.lanzaboote": { "osRelease": toplevel.join("os-release") }
"lanzaboote": { "osRelease": toplevel.join("os-release") }
}
}
}); });
let generation_link_path = profiles_directory.join(format!("system-{}-link", version)); let generation_link_path = profiles_directory.join(format!("system-{}-link", version));