forked from lix-project/lix-installer
Restructure common actions into common and base
Base actions are those that don't depend on another action to execute. They mostly map to "very simple" OS operations like creating a directory or user. Base actions MUST be multi-platform compatible. Common actions may then use any set of base actions or other common actions. Base actions MUST NOT depend on other base actions.
This commit is contained in:
parent
706ecccaa3
commit
e98827d5ae
22
src/action/base/mod.rs
Normal file
22
src/action/base/mod.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! Base actions that themselves have no other actions as dependencies
|
||||
|
||||
mod configure_nix_daemon_service;
|
||||
mod create_directory;
|
||||
mod create_file;
|
||||
mod create_group;
|
||||
mod create_or_append_file;
|
||||
mod create_user;
|
||||
mod fetch_nix;
|
||||
mod move_unpacked_nix;
|
||||
mod setup_default_profile;
|
||||
|
||||
pub use configure_nix_daemon_service::{ConfigureNixDaemonService, ConfigureNixDaemonServiceError};
|
||||
pub use create_directory::{CreateDirectory, CreateDirectoryError};
|
||||
pub use create_file::{CreateFile, CreateFileError};
|
||||
pub use create_group::{CreateGroup, CreateGroupError};
|
||||
pub use create_or_append_file::{CreateOrAppendFile, CreateOrAppendFileError};
|
||||
pub use create_user::{CreateUser, CreateUserError};
|
||||
pub use fetch_nix::{FetchNix, FetchNixError};
|
||||
pub use move_unpacked_nix::{MoveUnpackedNix, MoveUnpackedNixError};
|
||||
pub use setup_default_profile::{SetupDefaultProfile, SetupDefaultProfileError};
|
||||
|
|
@ -1,17 +1,15 @@
|
|||
use reqwest::Url;
|
||||
|
||||
use crate::{
|
||||
action::{
|
||||
common::{
|
||||
ConfigureNixDaemonService, ConfigureShellProfile, PlaceChannelConfiguration,
|
||||
PlaceNixConfiguration, SetupDefaultProfile,
|
||||
},
|
||||
base::{ConfigureNixDaemonService, SetupDefaultProfile},
|
||||
common::{ConfigureShellProfile, PlaceChannelConfiguration, PlaceNixConfiguration},
|
||||
Action, ActionDescription, ActionState,
|
||||
},
|
||||
channel_value::ChannelValue,
|
||||
BoxableError, CommonSettings,
|
||||
};
|
||||
|
||||
use reqwest::Url;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct ConfigureNix {
|
||||
setup_default_profile: SetupDefaultProfile,
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use crate::action::base::{CreateOrAppendFile, CreateOrAppendFileError};
|
||||
use crate::action::{Action, ActionDescription, ActionState};
|
||||
use crate::BoxableError;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use tokio::task::{JoinError, JoinSet};
|
||||
|
||||
use crate::action::common::{CreateOrAppendFile, CreateOrAppendFileError};
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionState},
|
||||
BoxableError,
|
||||
};
|
||||
|
||||
const PROFILE_TARGETS: &[&str] = &[
|
||||
"/etc/bashrc",
|
||||
"/etc/profile.d/nix.sh",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::action::common::{CreateDirectory, CreateDirectoryError};
|
||||
use crate::action::base::{CreateDirectory, CreateDirectoryError};
|
||||
use crate::action::{Action, ActionDescription, ActionState};
|
||||
|
||||
const PATHS: &[&str] = &[
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
use tokio::task::{JoinError, JoinSet};
|
||||
|
||||
use crate::CommonSettings;
|
||||
|
||||
use crate::{
|
||||
action::{
|
||||
common::{CreateGroup, CreateGroupError, CreateUser, CreateUserError},
|
||||
base::{CreateGroup, CreateGroupError, CreateUser, CreateUserError},
|
||||
Action, ActionDescription, ActionState,
|
||||
},
|
||||
BoxableError,
|
||||
};
|
||||
use tokio::task::{JoinError, JoinSet};
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct CreateUsersAndGroup {
|
||||
|
|
|
@ -1,35 +1,17 @@
|
|||
/*! Actions which only call other base plugins. */
|
||||
|
||||
mod configure_nix;
|
||||
mod configure_nix_daemon_service;
|
||||
mod configure_shell_profile;
|
||||
mod create_directory;
|
||||
mod create_file;
|
||||
mod create_group;
|
||||
mod create_nix_tree;
|
||||
mod create_or_append_file;
|
||||
mod create_user;
|
||||
mod configure_shell_profile;
|
||||
mod create_users_and_group;
|
||||
mod fetch_nix;
|
||||
mod move_unpacked_nix;
|
||||
mod place_channel_configuration;
|
||||
mod place_nix_configuration;
|
||||
mod provision_nix;
|
||||
mod setup_default_profile;
|
||||
|
||||
pub use configure_nix::ConfigureNix;
|
||||
pub use configure_nix_daemon_service::{ConfigureNixDaemonService, ConfigureNixDaemonServiceError};
|
||||
pub use configure_shell_profile::ConfigureShellProfile;
|
||||
pub use create_directory::{CreateDirectory, CreateDirectoryError};
|
||||
pub use create_file::{CreateFile, CreateFileError};
|
||||
pub use create_group::{CreateGroup, CreateGroupError};
|
||||
pub use create_nix_tree::{CreateNixTree, CreateNixTreeError};
|
||||
pub use create_or_append_file::{CreateOrAppendFile, CreateOrAppendFileError};
|
||||
pub use create_user::{CreateUser, CreateUserError};
|
||||
pub use create_users_and_group::{CreateUsersAndGroup, CreateUsersAndGroupError};
|
||||
pub use fetch_nix::{FetchNix, FetchNixError};
|
||||
pub use move_unpacked_nix::{MoveUnpackedNix, MoveUnpackedNixError};
|
||||
pub use place_channel_configuration::{PlaceChannelConfiguration, PlaceChannelConfigurationError};
|
||||
pub use place_nix_configuration::{PlaceNixConfiguration, PlaceNixConfigurationError};
|
||||
pub use provision_nix::{ProvisionNix, ProvisionNixError};
|
||||
pub use setup_default_profile::{SetupDefaultProfile, SetupDefaultProfileError};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use reqwest::Url;
|
||||
|
||||
use crate::action::base::{CreateFile, CreateFileError};
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionState},
|
||||
BoxableError,
|
||||
};
|
||||
|
||||
use crate::action::common::{CreateFile, CreateFileError};
|
||||
use reqwest::Url;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct PlaceChannelConfiguration {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::action::base::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||
use crate::action::{Action, ActionDescription, ActionState};
|
||||
|
||||
use crate::action::common::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||
|
||||
const NIX_CONF_FOLDER: &str = "/etc/nix";
|
||||
const NIX_CONF: &str = "/etc/nix/nix.conf";
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use tokio::task::JoinError;
|
||||
|
||||
use crate::action::common::{
|
||||
use crate::action::base::{
|
||||
CreateDirectoryError, FetchNix, FetchNixError, MoveUnpackedNix, MoveUnpackedNixError,
|
||||
};
|
||||
use crate::CommonSettings;
|
||||
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionState},
|
||||
BoxableError,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
use tokio::task::JoinError;
|
||||
|
||||
use super::{CreateNixTree, CreateNixTreeError, CreateUsersAndGroup, CreateUsersAndGroupError};
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::{
|
||||
action::{
|
||||
common::{CreateFile, CreateFileError, CreateOrAppendFile, CreateOrAppendFileError},
|
||||
base::{CreateFile, CreateFileError, CreateOrAppendFile, CreateOrAppendFileError},
|
||||
darwin::{
|
||||
BootstrapVolume, BootstrapVolumeError, CreateSyntheticObjects,
|
||||
CreateSyntheticObjectsError, CreateVolume, CreateVolumeError, EnableOwnership,
|
||||
|
@ -17,6 +11,11 @@ use crate::{
|
|||
},
|
||||
BoxableError,
|
||||
};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::process::Command;
|
||||
|
||||
const NIX_VOLUME_MOUNTD_DEST: &str = "/Library/LaunchDaemons/org.nixos.darwin-store.plist";
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::action::common::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||
use crate::action::base::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionState},
|
||||
BoxableError,
|
||||
};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const PATHS: &[&str] = &[
|
||||
"usr",
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::execute_command;
|
||||
|
||||
use crate::{
|
||||
action::{Action, ActionDescription, ActionState},
|
||||
BoxableError,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
use tokio::process::Command;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct SystemdSysextMerge {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pub mod base;
|
||||
pub mod common;
|
||||
pub mod darwin;
|
||||
pub mod linux;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
action::{
|
||||
common::{ConfigureNix, CreateDirectory, ProvisionNix},
|
||||
linux::StartSystemdUnit,
|
||||
base::CreateDirectory,
|
||||
common::{ConfigureNix, ProvisionNix},
|
||||
},
|
||||
planner::Planner,
|
||||
BuiltinPlanner, CommonSettings, InstallPlan,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser, serde::Serialize, serde::Deserialize)]
|
||||
pub struct LinuxMulti {
|
||||
|
|
|
@ -2,7 +2,8 @@ use std::collections::HashMap;
|
|||
|
||||
use crate::{
|
||||
action::{
|
||||
common::{CreateDirectory, ProvisionNix},
|
||||
base::CreateDirectory,
|
||||
common::ProvisionNix,
|
||||
linux::{CreateSystemdSysext, StartSystemdUnit},
|
||||
},
|
||||
planner::Planner,
|
||||
|
|
Loading…
Reference in a new issue