diff --git a/flake.lock b/flake.lock index af893ca..63b1c53 100644 --- a/flake.lock +++ b/flake.lock @@ -16,11 +16,11 @@ ] }, "locked": { - "lastModified": 1680584903, - "narHash": "sha256-uraq+D3jcLzw/UVk0xMHcnfILfIMa0DLrtAEq2nNlxU=", + "lastModified": 1681177078, + "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", "owner": "ipetkov", "repo": "crane", - "rev": "65d3f6a3970cd46bef5eedfd458300f72c56b3c5", + "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", "type": "github" }, "original": { @@ -66,12 +66,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "owner": "numtide", "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -103,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1682347030, - "narHash": "sha256-HYpAMGhF82mEaozCPz7FrHRCMJK5rOGA9Ed/kyszgmY=", + "lastModified": 1682741954, + "narHash": "sha256-RPZxzRu8XU0YD2WeYUFYzJy5yAvWUsxkuK+zWw+6WVk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8dd0f0a459b206fc4209570f6b7ce44ae66f264e", + "rev": "373e9eb4c42b2fc0611d794de5ea715a35d72393", "type": "github" }, "original": { @@ -148,11 +151,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1680981441, - "narHash": "sha256-Tqr2mCVssUVp1ZXXMpgYs9+ZonaWrZGPGltJz94FYi4=", + "lastModified": 1681413034, + "narHash": "sha256-/t7OjNQcNkeWeSq/CFLYVBfm+IEnkjoSm9iKvArnUUI=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2144d9ddcb550d6dce64a2b44facdc8c5ea2e28a", + "rev": "d3de8f69ca88fb6f8b09e5b598be5ac98d28ede5", "type": "github" }, "original": { @@ -194,6 +197,21 @@ "repo": "rust-overlay", "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", diff --git a/nix/tests/lanzaboote.nix b/nix/tests/lanzaboote.nix index eca724d..94b5afb 100644 --- a/nix/tests/lanzaboote.nix +++ b/nix/tests/lanzaboote.nix @@ -54,7 +54,7 @@ let return f'/boot/EFI/nixos/{store_dir}-{filename}.efi' 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!" src_path = ${path.src} dst_path = ${path.dst} diff --git a/rust/tool/Cargo.lock b/rust/tool/Cargo.lock index 38687b2..01870a9 100644 --- a/rust/tool/Cargo.lock +++ b/rust/tool/Cargo.lock @@ -17,7 +17,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" dependencies = [ - "anstyle 1.0.0", + "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", @@ -26,12 +26,6 @@ dependencies = [ "utf8parse", ] -[[package]] -name = "anstyle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" - [[package]] name = "anstyle" version = "1.0.0" @@ -62,7 +56,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" dependencies = [ - "anstyle 1.0.0", + "anstyle", "windows-sys 0.48.0", ] @@ -78,7 +72,7 @@ version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ - "anstyle 1.0.0", + "anstyle", "bstr", "doc-comment", "predicates", @@ -122,7 +116,8 @@ dependencies = [ [[package]] name = "bootspec" 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 = [ "serde", "serde_json", @@ -190,7 +185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" dependencies = [ "anstream", - "anstyle 1.0.0", + "anstyle", "bitflags", "clap_lex", "strsim", @@ -205,7 +200,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -232,15 +227,15 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -257,9 +252,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -269,9 +264,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -279,24 +274,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -333,17 +328,6 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "errno" version = "0.3.1" @@ -398,9 +382,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -408,9 +392,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -451,16 +435,16 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -490,25 +474,25 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "is-terminal" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.36.10", - "windows-sys 0.45.0", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -562,9 +546,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.140" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "link-cplusplus" @@ -577,15 +561,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "linux-raw-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c" [[package]] name = "log" @@ -653,11 +631,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "3.0.1" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba7d6ead3e3966038f68caa9fc1f860185d95a793180bbcfe0d0da47b3961ed" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ - "anstyle 0.3.5", + "anstyle", "difflib", "itertools", "predicates-core", @@ -753,30 +731,16 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "rustix" -version = "0.36.10" +version = "0.37.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778" +checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" dependencies = [ "bitflags", - "errno 0.2.8", + "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.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", + "linux-raw-sys", + "windows-sys 0.48.0", ] [[package]] @@ -837,7 +801,7 @@ checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -900,9 +864,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -918,7 +882,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.7", + "rustix", "windows-sys 0.45.0", ] @@ -1103,6 +1067,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "windows-sys" version = "0.45.0" diff --git a/rust/tool/Cargo.toml b/rust/tool/Cargo.toml index 83a6427..294191c 100644 --- a/rust/tool/Cargo.toml +++ b/rust/tool/Cargo.toml @@ -17,8 +17,7 @@ nix = { version = "0.26.2", default-features = false, features = [ "fs" ] } serde = { version = "1.0.160", features = ["derive"] } serde_json = "1.0.96" tempfile = "3.5.0" -# TODO: wait for a upstream release and pin it. -bootspec = { git = "https://github.com/DeterminateSystems/bootspec" } +bootspec = "0.1.0" walkdir = "2.3.3" time = "0.3.20" sha2 = "0.10.6" diff --git a/rust/tool/src/esp.rs b/rust/tool/src/esp.rs index 9e50e64..440c280 100644 --- a/rust/tool/src/esp.rs +++ b/rust/tool/src/esp.rs @@ -71,7 +71,7 @@ pub struct EspGenerationPaths { impl EspGenerationPaths { pub fn new(esp_paths: &EspPaths, generation: &Generation) -> Result { - let bootspec = &generation.spec.bootspec; + let bootspec = &generation.spec.bootspec.bootspec; Ok(Self { kernel: esp_paths diff --git a/rust/tool/src/generation.rs b/rust/tool/src/generation.rs index d5c5b5e..db0b9d5 100644 --- a/rust/tool/src/generation.rs +++ b/rust/tool/src/generation.rs @@ -4,8 +4,9 @@ use std::os::unix::fs::MetadataExt; use std::path::{Path, PathBuf}; use anyhow::{anyhow, Context, Result}; -use bootspec::generation::Generation as BootspecGeneration; +use bootspec::BootSpec; use bootspec::BootJson; +use bootspec::generation::Generation as BootspecGeneration; use bootspec::SpecialisationName; use time::Date; @@ -15,7 +16,7 @@ use time::Date; /// easy if/when we have to do it. #[derive(Debug, Clone)] pub struct ExtendedBootJson { - pub bootspec: BootJson, + pub bootspec: BootSpec, } /// A system configuration. @@ -41,14 +42,16 @@ pub struct Generation { impl Generation { pub fn from_link(link: &GenerationLink) -> Result { 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")?, ) .context("Failed to parse bootspec json")?; - let bootspec: BootJson = generation - .try_into() - .map_err(|err: &'static str| anyhow!(err))?; + // TODO: replace me when https://github.com/DeterminateSystems/bootspec/pull/109 lands. + let bootspec: BootSpec = match boot_json.generation { + BootspecGeneration::V1(bootspec) => bootspec, + _ => return Err(anyhow!("Unsupported bootspec schema")) + }; Ok(Self { version: link.version, @@ -58,7 +61,7 @@ impl Generation { }) } - pub fn specialise(&self, name: &SpecialisationName, bootspec: &BootJson) -> Result { + pub fn specialise(&self, name: &SpecialisationName, bootspec: &BootSpec) -> Result { Ok(Self { version: self.version, build_time: self.build_time, diff --git a/rust/tool/src/install.rs b/rust/tool/src/install.rs index b133b5b..a827d42 100644 --- a/rust/tool/src/install.rs +++ b/rust/tool/src/install.rs @@ -208,7 +208,7 @@ impl Installer { build_generation_artifacts(self, &generation, 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)?; build_generation_artifacts(self, &specialised_generation, generation_artifacts) @@ -233,7 +233,7 @@ impl Installer { ) -> Result<()> { 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)?; self.gc_roots.extend(esp_gen_paths.to_iter()); @@ -279,7 +279,7 @@ impl Installer { ) -> Result<()> { 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)?; diff --git a/rust/tool/src/os_release.rs b/rust/tool/src/os_release.rs index 1d05917..845b948 100644 --- a/rust/tool/src/os_release.rs +++ b/rust/tool/src/os_release.rs @@ -26,7 +26,7 @@ impl OsRelease { // 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. 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()); Ok(Self(map)) diff --git a/rust/tool/tests/common/mod.rs b/rust/tool/tests/common/mod.rs index 7980d8e..e650a79 100644 --- a/rust/tool/tests/common/mod.rs +++ b/rust/tool/tests/common/mod.rs @@ -39,7 +39,7 @@ pub fn setup_generation_link_from_toplevel( version: u64, ) -> Result { let bootspec = json!({ - "v1": { + "org.nixos.bootspec.v1": { "init": format!("init-v{}", version), "initrd": toplevel.join("initrd"), "kernel": toplevel.join("kernel"), @@ -56,11 +56,8 @@ pub fn setup_generation_link_from_toplevel( "label": "LanzaOS", "toplevel": toplevel, "system": "x86_64-linux", - "specialisation": {}, - "extensions": { - "lanzaboote": { "osRelease": toplevel.join("os-release") } - } - } + }, + "org.nixos-community.lanzaboote": { "osRelease": toplevel.join("os-release") } }); let generation_link_path = profiles_directory.join(format!("system-{}-link", version));