Fix ubuntu 16.04 support (#140)

* Fix ubuntu 16.04 support

* Format

* Correct env settings

* Rearrange plan a bit
This commit is contained in:
Ana Hobden 2022-12-23 13:24:06 -08:00 committed by GitHub
parent 3706bd387a
commit deee222ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 49 additions and 51 deletions

View file

@ -17,6 +17,7 @@ let
images = { images = {
# End of standard support https://wiki.ubuntu.com/Releases # End of standard support https://wiki.ubuntu.com/Releases
# No systemd
/* /*
"ubuntu-v14_04" = { "ubuntu-v14_04" = {
image = import <nix/fetchurl.nix> { image = import <nix/fetchurl.nix> {
@ -29,15 +30,14 @@ let
*/ */
# End of standard support https://wiki.ubuntu.com/Releases # End of standard support https://wiki.ubuntu.com/Releases
/* "ubuntu-v16_04" = { "ubuntu-v16_04" = {
image = import <nix/fetchurl.nix> { image = import <nix/fetchurl.nix> {
url = "https://app.vagrantup.com/generic/boxes/ubuntu1604/versions/4.1.12/providers/libvirt.box"; url = "https://app.vagrantup.com/generic/boxes/ubuntu1604/versions/4.1.12/providers/libvirt.box";
hash = "sha256-lO4oYQR2tCh5auxAYe6bPOgEqOgv3Y3GC1QM1tEEEU8="; hash = "sha256-lO4oYQR2tCh5auxAYe6bPOgEqOgv3Y3GC1QM1tEEEU8=";
}; };
rootDisk = "box.img"; rootDisk = "box.img";
system = "x86_64-linux"; system = "x86_64-linux";
}; };
*/
"ubuntu-v22_04" = { "ubuntu-v22_04" = {
image = import <nix/fetchurl.nix> { image = import <nix/fetchurl.nix> {
@ -67,6 +67,7 @@ let
hash = "sha256-QwzbvRoRRGqUCQptM7X/InRWFSP2sqwRt2HaaO6zBGM="; hash = "sha256-QwzbvRoRRGqUCQptM7X/InRWFSP2sqwRt2HaaO6zBGM=";
}; };
rootDisk = "box.img"; rootDisk = "box.img";
postBoot = disableSELinux;
system = "x86_64-linux"; system = "x86_64-linux";
}; };
*/ */

View file

@ -1,13 +1,13 @@
//! Base [`Action`](crate::action::Action)s that themselves have no other actions as dependencies //! Base [`Action`](crate::action::Action)s that themselves have no other actions as dependencies
mod create_directory; pub(crate) mod create_directory;
mod create_file; pub(crate) mod create_file;
mod create_group; pub(crate) mod create_group;
mod create_or_append_file; pub(crate) mod create_or_append_file;
mod create_user; pub(crate) mod create_user;
mod fetch_and_unpack_nix; pub(crate) mod fetch_and_unpack_nix;
mod move_unpacked_nix; pub(crate) mod move_unpacked_nix;
mod setup_default_profile; pub(crate) mod setup_default_profile;
pub use create_directory::CreateDirectory; pub use create_directory::CreateDirectory;
pub use create_file::CreateFile; pub use create_file::CreateFile;

View file

@ -1,8 +1,10 @@
use crate::{ use crate::{
action::{ action::{
base::SetupDefaultProfile, base::SetupDefaultProfile,
common::{ConfigureShellProfile, PlaceChannelConfiguration, PlaceNixConfiguration}, common::{
linux::ConfigureNixDaemonService, ConfigureNixDaemonService, ConfigureShellProfile, PlaceChannelConfiguration,
PlaceNixConfiguration,
},
Action, ActionDescription, ActionError, StatefulAction, Action, ActionDescription, ActionError, StatefulAction,
}, },
channel_value::ChannelValue, channel_value::ChannelValue,

View file

@ -156,7 +156,7 @@ impl Action for ConfigureNixDaemonService {
.process_group(0) .process_group(0)
.arg("enable") .arg("enable")
.arg("--now") .arg("--now")
.arg("nix-daemon.socket"), .arg(SOCKET_SRC),
) )
.await .await
.map_err(ActionError::Command)?; .map_err(ActionError::Command)?;

View file

@ -1,14 +1,16 @@
//! [`Action`](crate::action::Action)s which only call other base plugins //! [`Action`](crate::action::Action)s which only call other base plugins
mod configure_nix; pub(crate) mod configure_nix;
mod configure_shell_profile; pub(crate) mod configure_nix_daemon_service;
mod create_nix_tree; pub(crate) mod configure_shell_profile;
mod create_users_and_groups; pub(crate) mod create_nix_tree;
mod place_channel_configuration; pub(crate) mod create_users_and_groups;
mod place_nix_configuration; pub(crate) mod place_channel_configuration;
mod provision_nix; pub(crate) mod place_nix_configuration;
pub(crate) mod provision_nix;
pub use configure_nix::ConfigureNix; pub use configure_nix::ConfigureNix;
pub use configure_nix_daemon_service::{ConfigureNixDaemonService, ConfigureNixDaemonServiceError};
pub use configure_shell_profile::ConfigureShellProfile; pub use configure_shell_profile::ConfigureShellProfile;
pub use create_nix_tree::CreateNixTree; pub use create_nix_tree::CreateNixTree;
pub use create_users_and_groups::CreateUsersAndGroups; pub use create_users_and_groups::CreateUsersAndGroups;

View file

@ -1,14 +1,14 @@
/*! [`Action`](crate::action::Action)s for Darwin based systems /*! [`Action`](crate::action::Action)s for Darwin based systems
*/ */
mod bootstrap_apfs_volume; pub(crate) mod bootstrap_apfs_volume;
mod create_apfs_volume; pub(crate) mod create_apfs_volume;
mod create_nix_volume; pub(crate) mod create_nix_volume;
mod create_synthetic_objects; pub(crate) mod create_synthetic_objects;
mod enable_ownership; pub(crate) mod enable_ownership;
mod encrypt_apfs_volume; pub(crate) mod encrypt_apfs_volume;
mod kickstart_launchctl_service; pub(crate) mod kickstart_launchctl_service;
mod unmount_apfs_volume; pub(crate) mod unmount_apfs_volume;
pub use bootstrap_apfs_volume::{BootstrapApfsVolume, BootstrapVolumeError}; pub use bootstrap_apfs_volume::{BootstrapApfsVolume, BootstrapVolumeError};
pub use create_apfs_volume::{CreateApfsVolume, CreateVolumeError}; pub use create_apfs_volume::{CreateApfsVolume, CreateVolumeError};

View file

@ -1,5 +1,3 @@
mod configure_nix_daemon_service; pub(crate) mod start_systemd_unit;
mod start_systemd_unit;
pub use configure_nix_daemon_service::{ConfigureNixDaemonService, ConfigureNixDaemonServiceError};
pub use start_systemd_unit::{StartSystemdUnit, StartSystemdUnitError}; pub use start_systemd_unit::{StartSystemdUnit, StartSystemdUnitError};

View file

@ -32,8 +32,8 @@ action.try_revert().await.unwrap();
``` ```
A general guidance for what determines how fine-grained an [`Action`] should be is the unit of A general guidance for what determines how fine-grained an [`Action`] should be is the unit of
reversion. The [`ConfigureNixDaemonService`](linux::ConfigureNixDaemonService) action is a good reversion. The [`ConfigureNixDaemonService`](common::ConfigureNixDaemonService) action is a good
example of this,it takes several steps, such as running `systemd-tmpfiles`, and calling example of this, it takes several steps, such as running `systemd-tmpfiles`, and calling
`systemctl link` on some systemd units. `systemctl link` on some systemd units.
Where possible, tasks which could break during execution should be broken up, as uninstalling/installing Where possible, tasks which could break during execution should be broken up, as uninstalling/installing

View file

@ -99,7 +99,7 @@ pub fn ensure_root() -> eyre::Result<()> {
arg_vec_cstring.push(sudo_cstring.clone()); arg_vec_cstring.push(sudo_cstring.clone());
let mut preserve_env_list = vec![]; let mut preserve_env_list = vec![];
for (key, _value) in std::env::vars() { for (key, value) in std::env::vars() {
let preserve = match key.as_str() { let preserve = match key.as_str() {
// Rust logging/backtrace bits we use // Rust logging/backtrace bits we use
"RUST_LOG" | "RUST_BACKTRACE" => true, "RUST_LOG" | "RUST_BACKTRACE" => true,
@ -110,15 +110,19 @@ pub fn ensure_root() -> eyre::Result<()> {
_ => false, _ => false,
}; };
if preserve { if preserve {
preserve_env_list.push(key); preserve_env_list.push(format!("{key}={value}"));
} }
} }
if !preserve_env_list.is_empty() { if !preserve_env_list.is_empty() {
arg_vec_cstring.push( arg_vec_cstring
CString::new(format!("--preserve-env={}", preserve_env_list.join(","))) .push(CString::new("env").wrap_err("Building a `env` argument for `sudo`")?);
.wrap_err("Building a `--preserve-env` argument for `sudo`")?, for env in preserve_env_list {
); arg_vec_cstring.push(
CString::new(env.clone())
.wrap_err_with(|| format!("Building a `{}` argument for `sudo`", env))?,
);
}
} }
for arg in args { for arg in args {

View file

@ -2,7 +2,6 @@ use crate::{
action::{ action::{
base::CreateDirectory, base::CreateDirectory,
common::{ConfigureNix, ProvisionNix}, common::{ConfigureNix, ProvisionNix},
linux::StartSystemdUnit,
StatefulAction, StatefulAction,
}, },
planner::{Planner, PlannerError}, planner::{Planner, PlannerError},
@ -78,10 +77,6 @@ impl Planner for LinuxMulti {
.await .await
.map_err(PlannerError::Action)? .map_err(PlannerError::Action)?
.boxed(), .boxed(),
StartSystemdUnit::plan("nix-daemon.socket".to_string())
.await
.map_err(|v| PlannerError::Action(v.into()))?
.boxed(),
]) ])
} }

View file

@ -223,10 +223,6 @@ impl Planner for SteamDeck {
.await .await
.map_err(PlannerError::Action)? .map_err(PlannerError::Action)?
.boxed(), .boxed(),
StartSystemdUnit::plan("nix-daemon.socket".to_string())
.await
.map_err(PlannerError::Action)?
.boxed(),
]) ])
} }