Rename some of the planners (#243)

* Rename some of the planners

* Fixup Mac

* Also move actions

* Also update CI
This commit is contained in:
Ana Hobden 2023-02-10 12:35:00 -08:00 committed by GitHub
parent 0441ae64e1
commit ab4c528595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 690 additions and 702 deletions

View file

@ -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

View file

@ -73,12 +73,10 @@ Usage: nix-installer install [OPTIONS] [PLAN]
nix-installer install <COMMAND>
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

View file

@ -1,6 +1,6 @@
use crate::action::{
base::{create_or_insert_into_file, CreateFile, CreateOrInsertIntoFile},
darwin::{
macos::{
BootstrapApfsVolume, CreateApfsVolume, CreateSyntheticObjects, EnableOwnership,
EncryptApfsVolume, UnmountApfsVolume,
},

View file

@ -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,
};

View file

@ -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};

View file

@ -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.

View file

@ -1,5 +0,0 @@
//! Planners for Darwin based systems
mod multi;
pub use multi::DarwinMulti;

View file

@ -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<Self, PlannerError> {
Ok(Self {
settings: CommonSettings::default().await?,
@ -98,8 +98,8 @@ impl Planner for LinuxMulti {
}
}
impl Into<BuiltinPlanner> for LinuxMulti {
impl Into<BuiltinPlanner> for Linux {
fn into(self) -> BuiltinPlanner {
BuiltinPlanner::LinuxMulti(self)
BuiltinPlanner::Linux(self)
}
}

View file

@ -1,7 +0,0 @@
//! Planners for Linux based systems
mod multi;
mod steam_deck;
pub use multi::LinuxMulti;
pub use steam_deck::SteamDeck;

View file

@ -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<String, PlannerError> {
}
#[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<Self, PlannerError> {
Ok(Self {
settings: CommonSettings::default().await?,
@ -171,8 +171,8 @@ impl Planner for DarwinMulti {
}
}
impl Into<BuiltinPlanner> for DarwinMulti {
impl Into<BuiltinPlanner> for Macos {
fn into(self) -> BuiltinPlanner {
BuiltinPlanner::DarwinMulti(self)
BuiltinPlanner::Macos(self)
}
}

View file

@ -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<InstallPlan, NixInstallerError> {
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<dyn Planner> {
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<HashMap<String, serde_json::Value>, 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(),
}
}
}

View file

@ -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
}
}
}

628
tests/fixtures/linux/linux.json vendored Normal file
View file

@ -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
}
}
}

View file

@ -656,7 +656,7 @@
}
],
"planner": {
"planner": "darwin-multi",
"planner": "macos",
"settings": {
"channels": [
[

View file

@ -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(())
}