forked from lix-project/lix-installer
Fix various bugs in the tests such that Lix works now
- We were looking for a top-level tarball path that looked like nix-*.
This was invalid, since our tarballs have lix-*.
- We were looking for a store path that looked like nix-*.*.*. This was
invalid, since ours is lix-*.*.*.
This change accepts both.
- We also added a symlink for nix-installer and nix-installer.sh, which
deals with the test suite being pretty tightly coupled to that path.
- We fixed a bug exposed in the tests where --no-substitute is not
passed while self-testing builds. This seems to have been relying on
offline detection and while it eventually passed, it was busted and
took ages.
Change-Id: I2f497bd647ecf1db5963a4bb245279db582d2af3
This commit is contained in:
parent
4a4f16676d
commit
0256e915e7
|
@ -95,6 +95,8 @@
|
|||
};
|
||||
postInstall = ''
|
||||
cp lix-installer.sh $out/bin/lix-installer.sh
|
||||
ln -s lix-installer $out/bin/nix-installer
|
||||
ln -s lix-installer.sh $out/bin/nix-installer.sh
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
|
|
@ -2,7 +2,7 @@ FROM default
|
|||
COPY lix-installer /lix-installer
|
||||
RUN chmod +x /lix-installer
|
||||
COPY binary-tarball /binary-tarball
|
||||
RUN mv /binary-tarball/nix-*.tar.xz nix.tar.xz
|
||||
RUN mv /binary-tarball/[nl]ix-*.tar.xz nix.tar.xz
|
||||
RUN /lix-installer/bin/lix-installer install linux --logger pretty --log-directive lix_installer=debug --nix-package-url file:///nix.tar.xz --init none --extra-conf "sandbox = false" --no-confirm -vvv
|
||||
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
|
||||
RUN nix-build --no-substitute -E 'derivation { name = "foo"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo foobar > $out"]; }'
|
||||
|
|
|
@ -576,7 +576,7 @@ let
|
|||
scp -P 20022 $ssh_opts $installer/bin/lix-installer vagrant@localhost:nix-installer
|
||||
|
||||
echo "Copying nix tarball..."
|
||||
scp -P 20022 $ssh_opts $binaryTarball/nix-*.tar.xz vagrant@localhost:nix.tar.xz
|
||||
scp -P 20022 $ssh_opts $binaryTarball/lix-*.tar.xz vagrant@localhost:nix.tar.xz
|
||||
|
||||
echo "Running preinstall..."
|
||||
$ssh "set -eux; $preinstallScript"
|
||||
|
|
|
@ -6,8 +6,9 @@ use std::{
|
|||
use tracing::{span, Span};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::action::{
|
||||
Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction,
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionError, ActionErrorKind, ActionTag, StatefulAction},
|
||||
release_tarball,
|
||||
};
|
||||
|
||||
pub(crate) const DEST: &str = "/nix/";
|
||||
|
@ -62,15 +63,9 @@ impl Action for MoveUnpackedNix {
|
|||
let Self { unpacked_path } = self;
|
||||
|
||||
// This is the `nix-$VERSION` folder which unpacks from the tarball, not a nix derivation
|
||||
let found_nix_paths = glob::glob(&format!("{}/nix-*", unpacked_path.display()))
|
||||
.map_err(|e| Self::error(MoveUnpackedNixError::from(e)))?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| Self::error(MoveUnpackedNixError::from(e)))?;
|
||||
if found_nix_paths.len() != 1 {
|
||||
return Err(Self::error(ActionErrorKind::MalformedBinaryTarball));
|
||||
}
|
||||
let found_nix_path = found_nix_paths.into_iter().next().unwrap();
|
||||
let src_store = found_nix_path.join("store");
|
||||
let toplevel_path =
|
||||
release_tarball::find_toplevel_path(&unpacked_path).map_err(Self::error)?;
|
||||
let src_store = toplevel_path.join("store");
|
||||
let mut src_store_listing = tokio::fs::read_dir(src_store.clone())
|
||||
.await
|
||||
.map_err(|e| ActionErrorKind::ReadDir(src_store.clone(), e))
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::PathBuf;
|
|||
|
||||
use crate::{
|
||||
action::{ActionError, ActionErrorKind, ActionTag, StatefulAction},
|
||||
execute_command, set_env,
|
||||
execute_command, release_tarball, set_env,
|
||||
};
|
||||
|
||||
use glob::glob;
|
||||
|
@ -51,8 +51,10 @@ impl Action for SetupDefaultProfile {
|
|||
|
||||
#[tracing::instrument(level = "debug", skip_all)]
|
||||
async fn execute(&mut self) -> Result<(), ActionError> {
|
||||
// Find an `nix` package
|
||||
let nix_pkg_glob = format!("{}/nix-*/store/*-nix-*.*.*", self.unpacked_path.display());
|
||||
let toplevel_path =
|
||||
release_tarball::find_toplevel_path(&self.unpacked_path).map_err(Self::error)?;
|
||||
// Find a `nix` package
|
||||
let nix_pkg_glob = format!("{}/store/*-[nl]ix-*.*.*", toplevel_path.display());
|
||||
let mut found_nix_pkg = None;
|
||||
for entry in glob(&nix_pkg_glob).map_err(Self::error)? {
|
||||
match entry {
|
||||
|
@ -78,10 +80,7 @@ impl Action for SetupDefaultProfile {
|
|||
};
|
||||
|
||||
// Find an `nss-cacert` package, add it too.
|
||||
let nss_ca_cert_pkg_glob = format!(
|
||||
"{}/nix-*/store/*-nss-cacert-*.*",
|
||||
self.unpacked_path.display()
|
||||
);
|
||||
let nss_ca_cert_pkg_glob = format!("{}/store/*-nss-cacert-*.*", toplevel_path.display());
|
||||
let mut found_nss_ca_cert_pkg = None;
|
||||
for entry in glob(&nss_ca_cert_pkg_glob).map_err(Self::error)? {
|
||||
match entry {
|
||||
|
@ -108,14 +107,8 @@ impl Action for SetupDefaultProfile {
|
|||
return Err(Self::error(SetupDefaultProfileError::NoNssCacert));
|
||||
};
|
||||
|
||||
let found_nix_paths = glob::glob(&format!("{}/nix-*", self.unpacked_path.display()))
|
||||
.map_err(Self::error)?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(Self::error)?;
|
||||
if found_nix_paths.len() != 1 {
|
||||
return Err(Self::error(ActionErrorKind::MalformedBinaryTarball));
|
||||
}
|
||||
let found_nix_path = found_nix_paths.into_iter().next().unwrap();
|
||||
let found_nix_path =
|
||||
release_tarball::find_toplevel_path(&self.unpacked_path).map_err(Self::error)?;
|
||||
let reginfo_path = found_nix_path.join(".reginfo");
|
||||
let reginfo = tokio::fs::read(®info_path)
|
||||
.await
|
||||
|
|
|
@ -488,10 +488,7 @@ pub enum ActionErrorKind {
|
|||
"".to_string()
|
||||
}
|
||||
)]
|
||||
CommandOutput {
|
||||
command: String,
|
||||
output: Output,
|
||||
},
|
||||
CommandOutput { command: String, output: Output },
|
||||
#[error("Joining spawned async task")]
|
||||
Join(
|
||||
#[source]
|
||||
|
@ -509,7 +506,7 @@ pub enum ActionErrorKind {
|
|||
/// A MacOS (Darwin) plist related error
|
||||
#[error(transparent)]
|
||||
Plist(#[from] plist::Error),
|
||||
#[error("Unexpected binary tarball contents found, the build result from `https://releases.nixos.org/?prefix=nix/` or `nix build nix#hydraJobs.binaryTarball.$SYSTEM` is expected")]
|
||||
#[error("Unexpected binary tarball contents found, the build result from `https://releases.lix.systems/?prefix=nix/` or `nix build lix#hydraJobs.binaryTarball.$SYSTEM` is expected")]
|
||||
MalformedBinaryTarball,
|
||||
#[error("Could not find `{0}` in PATH; This action only works on SteamOS, which should have this present in PATH.")]
|
||||
MissingSteamosBinary(String),
|
||||
|
|
|
@ -20,9 +20,9 @@ pub trait CommandExecute {
|
|||
}
|
||||
|
||||
/**
|
||||
The Determinate Nix installer (lix variant)
|
||||
The Lix installer.
|
||||
|
||||
A fast, friendly, and reliable tool to help you use Nix with Flakes everywhere.
|
||||
A fast, friendly, and reliable tool to help you install CppNix or Lix on your system.
|
||||
*/
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(version)]
|
||||
|
|
|
@ -76,6 +76,7 @@ mod error;
|
|||
mod os;
|
||||
mod plan;
|
||||
pub mod planner;
|
||||
mod release_tarball;
|
||||
pub mod self_test;
|
||||
pub mod settings;
|
||||
|
||||
|
|
17
src/release_tarball.rs
Normal file
17
src/release_tarball.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::action::ActionErrorKind;
|
||||
|
||||
/// Finds the top-level path in the tarball, e.g. lix-2.90.0-rc1-x86_64-linux
|
||||
pub fn find_toplevel_path(unpacked_path: &Path) -> Result<PathBuf, ActionErrorKind> {
|
||||
let found_nix_paths = glob::glob(&format!("{}/[nl]ix-*", unpacked_path.display()))
|
||||
.map_err(ActionErrorKind::from)?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(ActionErrorKind::from)?;
|
||||
if found_nix_paths.len() != 1 {
|
||||
return Err(ActionErrorKind::MalformedBinaryTarball);
|
||||
}
|
||||
let found_nix_path = found_nix_paths.into_iter().next().unwrap();
|
||||
|
||||
Ok(found_nix_path)
|
||||
}
|
|
@ -86,7 +86,7 @@ impl Shell {
|
|||
.as_millis();
|
||||
|
||||
command.arg(format!(
|
||||
r#"nix build --no-link --expr 'derivation {{ name = "self-test-{executable}-{timestamp_millis}"; system = "{SYSTEM}"; builder = "/bin/sh"; args = ["-c" "echo hello > \$out"]; }}'"#
|
||||
r#"nix build --no-substitute --no-link --expr 'derivation {{ name = "self-test-{executable}-{timestamp_millis}"; system = "{SYSTEM}"; builder = "/bin/sh"; args = ["-c" "echo hello > \$out"]; }}'"#
|
||||
));
|
||||
let command_str = format!("{:?}", command.as_std());
|
||||
|
||||
|
|
Loading…
Reference in a new issue