diff --git a/src/image_builder.rs b/src/image_builder.rs index c1688fb..fed146e 100644 --- a/src/image_builder.rs +++ b/src/image_builder.rs @@ -26,15 +26,13 @@ use tempfile::tempdir; use crate::nixos; use crate::shell::*; -const NIX_VERSION: &str = "2.28.3"; - const NIX_CONF: &str = formatcp!( "experimental-features = nix-command flakes extra-nix-path = nixpkgs=github:nixos/nixpkgs/nixos-{} build-users-group = sandbox = false ", - nixos::NIXOS_VERSION + crate::NIXOS_VERSION ); static BASE_SHA256: &str = "/nix/.base.sha256"; @@ -464,8 +462,8 @@ where let nix_store = dest.join("store"); if !nix_store.exists() { log::info!("installing Nix in {}", dest.display()); - let nix_url = nix_installer_url(NIX_VERSION, arch); - download_and_install_nix(NIX_VERSION, arch, &nix_url, dest)?; + let nix_url = nix_installer_url(crate::NIX_VERSION, arch); + download_and_install_nix(crate::NIX_VERSION, arch, &nix_url, dest)?; } let nix_bin = dest.join(".bin"); @@ -473,7 +471,7 @@ where fs::create_dir_all(&gcroots)?; if !symlink_exists(&nix_bin) { - let nix_store_path = find_nix(&nix_store, NIX_VERSION)?; + let nix_store_path = find_nix(&nix_store, crate::NIX_VERSION)?; let nix_path = Path::new("/nix/store").join(nix_store_path); symlink(nix_path.join("bin"), nix_bin).unwrap(); symlink(&nix_path, gcroots.join("nix")).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 60c4dd2..e34bfb3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,9 @@ mod embedded_image; mod pid_file; +pub(crate) const NIX_VERSION: &str = "2.28.3"; +pub(crate) const NIXOS_VERSION: &str = "25.05"; + pub(crate) const CACHE_HOME: &str = "/nix/.cache"; pub(crate) const CONFIG_HOME: &str = "/nix/.config"; diff --git a/src/nixos.rs b/src/nixos.rs index ce1e5a3..188b81d 100644 --- a/src/nixos.rs +++ b/src/nixos.rs @@ -8,8 +8,6 @@ use std::{ use anyhow::{bail, Context, Result}; use regex::Regex; -pub(crate) const NIXOS_VERSION: &str = "25.05"; - pub(crate) const ENV_VARS: [(&str, &str); 4] = [ ("PATH", "/nix/.bin"), ("NIX_CONF_DIR", "/nix/etc"), @@ -78,7 +76,7 @@ pub fn build_flake_from_package_list( match &caps[1] { "name" => name, "description" => description, - "version" => NIXOS_VERSION, + "version" => crate::NIXOS_VERSION, "packages" => &package_list, _ => "", }