diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d539178..d4fbde3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,7 +204,7 @@ jobs: uses: DeterminateSystems/nix-installer-action@start-daemon-and-init with: init: none - planner: linux-multi + planner: linux local-root: install-root/ logger: pretty log-directives: nix_installer=trace @@ -237,7 +237,7 @@ jobs: uses: DeterminateSystems/nix-installer-action@start-daemon-and-init with: init: none - planner: linux-multi + planner: linux local-root: install-root/ logger: pretty log-directives: nix_installer=trace diff --git a/README.md b/README.md index 6a9d1dd..42aff9e 100644 --- a/README.md +++ b/README.md @@ -73,12 +73,10 @@ Usage: nix-installer install [OPTIONS] [PLAN] nix-installer install Commands: - linux-multi - A standard Linux multi-user install - darwin-multi - A standard MacOS (Darwin) multi-user install + linux + A planner for Linux installs steam-deck - A specialized install suitable for the Valve Steam Deck console + A planner suitable for the Valve Steam Deck running SteamOS help Print this message or the help of the given subcommand(s) # ... @@ -87,10 +85,10 @@ Commands: Planners have their own options and defaults, sharing most of them in common: ```bash -$ ./nix-installer install linux-multi --help -A standard Linux multi-user install +$ ./nix-installer install linux --help +A planner for Linux installs -Usage: nix-installer install linux-multi [OPTIONS] +Usage: nix-installer install linux [OPTIONS] Options: # ... @@ -166,7 +164,7 @@ FROM ubuntu:latest RUN apt update -y RUN apt install curl -y COPY nix-installer /nix-installer -RUN /nix-installer install linux-multi --init none --no-confirm +RUN /nix-installer install linux --init none --no-confirm ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin" RUN nix run nixpkgs#hello ``` @@ -181,7 +179,7 @@ FROM ubuntu:latest RUN apt update -y RUN apt install curl -y COPY nix-installer /nix-installer -RUN /nix-installer install linux-multi --extra-conf "sandbox = false" --init none --no-confirm +RUN /nix-installer install linux --extra-conf "sandbox = false" --init none --no-confirm ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin" RUN nix run nixpkgs#hello ``` @@ -194,7 +192,7 @@ FROM ubuntu:latest RUN apt update -y RUN apt install curl systemd -y COPY nix-installer /nix-installer -RUN /nix-installer install linux-multi --extra-conf "sandbox = false" --no-start-daemon --no-confirm +RUN /nix-installer install linux --extra-conf "sandbox = false" --no-start-daemon --no-confirm ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin" RUN nix run nixpkgs#hello CMD [ "/usr/sbin/init" ] @@ -218,7 +216,7 @@ If systemd is not enabled, pass `--init none` at the end of the command: ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --init none +curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none ``` ## Building a binary diff --git a/src/action/darwin/bootstrap_apfs_volume.rs b/src/action/macos/bootstrap_apfs_volume.rs similarity index 100% rename from src/action/darwin/bootstrap_apfs_volume.rs rename to src/action/macos/bootstrap_apfs_volume.rs diff --git a/src/action/darwin/create_apfs_volume.rs b/src/action/macos/create_apfs_volume.rs similarity index 100% rename from src/action/darwin/create_apfs_volume.rs rename to src/action/macos/create_apfs_volume.rs diff --git a/src/action/darwin/create_fstab_entry.rs b/src/action/macos/create_fstab_entry.rs similarity index 100% rename from src/action/darwin/create_fstab_entry.rs rename to src/action/macos/create_fstab_entry.rs diff --git a/src/action/darwin/create_nix_volume.rs b/src/action/macos/create_nix_volume.rs similarity index 99% rename from src/action/darwin/create_nix_volume.rs rename to src/action/macos/create_nix_volume.rs index 8b048fe..08371f2 100644 --- a/src/action/darwin/create_nix_volume.rs +++ b/src/action/macos/create_nix_volume.rs @@ -1,6 +1,6 @@ use crate::action::{ base::{create_or_insert_into_file, CreateFile, CreateOrInsertIntoFile}, - darwin::{ + macos::{ BootstrapApfsVolume, CreateApfsVolume, CreateSyntheticObjects, EnableOwnership, EncryptApfsVolume, UnmountApfsVolume, }, diff --git a/src/action/darwin/create_synthetic_objects.rs b/src/action/macos/create_synthetic_objects.rs similarity index 100% rename from src/action/darwin/create_synthetic_objects.rs rename to src/action/macos/create_synthetic_objects.rs diff --git a/src/action/darwin/enable_ownership.rs b/src/action/macos/enable_ownership.rs similarity index 100% rename from src/action/darwin/enable_ownership.rs rename to src/action/macos/enable_ownership.rs diff --git a/src/action/darwin/encrypt_apfs_volume.rs b/src/action/macos/encrypt_apfs_volume.rs similarity index 98% rename from src/action/darwin/encrypt_apfs_volume.rs rename to src/action/macos/encrypt_apfs_volume.rs index 27022d7..4b80992 100644 --- a/src/action/darwin/encrypt_apfs_volume.rs +++ b/src/action/macos/encrypt_apfs_volume.rs @@ -1,6 +1,6 @@ use crate::{ action::{ - darwin::NIX_VOLUME_MOUNTD_DEST, Action, ActionDescription, ActionError, StatefulAction, + macos::NIX_VOLUME_MOUNTD_DEST, Action, ActionDescription, ActionError, StatefulAction, }, execute_command, }; diff --git a/src/action/darwin/mod.rs b/src/action/macos/mod.rs similarity index 100% rename from src/action/darwin/mod.rs rename to src/action/macos/mod.rs diff --git a/src/action/darwin/unmount_apfs_volume.rs b/src/action/macos/unmount_apfs_volume.rs similarity index 100% rename from src/action/darwin/unmount_apfs_volume.rs rename to src/action/macos/unmount_apfs_volume.rs diff --git a/src/action/mod.rs b/src/action/mod.rs index 3b9fce1..96e45b7 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -157,8 +157,8 @@ match plan.install(None).await { pub mod base; pub mod common; -pub mod darwin; pub mod linux; +pub mod macos; mod stateful; pub use stateful::{ActionState, StatefulAction}; diff --git a/src/lib.rs b/src/lib.rs index abad0d7..36fef2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,9 +42,9 @@ use nix_installer::{InstallPlan, planner::Planner}; # async fn chosen_planner_install() -> color_eyre::Result<()> { #[cfg(target_os = "linux")] -let planner = nix_installer::planner::linux::SteamDeck::default().await?; +let planner = nix_installer::planner::steam_deck::SteamDeck::default().await?; #[cfg(target_os = "macos")] -let planner = nix_installer::planner::darwin::DarwinMulti::default().await?; +let planner = nix_installer::planner::macos::Macos::default().await?; // Or call `crate::planner::BuiltinPlanner::default()` // Match on the result to customize. diff --git a/src/planner/darwin/mod.rs b/src/planner/darwin/mod.rs deleted file mode 100644 index 18747e0..0000000 --- a/src/planner/darwin/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Planners for Darwin based systems - -mod multi; - -pub use multi::DarwinMulti; diff --git a/src/planner/linux/multi.rs b/src/planner/linux.rs similarity index 94% rename from src/planner/linux/multi.rs rename to src/planner/linux.rs index 9b82d9a..cb6bc75 100644 --- a/src/planner/linux/multi.rs +++ b/src/planner/linux.rs @@ -12,10 +12,10 @@ use crate::{ use std::{collections::HashMap, path::Path}; use tokio::process::Command; -/// A planner for Linux multi-user installs +/// A planner for Linux installs #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "cli", derive(clap::Parser))] -pub struct LinuxMulti { +pub struct Linux { #[cfg_attr(feature = "cli", clap(flatten))] pub settings: CommonSettings, #[cfg_attr(feature = "cli", clap(flatten))] @@ -23,8 +23,8 @@ pub struct LinuxMulti { } #[async_trait::async_trait] -#[typetag::serde(name = "linux-multi")] -impl Planner for LinuxMulti { +#[typetag::serde(name = "linux")] +impl Planner for Linux { async fn default() -> Result { Ok(Self { settings: CommonSettings::default().await?, @@ -98,8 +98,8 @@ impl Planner for LinuxMulti { } } -impl Into for LinuxMulti { +impl Into for Linux { fn into(self) -> BuiltinPlanner { - BuiltinPlanner::LinuxMulti(self) + BuiltinPlanner::Linux(self) } } diff --git a/src/planner/linux/mod.rs b/src/planner/linux/mod.rs deleted file mode 100644 index e050ec8..0000000 --- a/src/planner/linux/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Planners for Linux based systems - -mod multi; -mod steam_deck; - -pub use multi::LinuxMulti; -pub use steam_deck::SteamDeck; diff --git a/src/planner/darwin/multi.rs b/src/planner/macos.rs similarity index 95% rename from src/planner/darwin/multi.rs rename to src/planner/macos.rs index 2e01539..6a03806 100644 --- a/src/planner/darwin/multi.rs +++ b/src/planner/macos.rs @@ -7,7 +7,7 @@ use tokio::process::Command; use crate::{ action::{ common::{ConfigureInitService, ConfigureNix, ProvisionNix}, - darwin::CreateNixVolume, + macos::CreateNixVolume, StatefulAction, }, execute_command, @@ -18,10 +18,10 @@ use crate::{ Action, BuiltinPlanner, }; -/// A planner for MacOS (Darwin) multi-user installs +/// A planner for MacOS (Darwin) installs #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "cli", derive(clap::Parser))] -pub struct DarwinMulti { +pub struct Macos { #[cfg_attr(feature = "cli", clap(flatten))] pub settings: CommonSettings, @@ -73,8 +73,8 @@ async fn default_root_disk() -> Result { } #[async_trait::async_trait] -#[typetag::serde(name = "darwin-multi")] -impl Planner for DarwinMulti { +#[typetag::serde(name = "macos")] +impl Planner for Macos { async fn default() -> Result { Ok(Self { settings: CommonSettings::default().await?, @@ -171,8 +171,8 @@ impl Planner for DarwinMulti { } } -impl Into for DarwinMulti { +impl Into for Macos { fn into(self) -> BuiltinPlanner { - BuiltinPlanner::DarwinMulti(self) + BuiltinPlanner::Macos(self) } } diff --git a/src/planner/mod.rs b/src/planner/mod.rs index bd9de53..0bc6f24 100644 --- a/src/planner/mod.rs +++ b/src/planner/mod.rs @@ -73,10 +73,12 @@ match plan.install(None).await { ``` */ -#[cfg(target_os = "macos")] -pub mod darwin; #[cfg(target_os = "linux")] pub mod linux; +#[cfg(target_os = "macos")] +pub mod macos; +#[cfg(target_os = "linux")] +pub mod steam_deck; use std::{collections::HashMap, string::FromUtf8Error}; @@ -115,14 +117,14 @@ dyn_clone::clone_trait_object!(Planner); #[cfg_attr(feature = "cli", derive(clap::Subcommand))] pub enum BuiltinPlanner { #[cfg(target_os = "linux")] - /// A standard Linux multi-user install - LinuxMulti(linux::LinuxMulti), - /// A standard MacOS (Darwin) multi-user install + /// A planner for Linux installs + Linux(linux::Linux), + /// A planner MacOS (Darwin) for installs #[cfg(target_os = "macos")] - DarwinMulti(darwin::DarwinMulti), - /// A specialized install suitable for the Valve Steam Deck console + Macos(macos::Macos), + /// A planner suitable for the Valve Steam Deck running SteamOS #[cfg(target_os = "linux")] - SteamDeck(linux::SteamDeck), + SteamDeck(steam_deck::SteamDeck), } impl BuiltinPlanner { @@ -132,25 +134,25 @@ impl BuiltinPlanner { match (Architecture::host(), OperatingSystem::host()) { #[cfg(target_os = "linux")] (Architecture::X86_64, OperatingSystem::Linux) => { - Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) + Ok(Self::Linux(linux::Linux::default().await?)) }, #[cfg(target_os = "linux")] (Architecture::X86_32(_), OperatingSystem::Linux) => { - Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) + Ok(Self::Linux(linux::Linux::default().await?)) }, #[cfg(target_os = "linux")] (Architecture::Aarch64(_), OperatingSystem::Linux) => { - Ok(Self::LinuxMulti(linux::LinuxMulti::default().await?)) + Ok(Self::Linux(linux::Linux::default().await?)) }, #[cfg(target_os = "macos")] (Architecture::X86_64, OperatingSystem::MacOSX { .. }) | (Architecture::X86_64, OperatingSystem::Darwin) => { - Ok(Self::DarwinMulti(darwin::DarwinMulti::default().await?)) + Ok(Self::Macos(macos::Macos::default().await?)) }, #[cfg(target_os = "macos")] (Architecture::Aarch64(_), OperatingSystem::MacOSX { .. }) | (Architecture::Aarch64(_), OperatingSystem::Darwin) => { - Ok(Self::DarwinMulti(darwin::DarwinMulti::default().await?)) + Ok(Self::Macos(macos::Macos::default().await?)) }, _ => Err(PlannerError::UnsupportedArchitecture(target_lexicon::HOST)), } @@ -160,11 +162,11 @@ impl BuiltinPlanner { let mut built = Self::default().await?; match &mut built { #[cfg(target_os = "linux")] - BuiltinPlanner::LinuxMulti(inner) => inner.settings = settings, + BuiltinPlanner::Linux(inner) => inner.settings = settings, #[cfg(target_os = "linux")] BuiltinPlanner::SteamDeck(inner) => inner.settings = settings, #[cfg(target_os = "macos")] - BuiltinPlanner::DarwinMulti(inner) => inner.settings = settings, + BuiltinPlanner::Macos(inner) => inner.settings = settings, } Ok(built) } @@ -172,43 +174,43 @@ impl BuiltinPlanner { pub async fn plan(self) -> Result { match self { #[cfg(target_os = "linux")] - BuiltinPlanner::LinuxMulti(planner) => InstallPlan::plan(planner).await, + BuiltinPlanner::Linux(planner) => InstallPlan::plan(planner).await, #[cfg(target_os = "linux")] BuiltinPlanner::SteamDeck(planner) => InstallPlan::plan(planner).await, #[cfg(target_os = "macos")] - BuiltinPlanner::DarwinMulti(planner) => InstallPlan::plan(planner).await, + BuiltinPlanner::Macos(planner) => InstallPlan::plan(planner).await, } } pub fn boxed(self) -> Box { match self { #[cfg(target_os = "linux")] - BuiltinPlanner::LinuxMulti(i) => i.boxed(), + BuiltinPlanner::Linux(i) => i.boxed(), #[cfg(target_os = "linux")] BuiltinPlanner::SteamDeck(i) => i.boxed(), #[cfg(target_os = "macos")] - BuiltinPlanner::DarwinMulti(i) => i.boxed(), + BuiltinPlanner::Macos(i) => i.boxed(), } } pub fn typetag_name(&self) -> &'static str { match self { #[cfg(target_os = "linux")] - BuiltinPlanner::LinuxMulti(i) => i.typetag_name(), + BuiltinPlanner::Linux(i) => i.typetag_name(), #[cfg(target_os = "linux")] BuiltinPlanner::SteamDeck(i) => i.typetag_name(), #[cfg(target_os = "macos")] - BuiltinPlanner::DarwinMulti(i) => i.typetag_name(), + BuiltinPlanner::Macos(i) => i.typetag_name(), } } pub fn settings(&self) -> Result, InstallSettingsError> { match self { #[cfg(target_os = "linux")] - BuiltinPlanner::LinuxMulti(i) => i.settings(), + BuiltinPlanner::Linux(i) => i.settings(), #[cfg(target_os = "linux")] BuiltinPlanner::SteamDeck(i) => i.settings(), #[cfg(target_os = "macos")] - BuiltinPlanner::DarwinMulti(i) => i.settings(), + BuiltinPlanner::Macos(i) => i.settings(), } } } diff --git a/src/planner/linux/steam_deck.rs b/src/planner/steam_deck.rs similarity index 100% rename from src/planner/linux/steam_deck.rs rename to src/planner/steam_deck.rs diff --git a/tests/fixtures/linux/linux-multi.json b/tests/fixtures/linux/linux-multi.json deleted file mode 100644 index ad06a1c..0000000 --- a/tests/fixtures/linux/linux-multi.json +++ /dev/null @@ -1,628 +0,0 @@ -{ - "version": "0.2.1-unreleased", - "actions": [ - { - "action": { - "action": "create_directory", - "path": "/nix", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": true - }, - "state": "Uncompleted" - }, - { - "action": { - "action": "provision_nix", - "fetch_nix": { - "action": { - "url": "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz", - "dest": "/nix/temp-install-dir" - }, - "state": "Uncompleted" - }, - "create_users_and_group": { - "action": { - "nix_build_user_count": 32, - "nix_build_group_name": "nixbld", - "nix_build_group_id": 3000, - "nix_build_user_prefix": "nixbld", - "nix_build_user_id_base": 3000, - "create_group": { - "action": { - "name": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - "create_users": [ - { - "action": { - "name": "nixbld0", - "uid": 3000, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld1", - "uid": 3001, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld2", - "uid": 3002, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld3", - "uid": 3003, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld4", - "uid": 3004, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld5", - "uid": 3005, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld6", - "uid": 3006, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld7", - "uid": 3007, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld8", - "uid": 3008, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld9", - "uid": 3009, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld10", - "uid": 3010, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld11", - "uid": 3011, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld12", - "uid": 3012, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld13", - "uid": 3013, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld14", - "uid": 3014, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld15", - "uid": 3015, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld16", - "uid": 3016, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld17", - "uid": 3017, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld18", - "uid": 3018, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld19", - "uid": 3019, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld20", - "uid": 3020, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld21", - "uid": 3021, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld22", - "uid": 3022, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld23", - "uid": 3023, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld24", - "uid": 3024, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld25", - "uid": 3025, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld26", - "uid": 3026, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld27", - "uid": 3027, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld28", - "uid": 3028, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld29", - "uid": 3029, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld30", - "uid": 3030, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - }, - { - "action": { - "name": "nixbld31", - "uid": 3031, - "groupname": "nixbld", - "gid": 3000 - }, - "state": "Uncompleted" - } - ] - }, - "state": "Uncompleted" - }, - "create_nix_tree": { - "action": { - "create_directories": [ - { - "action": { - "path": "/nix/var", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/log", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/log/nix", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/log/nix/drvs", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/db", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/gcroots", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/gcroots/per-user", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/profiles", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/profiles/per-user", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/temproots", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/userpool", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/nix/var/nix/daemon-socket", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - } - ] - }, - "state": "Uncompleted" - }, - "move_unpacked_nix": { - "action": { - "src": "/nix/temp-install-dir" - }, - "state": "Uncompleted" - } - }, - "state": "Uncompleted" - }, - { - "action": { - "action": "configure_nix", - "setup_default_profile": { - "action": { - "channels": [ - [ - "nixpkgs", - "https://nixos.org/channels/nixpkgs-unstable" - ] - ] - }, - "state": "Uncompleted" - }, - "configure_shell_profile": { - "action": { - "create_directories": [], - "create_or_insert_into_files": [ - { - "action": { - "path": "/etc/bashrc", - "user": null, - "group": null, - "mode": 493, - "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", - "position": "Beginning" - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/etc/profile.d/nix.sh", - "user": null, - "group": null, - "mode": 493, - "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", - "position": "Beginning" - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/etc/zshenv", - "user": null, - "group": null, - "mode": 493, - "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", - "position": "Beginning" - }, - "state": "Uncompleted" - }, - { - "action": { - "path": "/etc/bash.bashrc", - "user": null, - "group": null, - "mode": 493, - "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", - "position": "Beginning" - }, - "state": "Uncompleted" - } - ] - }, - "state": "Uncompleted" - }, - "place_channel_configuration": { - "action": { - "channels": [ - [ - "nixpkgs", - "https://nixos.org/channels/nixpkgs-unstable" - ] - ], - "create_file": { - "action": { - "path": "/home/ana/.nix-channels", - "user": null, - "group": null, - "mode": 436, - "buf": "https://nixos.org/channels/nixpkgs-unstable nixpkgs", - "force": false - }, - "state": "Uncompleted" - } - }, - "state": "Uncompleted" - }, - "place_nix_configuration": { - "action": { - "create_directory": { - "action": { - "path": "/etc/nix", - "user": null, - "group": null, - "mode": 493, - "force_prune_on_revert": false - }, - "state": "Uncompleted" - }, - "create_file": { - "action": { - "path": "/etc/nix/nix.conf", - "user": null, - "group": null, - "mode": 436, - "buf": "# Generated by https://github.com/DeterminateSystems/nix-installer, version 0.1.0-unreleased.\n\n\n\nbuild-users-group = nixbld\n\nexperimental-features = nix-command flakes\n\nauto-optimise-store = true\n\nbash-prompt-prefix = (nix:$name)\\040\n", - "force": false - }, - "state": "Uncompleted" - } - }, - "state": "Uncompleted" - } - }, - "state": "Uncompleted" - }, - { - "action": { - "action": "configure_nix_daemon", - "init": "Systemd", - "start_daemon": true - }, - "state": "Uncompleted" - } - ], - "planner": { - "planner": "linux-multi", - "settings": { - "channels": [ - [ - "nixpkgs", - "https://nixos.org/channels/nixpkgs-unstable" - ] - ], - "modify_profile": true, - "nix_build_user_count": 32, - "nix_build_group_name": "nixbld", - "nix_build_group_id": 3000, - "nix_build_user_prefix": "nixbld", - "nix_build_user_id_base": 3000, - "nix_package_url": "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz", - "extra_conf": [], - "force": false - }, - "init": { - "init": "Systemd", - "start_daemon": true - } - } - } \ No newline at end of file diff --git a/tests/fixtures/linux/linux.json b/tests/fixtures/linux/linux.json new file mode 100644 index 0000000..d75a8ff --- /dev/null +++ b/tests/fixtures/linux/linux.json @@ -0,0 +1,628 @@ +{ + "version": "0.2.1-unreleased", + "actions": [ + { + "action": { + "action": "create_directory", + "path": "/nix", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": true + }, + "state": "Uncompleted" + }, + { + "action": { + "action": "provision_nix", + "fetch_nix": { + "action": { + "url": "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz", + "dest": "/nix/temp-install-dir" + }, + "state": "Uncompleted" + }, + "create_users_and_group": { + "action": { + "nix_build_user_count": 32, + "nix_build_group_name": "nixbld", + "nix_build_group_id": 3000, + "nix_build_user_prefix": "nixbld", + "nix_build_user_id_base": 3000, + "create_group": { + "action": { + "name": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + "create_users": [ + { + "action": { + "name": "nixbld0", + "uid": 3000, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld1", + "uid": 3001, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld2", + "uid": 3002, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld3", + "uid": 3003, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld4", + "uid": 3004, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld5", + "uid": 3005, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld6", + "uid": 3006, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld7", + "uid": 3007, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld8", + "uid": 3008, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld9", + "uid": 3009, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld10", + "uid": 3010, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld11", + "uid": 3011, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld12", + "uid": 3012, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld13", + "uid": 3013, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld14", + "uid": 3014, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld15", + "uid": 3015, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld16", + "uid": 3016, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld17", + "uid": 3017, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld18", + "uid": 3018, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld19", + "uid": 3019, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld20", + "uid": 3020, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld21", + "uid": 3021, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld22", + "uid": 3022, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld23", + "uid": 3023, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld24", + "uid": 3024, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld25", + "uid": 3025, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld26", + "uid": 3026, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld27", + "uid": 3027, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld28", + "uid": 3028, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld29", + "uid": 3029, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld30", + "uid": 3030, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + }, + { + "action": { + "name": "nixbld31", + "uid": 3031, + "groupname": "nixbld", + "gid": 3000 + }, + "state": "Uncompleted" + } + ] + }, + "state": "Uncompleted" + }, + "create_nix_tree": { + "action": { + "create_directories": [ + { + "action": { + "path": "/nix/var", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/log", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/log/nix", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/log/nix/drvs", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/db", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/gcroots", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/gcroots/per-user", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/profiles", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/profiles/per-user", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/temproots", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/userpool", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/nix/var/nix/daemon-socket", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + } + ] + }, + "state": "Uncompleted" + }, + "move_unpacked_nix": { + "action": { + "src": "/nix/temp-install-dir" + }, + "state": "Uncompleted" + } + }, + "state": "Uncompleted" + }, + { + "action": { + "action": "configure_nix", + "setup_default_profile": { + "action": { + "channels": [ + [ + "nixpkgs", + "https://nixos.org/channels/nixpkgs-unstable" + ] + ] + }, + "state": "Uncompleted" + }, + "configure_shell_profile": { + "action": { + "create_directories": [], + "create_or_insert_into_files": [ + { + "action": { + "path": "/etc/bashrc", + "user": null, + "group": null, + "mode": 493, + "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", + "position": "Beginning" + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/etc/profile.d/nix.sh", + "user": null, + "group": null, + "mode": 493, + "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", + "position": "Beginning" + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/etc/zshenv", + "user": null, + "group": null, + "mode": 493, + "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", + "position": "Beginning" + }, + "state": "Uncompleted" + }, + { + "action": { + "path": "/etc/bash.bashrc", + "user": null, + "group": null, + "mode": 493, + "buf": "\n# Nix\nif [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then\n . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'\nfi\n# End Nix\n\n \n", + "position": "Beginning" + }, + "state": "Uncompleted" + } + ] + }, + "state": "Uncompleted" + }, + "place_channel_configuration": { + "action": { + "channels": [ + [ + "nixpkgs", + "https://nixos.org/channels/nixpkgs-unstable" + ] + ], + "create_file": { + "action": { + "path": "/home/ana/.nix-channels", + "user": null, + "group": null, + "mode": 436, + "buf": "https://nixos.org/channels/nixpkgs-unstable nixpkgs", + "force": false + }, + "state": "Uncompleted" + } + }, + "state": "Uncompleted" + }, + "place_nix_configuration": { + "action": { + "create_directory": { + "action": { + "path": "/etc/nix", + "user": null, + "group": null, + "mode": 493, + "force_prune_on_revert": false + }, + "state": "Uncompleted" + }, + "create_file": { + "action": { + "path": "/etc/nix/nix.conf", + "user": null, + "group": null, + "mode": 436, + "buf": "# Generated by https://github.com/DeterminateSystems/nix-installer, version 0.1.0-unreleased.\n\n\n\nbuild-users-group = nixbld\n\nexperimental-features = nix-command flakes\n\nauto-optimise-store = true\n\nbash-prompt-prefix = (nix:$name)\\040\n", + "force": false + }, + "state": "Uncompleted" + } + }, + "state": "Uncompleted" + } + }, + "state": "Uncompleted" + }, + { + "action": { + "action": "configure_nix_daemon", + "init": "Systemd", + "start_daemon": true + }, + "state": "Uncompleted" + } + ], + "planner": { + "planner": "linux", + "settings": { + "channels": [ + [ + "nixpkgs", + "https://nixos.org/channels/nixpkgs-unstable" + ] + ], + "modify_profile": true, + "nix_build_user_count": 32, + "nix_build_group_name": "nixbld", + "nix_build_group_id": 3000, + "nix_build_user_prefix": "nixbld", + "nix_build_user_id_base": 3000, + "nix_package_url": "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz", + "extra_conf": [], + "force": false + }, + "init": { + "init": "Systemd", + "start_daemon": true + } + } +} \ No newline at end of file diff --git a/tests/fixtures/darwin/darwin-multi.json b/tests/fixtures/macos/macos.json similarity index 99% rename from tests/fixtures/darwin/darwin-multi.json rename to tests/fixtures/macos/macos.json index 85c3ad5..595af13 100644 --- a/tests/fixtures/darwin/darwin-multi.json +++ b/tests/fixtures/macos/macos.json @@ -656,7 +656,7 @@ } ], "planner": { - "planner": "darwin-multi", + "planner": "macos", "settings": { "channels": [ [ diff --git a/tests/plan.rs b/tests/plan.rs index bf5d8e2..e34ad0f 100644 --- a/tests/plan.rs +++ b/tests/plan.rs @@ -1,18 +1,18 @@ use nix_installer::InstallPlan; #[cfg(target_os = "linux")] -const LINUX_MULTI: &str = include_str!("./fixtures/linux/linux-multi.json"); +const LINUX: &str = include_str!("./fixtures/linux/linux.json"); #[cfg(target_os = "linux")] const STEAM_DECK: &str = include_str!("./fixtures/linux/steam-deck.json"); #[cfg(target_os = "macos")] -const DARWIN_MULTI: &str = include_str!("./fixtures/darwin/darwin-multi.json"); +const MACOS: &str = include_str!("./fixtures/macos/macos.json"); // Ensure existing plans still parse // If this breaks and you need to update the fixture, disable these tests, bump `nix_installer` to a new version, and update the plans. #[cfg(target_os = "linux")] #[test] -fn plan_compat_linux_multi() -> eyre::Result<()> { - let _: InstallPlan = serde_json::from_str(LINUX_MULTI)?; +fn plan_compat_linux() -> eyre::Result<()> { + let _: InstallPlan = serde_json::from_str(LINUX)?; Ok(()) } @@ -29,7 +29,7 @@ fn plan_compat_steam_deck() -> eyre::Result<()> { // If this breaks and you need to update the fixture, disable these tests, bump `nix_installer` to a new version, and update the plans. #[cfg(target_os = "macos")] #[test] -fn plan_compat_darwin_multi() -> eyre::Result<()> { - let _: InstallPlan = serde_json::from_str(DARWIN_MULTI)?; +fn plan_compat_macos() -> eyre::Result<()> { + let _: InstallPlan = serde_json::from_str(MACOS)?; Ok(()) }