Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/image_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -464,16 +462,16 @@ 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");
let gcroots = dest.join("var/nix/gcroots");
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();
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 1 addition & 3 deletions src/nixos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
_ => "",
}
Expand Down