From 9c179b0db8013a2e6704104d95cf10c5b09cbfef Mon Sep 17 00:00:00 2001 From: Glenn McDonald <2371316+glenn-m@users.noreply.github.com> Date: Mon, 7 Mar 2022 23:52:22 -0500 Subject: [PATCH] apply_local: Fix nixos detection from os-release (#63) --- src/command/apply_local.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/command/apply_local.rs b/src/command/apply_local.rs index a789b53..c284b69 100644 --- a/src/command/apply_local.rs +++ b/src/command/apply_local.rs @@ -1,4 +1,5 @@ use std::env; +use regex::Regex; use std::collections::HashMap; use clap::{Arg, App, ArgMatches}; @@ -61,7 +62,8 @@ By default, Colmena will deploy keys set in `deployment.keys` before activating pub async fn run(_global_args: &ArgMatches, local_args: &ArgMatches) -> Result<(), ColmenaError> { // Sanity check: Are we running NixOS? if let Ok(os_release) = fs::read_to_string("/etc/os-release").await { - if !os_release.contains("ID=nixos\n") { + let re = Regex::new(r#"ID="?nixos"?"#).unwrap(); + if !re.is_match(&os_release) { log::error!("\"apply-local\" only works on NixOS machines."); quit::with_code(5); }