ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/

skip nonhive nixosconfigurations (#115)

authored by

marshmallow and committed by
GitHub
a8d83e6e 6356fc2e

+190 -4
+65 -2
Cargo.lock
··· 356 356 checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 357 357 358 358 [[package]] 359 + name = "fuchsia-cprng" 360 + version = "0.1.1" 361 + source = "registry+https://github.com/rust-lang/crates.io-index" 362 + checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 363 + 364 + [[package]] 359 365 name = "futures" 360 366 version = "0.3.31" 361 367 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 491 497 checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" 492 498 dependencies = [ 493 499 "bitmaps", 494 - "rand_core", 500 + "rand_core 0.6.4", 495 501 "rand_xoshiro", 496 502 "serde", 497 503 "sized-chunks", ··· 587 593 "serde-query", 588 594 "serde_json", 589 595 "serde_repr", 596 + "tempdir", 590 597 "thiserror", 591 598 "tokio", 592 599 "tracing", ··· 909 916 checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" 910 917 911 918 [[package]] 919 + name = "rand" 920 + version = "0.4.6" 921 + source = "registry+https://github.com/rust-lang/crates.io-index" 922 + checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" 923 + dependencies = [ 924 + "fuchsia-cprng", 925 + "libc", 926 + "rand_core 0.3.1", 927 + "rdrand", 928 + "winapi", 929 + ] 930 + 931 + [[package]] 932 + name = "rand_core" 933 + version = "0.3.1" 934 + source = "registry+https://github.com/rust-lang/crates.io-index" 935 + checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 936 + dependencies = [ 937 + "rand_core 0.4.2", 938 + ] 939 + 940 + [[package]] 941 + name = "rand_core" 942 + version = "0.4.2" 943 + source = "registry+https://github.com/rust-lang/crates.io-index" 944 + checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 945 + 946 + [[package]] 912 947 name = "rand_core" 913 948 version = "0.6.4" 914 949 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 920 955 source = "registry+https://github.com/rust-lang/crates.io-index" 921 956 checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" 922 957 dependencies = [ 923 - "rand_core", 958 + "rand_core 0.6.4", 959 + ] 960 + 961 + [[package]] 962 + name = "rdrand" 963 + version = "0.4.0" 964 + source = "registry+https://github.com/rust-lang/crates.io-index" 965 + checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 966 + dependencies = [ 967 + "rand_core 0.3.1", 924 968 ] 925 969 926 970 [[package]] ··· 966 1010 version = "0.8.5" 967 1011 source = "registry+https://github.com/rust-lang/crates.io-index" 968 1012 checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 1013 + 1014 + [[package]] 1015 + name = "remove_dir_all" 1016 + version = "0.5.3" 1017 + source = "registry+https://github.com/rust-lang/crates.io-index" 1018 + checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 1019 + dependencies = [ 1020 + "winapi", 1021 + ] 969 1022 970 1023 [[package]] 971 1024 name = "rustc-demangle" ··· 1158 1211 "proc-macro2", 1159 1212 "quote", 1160 1213 "unicode-ident", 1214 + ] 1215 + 1216 + [[package]] 1217 + name = "tempdir" 1218 + version = "0.3.7" 1219 + source = "registry+https://github.com/rust-lang/crates.io-index" 1220 + checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" 1221 + dependencies = [ 1222 + "rand", 1223 + "remove_dir_all", 1161 1224 ] 1162 1225 1163 1226 [[package]]
+1 -1
runtime/evaluate.nix
··· 28 28 "meta" 29 29 "defaults" 30 30 ] 31 - ) (builtins.attrNames mergedHive); 31 + ) (builtins.filter (name: builtins.hasAttr name hive) (builtins.attrNames mergedHive)); 32 32 33 33 resolvedNixpkgs = 34 34 if mergedHive.meta ? "nixpkgs" then
+1
tests/rust/flake_hive/flake.lock
··· 1 + ../../../flake.lock
+39
tests/rust/flake_hive/flake.nix
··· 1 + { 2 + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 3 + 4 + outputs = 5 + { nixpkgs, ... }@inputs: 6 + { 7 + colmena = { 8 + node-a = { }; 9 + node-b = { 10 + nixpkgs.hostPlatform = "x86_64-linux"; 11 + }; 12 + }; 13 + 14 + nixosConfigurations = { 15 + # non-hive nixosConfiguration 16 + # will fail to evaluate if this node is ever included 17 + # in the hive because this system does not specify 18 + # hostPlatform 19 + system-c = nixpkgs.lib.nixosSystem { 20 + system = "x86_64-linux"; 21 + specialArgs = { inherit inputs; }; 22 + modules = [ ]; 23 + }; 24 + 25 + # hive nixosConfiguration 26 + # its verified that these are merged because hostPlatform 27 + # must be specified, and its not specified in the hive 28 + node-a = nixpkgs.lib.nixosSystem { 29 + system = "x86_64-linux"; 30 + specialArgs = { inherit inputs; }; 31 + modules = [ 32 + { 33 + nixpkgs.hostPlatform = "x86_64-linux"; 34 + } 35 + ]; 36 + }; 37 + }; 38 + }; 39 + }
+3
wire/lib/Cargo.toml
··· 24 24 prost = { workspace = true } 25 25 gethostname = "1.0.2" 26 26 async-trait = "0.1.88" 27 + 28 + [dev-dependencies] 29 + tempdir = "0.3"
+26 -1
wire/lib/src/hive/mod.rs
··· 101 101 mod tests { 102 102 use im::vector; 103 103 104 - use crate::get_test_path; 104 + use crate::{get_test_path, test_support::make_flake_sandbox}; 105 105 106 106 use super::*; 107 107 use std::env; ··· 175 175 path.push("hive.nix"); 176 176 177 177 assert_eq!(hive, Hive { nodes, path }); 178 + } 179 + 180 + #[tokio::test] 181 + #[cfg_attr(feature = "no_web_tests", ignore)] 182 + async fn flake_hive() { 183 + let tmp_dir = make_flake_sandbox(&get_test_path!()).unwrap(); 184 + 185 + let hive = Hive::new_from_path(tmp_dir.path(), SubCommandModifiers::default()) 186 + .await 187 + .unwrap(); 188 + 189 + let mut nodes = HashMap::new(); 190 + 191 + // a merged node 192 + nodes.insert(Name("node-a".into()), Node::from_host("node-a")); 193 + // a non-merged node 194 + nodes.insert(Name("node-b".into()), Node::from_host("node-b")); 195 + // omit a node called system-c 196 + 197 + let mut path = tmp_dir.path().to_path_buf(); 198 + path.push("flake.nix"); 199 + 200 + assert_eq!(hive, Hive { nodes, path }); 201 + 202 + tmp_dir.close().unwrap(); 178 203 } 179 204 180 205 #[tokio::test]
+20
wire/lib/src/hive/node.rs
··· 42 42 } 43 43 } 44 44 45 + #[cfg(test)] 46 + impl Target { 47 + fn from_host(host: &str) -> Self { 48 + Target { 49 + host: host.into(), 50 + ..Default::default() 51 + } 52 + } 53 + } 54 + 45 55 #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Hash)] 46 56 pub struct Node { 47 57 #[serde(rename = "target")] ··· 73 83 allow_local_deployment: true, 74 84 build_remotely: false, 75 85 host_platform: "x86_64-linux".into(), 86 + } 87 + } 88 + } 89 + 90 + #[cfg(test)] 91 + impl Node { 92 + pub fn from_host(host: &str) -> Self { 93 + Node { 94 + target: Target::from_host(host), 95 + ..Default::default() 76 96 } 77 97 } 78 98 }
+5
wire/lib/src/lib.rs
··· 17 17 pub mod hive; 18 18 mod nix; 19 19 mod nix_log; 20 + 21 + #[cfg(test)] 20 22 mod test_macros; 23 + 24 + #[cfg(test)] 25 + mod test_support; 21 26 22 27 fn create_ssh_command(target: &Target, sudo: bool) -> Command { 23 28 let mut command = Command::new("ssh");
+30
wire/lib/src/test_support.rs
··· 1 + use std::{fs, io, path::Path, process::Command}; 2 + 3 + use tempdir::TempDir; 4 + 5 + pub fn make_flake_sandbox(path: &Path) -> Result<TempDir, io::Error> { 6 + let tmp_dir = TempDir::new("wire-test")?; 7 + 8 + Command::new("git") 9 + .args(["init", "-b", "tmp"]) 10 + .current_dir(tmp_dir.path()) 11 + .status()?; 12 + 13 + for entry in fs::read_dir(path)? { 14 + let entry = entry?; 15 + 16 + fs::copy(entry.path(), tmp_dir.as_ref().join(entry.file_name()))?; 17 + } 18 + 19 + Command::new("git") 20 + .args(["add", "-A"]) 21 + .current_dir(tmp_dir.path()) 22 + .status()?; 23 + 24 + Command::new("nix") 25 + .args(["flake", "lock"]) 26 + .current_dir(tmp_dir.path()) 27 + .status()?; 28 + 29 + Ok(tmp_dir) 30 + }