forked from lix-project/lix-installer
Merge pull request #47 from DeterminateSystems/spacekookie/refactor-actions
Refactoring actions/ part 2
This commit is contained in:
commit
392d98f876
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
description = "riff";
|
description = "harmonic";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
||||||
|
|
21
src/action/base/mod.rs
Normal file
21
src/action/base/mod.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//! 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::{
|
use crate::{
|
||||||
action::{
|
action::{
|
||||||
common::{
|
base::{ConfigureNixDaemonService, SetupDefaultProfile},
|
||||||
ConfigureNixDaemonService, ConfigureShellProfile, PlaceChannelConfiguration,
|
common::{ConfigureShellProfile, PlaceChannelConfiguration, PlaceNixConfiguration},
|
||||||
PlaceNixConfiguration, SetupDefaultProfile,
|
|
||||||
},
|
|
||||||
Action, ActionDescription, ActionState,
|
Action, ActionDescription, ActionState,
|
||||||
},
|
},
|
||||||
channel_value::ChannelValue,
|
channel_value::ChannelValue,
|
||||||
BoxableError, CommonSettings,
|
BoxableError, CommonSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use reqwest::Url;
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||||
pub struct ConfigureNix {
|
pub struct ConfigureNix {
|
||||||
setup_default_profile: SetupDefaultProfile,
|
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 std::path::Path;
|
||||||
|
|
||||||
use tokio::task::{JoinError, JoinSet};
|
use tokio::task::{JoinError, JoinSet};
|
||||||
|
|
||||||
use crate::action::common::{CreateOrAppendFile, CreateOrAppendFileError};
|
|
||||||
use crate::{
|
|
||||||
action::{Action, ActionDescription, ActionState},
|
|
||||||
BoxableError,
|
|
||||||
};
|
|
||||||
|
|
||||||
const PROFILE_TARGETS: &[&str] = &[
|
const PROFILE_TARGETS: &[&str] = &[
|
||||||
"/etc/bashrc",
|
"/etc/bashrc",
|
||||||
"/etc/profile.d/nix.sh",
|
"/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};
|
use crate::action::{Action, ActionDescription, ActionState};
|
||||||
|
|
||||||
const PATHS: &[&str] = &[
|
const PATHS: &[&str] = &[
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
use tokio::task::{JoinError, JoinSet};
|
|
||||||
|
|
||||||
use crate::CommonSettings;
|
use crate::CommonSettings;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{
|
action::{
|
||||||
common::{CreateGroup, CreateGroupError, CreateUser, CreateUserError},
|
base::{CreateGroup, CreateGroupError, CreateUser, CreateUserError},
|
||||||
Action, ActionDescription, ActionState,
|
Action, ActionDescription, ActionState,
|
||||||
},
|
},
|
||||||
BoxableError,
|
BoxableError,
|
||||||
};
|
};
|
||||||
|
use tokio::task::{JoinError, JoinSet};
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||||
pub struct CreateUsersAndGroup {
|
pub struct CreateUsersAndGroup {
|
||||||
|
|
|
@ -1,35 +1,17 @@
|
||||||
/*! Actions which only call other base plugins. */
|
/*! Actions which only call other base plugins. */
|
||||||
|
|
||||||
mod configure_nix;
|
mod configure_nix;
|
||||||
mod configure_nix_daemon_service;
|
|
||||||
mod configure_shell_profile;
|
mod configure_shell_profile;
|
||||||
mod create_directory;
|
|
||||||
mod create_file;
|
|
||||||
mod create_group;
|
|
||||||
mod create_nix_tree;
|
mod create_nix_tree;
|
||||||
mod create_or_append_file;
|
|
||||||
mod create_user;
|
|
||||||
mod create_users_and_group;
|
mod create_users_and_group;
|
||||||
mod fetch_nix;
|
|
||||||
mod move_unpacked_nix;
|
|
||||||
mod place_channel_configuration;
|
mod place_channel_configuration;
|
||||||
mod place_nix_configuration;
|
mod place_nix_configuration;
|
||||||
mod provision_nix;
|
mod provision_nix;
|
||||||
mod setup_default_profile;
|
|
||||||
|
|
||||||
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_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_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 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_channel_configuration::{PlaceChannelConfiguration, PlaceChannelConfigurationError};
|
||||||
pub use place_nix_configuration::{PlaceNixConfiguration, PlaceNixConfigurationError};
|
pub use place_nix_configuration::{PlaceNixConfiguration, PlaceNixConfigurationError};
|
||||||
pub use provision_nix::{ProvisionNix, ProvisionNixError};
|
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::{
|
use crate::{
|
||||||
action::{Action, ActionDescription, ActionState},
|
action::{Action, ActionDescription, ActionState},
|
||||||
BoxableError,
|
BoxableError,
|
||||||
};
|
};
|
||||||
|
use reqwest::Url;
|
||||||
use crate::action::common::{CreateFile, CreateFileError};
|
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||||
pub struct PlaceChannelConfiguration {
|
pub struct PlaceChannelConfiguration {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
use crate::action::base::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||||
use crate::action::{Action, ActionDescription, ActionState};
|
use crate::action::{Action, ActionDescription, ActionState};
|
||||||
|
|
||||||
use crate::action::common::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
|
||||||
|
|
||||||
const NIX_CONF_FOLDER: &str = "/etc/nix";
|
const NIX_CONF_FOLDER: &str = "/etc/nix";
|
||||||
const NIX_CONF: &str = "/etc/nix/nix.conf";
|
const NIX_CONF: &str = "/etc/nix/nix.conf";
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
use std::path::PathBuf;
|
use crate::action::base::{
|
||||||
|
|
||||||
use tokio::task::JoinError;
|
|
||||||
|
|
||||||
use crate::action::common::{
|
|
||||||
CreateDirectoryError, FetchNix, FetchNixError, MoveUnpackedNix, MoveUnpackedNixError,
|
CreateDirectoryError, FetchNix, FetchNixError, MoveUnpackedNix, MoveUnpackedNixError,
|
||||||
};
|
};
|
||||||
use crate::CommonSettings;
|
use crate::CommonSettings;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{Action, ActionDescription, ActionState},
|
action::{Action, ActionDescription, ActionState},
|
||||||
BoxableError,
|
BoxableError,
|
||||||
};
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tokio::task::JoinError;
|
||||||
|
|
||||||
use super::{CreateNixTree, CreateNixTreeError, CreateUsersAndGroup, CreateUsersAndGroupError};
|
use super::{CreateNixTree, CreateNixTreeError, CreateUsersAndGroup, CreateUsersAndGroupError};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
use std::{
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
use tokio::process::Command;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{
|
action::{
|
||||||
common::{CreateFile, CreateFileError, CreateOrAppendFile, CreateOrAppendFileError},
|
base::{CreateFile, CreateFileError, CreateOrAppendFile, CreateOrAppendFileError},
|
||||||
darwin::{
|
darwin::{
|
||||||
BootstrapVolume, BootstrapVolumeError, CreateSyntheticObjects,
|
BootstrapVolume, BootstrapVolumeError, CreateSyntheticObjects,
|
||||||
CreateSyntheticObjectsError, CreateVolume, CreateVolumeError, EnableOwnership,
|
CreateSyntheticObjectsError, CreateVolume, CreateVolumeError, EnableOwnership,
|
||||||
|
@ -17,6 +11,11 @@ use crate::{
|
||||||
},
|
},
|
||||||
BoxableError,
|
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";
|
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::base::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
||||||
|
|
||||||
use crate::action::common::{CreateDirectory, CreateDirectoryError, CreateFile, CreateFileError};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{Action, ActionDescription, ActionState},
|
action::{Action, ActionDescription, ActionState},
|
||||||
BoxableError,
|
BoxableError,
|
||||||
};
|
};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
const PATHS: &[&str] = &[
|
const PATHS: &[&str] = &[
|
||||||
"usr",
|
"usr",
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use tokio::process::Command;
|
|
||||||
|
|
||||||
use crate::execute_command;
|
use crate::execute_command;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{Action, ActionDescription, ActionState},
|
action::{Action, ActionDescription, ActionState},
|
||||||
BoxableError,
|
BoxableError,
|
||||||
};
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||||
pub struct SystemdSysextMerge {
|
pub struct SystemdSysextMerge {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
pub mod base;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod darwin;
|
pub mod darwin;
|
||||||
pub mod linux;
|
pub mod linux;
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{
|
action::{
|
||||||
common::{ConfigureNix, CreateDirectory, ProvisionNix},
|
base::CreateDirectory,
|
||||||
linux::StartSystemdUnit,
|
common::{ConfigureNix, ProvisionNix},
|
||||||
},
|
},
|
||||||
planner::Planner,
|
planner::Planner,
|
||||||
BuiltinPlanner, CommonSettings, InstallPlan,
|
BuiltinPlanner, CommonSettings, InstallPlan,
|
||||||
};
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Debug, Clone, clap::Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, clap::Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct LinuxMulti {
|
pub struct LinuxMulti {
|
||||||
|
|
|
@ -2,7 +2,8 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{
|
action::{
|
||||||
common::{CreateDirectory, ProvisionNix},
|
base::CreateDirectory,
|
||||||
|
common::ProvisionNix,
|
||||||
linux::{CreateSystemdSysext, StartSystemdUnit},
|
linux::{CreateSystemdSysext, StartSystemdUnit},
|
||||||
},
|
},
|
||||||
planner::Planner,
|
planner::Planner,
|
||||||
|
|
Loading…
Reference in a new issue