Rename harmonic to nix-installer (#125)

* Rename harmonic to nix-installer

* Fix build

* handle nix-install.sh rename

* Forgot some things

* Fix a mistype

* Fix env var

* Fix merge change that popped up
This commit is contained in:
Ana Hobden 2022-12-19 10:26:58 -08:00 committed by GitHub
parent 1e6d7d75c9
commit d299dbf0f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 346 additions and 340 deletions

View file

@ -1,10 +1,10 @@
steps:
- label: harmonic-aarch64-darwin
- label: nix-installer-aarch64-darwin
agents:
mac: 1
system: aarch64-darwin
nix: 1
command:
- nix --extra-experimental-features "nix-command flakes" build .#packages.aarch64-darwin.harmonic -L
- cp result/bin/harmonic ./harmonic-aarch64-darwin
- buildkite-agent artifact upload harmonic-aarch64-darwin
- nix --extra-experimental-features "nix-command flakes" build .#packages.aarch64-darwin.nix-installer -L
- cp result/bin/nix-installer ./nix-installer-aarch64-darwin
- buildkite-agent artifact upload nix-installer-aarch64-darwin

View file

@ -45,18 +45,18 @@ jobs:
with:
path: ~/.ci-store
key: build-store-x86_64-linux-${{ hashFiles('**/Cargo.lock', '**/flake.lock') }}-v1
- name: Build harmonicStatic
run: nix build --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.harmonicStatic
- name: Build `nix-installer-static`
run: nix build --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.nix-installer-static
- name: Copy artifact
run: |
RESULT=$(nix eval --raw --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.harmonicStatic --apply "x: \"$HOME/.ci-store\${x}\"")
cp $RESULT/bin/harmonic harmonic
- name: Create artifact for x86_64-linux harmonic
RESULT=$(nix eval --raw --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.nix-installer-static --apply "x: \"$HOME/.ci-store\${x}\"")
cp $RESULT/bin/nix-installer nix-installer
- name: Create artifact for x86_64-linux nix-installer
uses: actions/upload-artifact@v3
with:
name: harmonic-x86_64-linux
name: nix-installer-x86_64-linux
path: |
harmonic
nix-installer
# Various feature variations or versions of the build which we expect to always work
# Since it uses the `build-store-x86_64-linux-*` cache it should be quite fast
@ -76,8 +76,8 @@ jobs:
with:
path: ~/.ci-store
key: build-store-x86_64-linux-${{ hashFiles('**/Cargo.lock', '**/flake.lock') }}-v1
- name: Build harmonic
run: nix build --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.harmonic
- name: Build `nix-installer`
run: nix build --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.nix-installer
- name: Test `nix develop` build without default features
run: nix develop --store ~/.ci-store --print-build-logs .# --command "cargo" build --no-default-features
- name: Test `nix develop` build all features
@ -92,27 +92,27 @@ jobs:
- run: sudo apt install fish zsh
- uses: actions/download-artifact@v3
with:
name: harmonic-x86_64-linux
name: nix-installer-x86_64-linux
- name: Move & set executable
run: |
chmod +x ./harmonic
chmod +x ./nix-installer
mkdir install-root
cp nix-install.sh install-root/nix-install.sh
mv harmonic install-root/harmonic-x86_64-linux
cp nix-installer.sh install-root/nix-installer.sh
mv nix-installer install-root/nix-installer-x86_64-linux
- name: Initial install
uses: ./
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Initial uninstall (without a `nix run` first)
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full
- name: Ensure `nix` is removed
run: |
@ -133,7 +133,7 @@ jobs:
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: echo $PATH
@ -158,11 +158,11 @@ jobs:
if: success() || failure()
shell: fish --login {0}
- name: Repeated uninstall
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full
- name: Ensure `nix` is removed
run: |
@ -188,13 +188,13 @@ jobs:
- run: sudo apt install fish zsh
- uses: actions/download-artifact@v3
with:
name: harmonic-x86_64-linux
name: nix-installer-x86_64-linux
- name: Move & set executable
run: |
chmod +x ./harmonic
chmod +x ./nix-installer
mkdir install-root
cp nix-install.sh install-root/nix-install.sh
mv harmonic install-root/harmonic-x86_64-linux
cp nix-installer.sh install-root/nix-installer.sh
mv nix-installer install-root/nix-installer-x86_64-linux
- name: Make the CI look like a steam deck
run: |
mkdir -p ~/bin
@ -206,17 +206,17 @@ jobs:
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
planner: steam-deck
extra-args: --persistence /home/runner/.ci-test-nix-home
- name: Initial uninstall (without a `nix run` first)
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full
- name: Ensure `nix` is removed
run: |
@ -241,7 +241,7 @@ jobs:
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
planner: steam-deck
@ -268,11 +268,11 @@ jobs:
if: success() || failure()
shell: fish --login {0}
- name: Repeated uninstall
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full
- name: Ensure `nix` is removed
run: |
@ -303,14 +303,14 @@ jobs:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
# Runs clippy as part of the preBuild.
- name: Build harmonic
run: nix build .#packages.x86_64-darwin.harmonic -L
- name: Create artifact for x86_64-darwin harmonic
- name: Build nix-installer
run: nix build .#packages.x86_64-darwin.nix-installer -L
- name: Create artifact for x86_64-darwin nix-installer
uses: actions/upload-artifact@v3
with:
name: harmonic-x86_64-darwin
name: nix-installer-x86_64-darwin
path: |
result/bin/harmonic
result/bin/nix-installer
run-x86_64-darwin:
name: Run x86_64 Darwin
@ -321,34 +321,34 @@ jobs:
- run: brew install fish coreutils
- uses: actions/download-artifact@v3
with:
name: harmonic-x86_64-darwin
name: nix-installer-x86_64-darwin
- name: Move & set executable
run: |
chmod +x ./harmonic
chmod +x ./nix-installer
mkdir install-root
cp nix-install.sh install-root/nix-install.sh
mv harmonic install-root/harmonic-x86_64-darwin
cp nix-installer.sh install-root/nix-installer.sh
mv nix-installer install-root/nix-installer-x86_64-darwin
- name: Initial install
uses: ./
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Initial uninstall (without a `nix run` first)
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full
- name: Repeated install
uses: ./
with:
local-root: install-root/
logger: pretty
log-directives: harmonic=trace
log-directives: nix_installer=trace
backtrace: full
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: echo $PATH
@ -373,10 +373,10 @@ jobs:
if: success() || failure()
shell: fish --login {0}
- name: Repeated uninstall
run: sudo -E /nix/harmonic uninstall
run: sudo -E /nix/nix-installer uninstall
env:
HARMONIC_NO_CONFIRM: true
HARMONIC_LOGGER: pretty
HARMONIC_LOG_DIRECTIVES: harmonic=trace
NIX_INSTALLER_NO_CONFIRM: true
NIX_INSTALLER_LOGGER: pretty
NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=trace
RUST_BACKTRACE: full

View file

@ -1,14 +1,14 @@
# Contributing to Harmonic
# Contributing to `nix-installer`
We're excited to see what you'd like to contribute to Harmonic!
We're excited to see what you'd like to contribute to `nix-installer`!
Regardless of what (or how much) you contribute to Harmonic, we value your time
Regardless of what (or how much) you contribute to `nix-installer`, we value your time
and energy trying to improve the tool.
In order to ensure we all have a good experience, please review this document
if you have any questions about the process.
**Regular Rust committer?** Contributing to Harmonic should feel similar to
**Regular Rust committer?** Contributing to `nix-installer` should feel similar to
contributing to other serious Rust ecosystem projects. You may already know
the process and expectations of you, this document shouldn't contain any
surprises.
@ -69,13 +69,13 @@ Here are how to do various kinds of contributions.
## Bug Reports
Create an issue on [the issue page](https://github.com/DeterminateSystems/harmonic/issues).
Create an issue on [the issue page](https://github.com/DeterminateSystems/nix-installer/issues).
It should contain:
1. Your OS (Linux, Mac) and architecture (x86_64, aarch64)
2. Your Harmonic version (`harmonic --version`)
3. The thing you tried to run (eg `harmonic`)
2. Your `nix-installer`` version (`nix-installer --version`)
3. The thing you tried to run (eg `nix-installer`)
4. What happened (the output of the command, please)
5. What you expected to happen
6. If you tried to fix it, what did you try?
@ -85,10 +85,10 @@ It should contain:
For **minor** fixes, documentation, or changes which **do not** have a
tangible impact on user experience, feel free to open a
[pull request](https://github.com/DeterminateSystems/harmonic/pulls) directly.
[pull request](https://github.com/DeterminateSystems/nix-installer/pulls) directly.
If the code improvement is not minor, such as new features or user facing
changes, an [issue](https://github.com/DeterminateSystems/harmonic/issues)
changes, an [issue](https://github.com/DeterminateSystems/nix-installer/issues)
proposing the change is **required** for non-maintainers.
Please:
@ -103,16 +103,16 @@ Please:
## Non-code contributions
Please open an [issue](https://github.com/DeterminateSystems/harmonic/issues)
Please open an [issue](https://github.com/DeterminateSystems/nix-installer/issues)
to chat about your contribution and figure out how to best integrate it into
the project.
# Who maintains Harmonic and why?
# Who maintains `nix-installer` and why?
Harmonic is maintained by [Determinate Systems](https://determinate.systems/) in
`nix-installer` is maintained by [Determinate Systems](https://determinate.systems/) in
an effort to explore Nix installer ideas.
Determinate Systems has no plans to monetize or relicense Harmonic. If your
Determinate Systems has no plans to monetize or relicense `nix-installer`. If your
enterprise requires a support contact in order to adopt a tool, please contact
Determinate Systems and something can be worked out.

70
Cargo.lock generated
View file

@ -527,41 +527,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "harmonic"
version = "0.0.0-unreleased"
dependencies = [
"async-trait",
"atty",
"bytes 1.3.0",
"clap",
"color-eyre",
"dirs",
"dyn-clone",
"eyre",
"glob",
"nix",
"owo-colors",
"plist",
"rand",
"reqwest",
"semver",
"serde",
"serde_json",
"serde_with",
"tar",
"target-lexicon",
"term",
"thiserror",
"tokio",
"tracing",
"tracing-error",
"tracing-subscriber",
"typetag",
"url",
"xz2",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@ -914,6 +879,41 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "nix-installer"
version = "0.0.0-unreleased"
dependencies = [
"async-trait",
"atty",
"bytes 1.3.0",
"clap",
"color-eyre",
"dirs",
"dyn-clone",
"eyre",
"glob",
"nix",
"owo-colors",
"plist",
"rand",
"reqwest",
"semver",
"serde",
"serde_json",
"serde_with",
"tar",
"target-lexicon",
"term",
"thiserror",
"tokio",
"tracing",
"tracing-error",
"tracing-subscriber",
"typetag",
"url",
"xz2",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"

View file

@ -1,5 +1,5 @@
[package]
name = "harmonic"
name = "nix-installer"
description = "A `nix` installer"
version = "0.0.0-unreleased"
edition = "2021"
@ -16,7 +16,7 @@ default = ["cli"]
cli = [ "eyre", "color-eyre", "clap", "tracing-subscriber", "tracing-error", "atty" ]
[[bin]]
name = "harmonic"
name = "nix-installer"
required-features = [ "cli" ]
[dependencies]

View file

@ -1,8 +1,8 @@
# Harmonic
# Nix Installer
> **Harmonic is pre-release and experimental.** Don't run it on machines you care about.
> **`nix-installer` is pre-release and experimental.** Don't run it on machines you care about.
Harmonic is an opinionated, experimental Nix installer.
`nix-installer` is an opinionated, experimental Nix installer.
> Try it on a machine/VM you don't care about!
>
@ -12,7 +12,7 @@ Harmonic is an opinionated, experimental Nix installer.
## Status
Harmonic is **pre-release and experimental**. It is not ready for you to use! *Please* don't use it on a machine you are not planning to obliterate!
`nix-installer` is **pre-release and experimental**. It is not ready for you to use! *Please* don't use it on a machine you are not planning to obliterate!
Planned support:
@ -34,7 +34,7 @@ Planned support:
Differing from the current official [Nix](https://github.com/NixOS/nix) installer scripts:
* Nix is installed with the `nix-command` and `flakes` features enabled in the `nix.conf`
* Harmonic stores an installation receipt (for uninstalling) at `/nix/receipt.json` as well as a copy of the install binary at `/nix/harmonic`
* `nix-installer` stores an installation receipt (for uninstalling) at `/nix/receipt.json` as well as a copy of the install binary at `/nix/nix-installer`
## Motivations
@ -52,38 +52,38 @@ So far, our explorations have been quite fruitful, so we wanted to share and kee
## Building
Since you'll be using Harmonic to install Nix on systems without Nix, the default build is a static binary.
Since you'll be using `nix-installer` to install Nix on systems without Nix, the default build is a static binary.
Build it on a system with Nix:
```bash
nix build github:determinatesystems/harmonic
nix build github:determinatesystems/nix-installer
```
Then copy the `result/bin/harmonic` to the machine you wish to run it on.
Then copy the `result/bin/nix-installer` to the machine you wish to run it on.
## Installing
Install Nix with the default planner and options:
```bash
./harmonic install
./nix-installer install
```
> `harmonic` will elevate itself if it is not run as `root` using `sudo`. If you use `doas` or `please` you may need to elevate `harmonic` yourself.
> `nix-installer` will elevate itself if it is not run as `root` using `sudo`. If you use `doas` or `please` you may need to elevate `nix-installer` yourself.
To observe verbose logging, either use `harmonic -v`, this tool [also respects the `RUST_LOG` environment](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives). (Eg `RUST_LOG=harmonic=trace harmonic`).
To observe verbose logging, either use `nix-installer -v`, this tool [also respects the `RUST_LOG` environment](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives). (Eg `RUST_LOG=nix_installer=trace nix-installer`).
Harmonic installs Nix by following a *plan* made by a *planner*. Review the available planners:
`nix-installer` installs Nix by following a *plan* made by a *planner*. Review the available planners:
```bash
$ ./harmonic install --help
$ ./nix-installer install --help
Execute an install (possibly using an existing plan)
To pass custom options, select a planner, for example `harmonic install linux-multi --help`
To pass custom options, select a planner, for example `nix-installer install linux-multi --help`
Usage: harmonic install [OPTIONS] [PLAN]
harmonic install <COMMAND>
Usage: nix-installer install [OPTIONS] [PLAN]
nix-installer install <COMMAND>
Commands:
linux-multi
@ -100,14 +100,14 @@ Commands:
Planners have their own options and defaults, sharing most of them in common:
```bash
$ ./harmonic install linux-multi --help
$ ./nix-installer install linux-multi --help
A standard Linux multi-user install
Usage: harmonic install linux-multi [OPTIONS]
Usage: nix-installer install linux-multi [OPTIONS]
Options:
--channels <channel>
Channel(s) to add [env: HARMONIC_CHANNEL=] [default: nixpkgs=https://nixos.org/channels/nixpkgs-unstable]
Channel(s) to add [env: NIX_INSTALLER_CHANNEL=] [default: nixpkgs=https://nixos.org/channels/nixpkgs-unstable]
--no-confirm
-v, --verbose...
@ -117,23 +117,23 @@ Options:
--logger <LOGGER>
Which logger to use [default: compact] [possible values: compact, full, pretty, json]
--modify-profile
Modify the user profile to automatically load nix [env: HARMONIC_NO_MODIFY_PROFILE=]
Modify the user profile to automatically load nix [env: NIX_INSTALLER_NO_MODIFY_PROFILE=]
--daemon-user-count <DAEMON_USER_COUNT>
Number of build users to create [env: HARMONIC_DAEMON_USER_COUNT=] [default: 32]
Number of build users to create [env: NIX_INSTALLER_DAEMON_USER_COUNT=] [default: 32]
--nix-build-group-name <NIX_BUILD_GROUP_NAME>
The Nix build group name [env: HARMONIC_NIX_BUILD_GROUP_NAME=] [default: nixbld]
The Nix build group name [env: NIX_INSTALLER_NIX_BUILD_GROUP_NAME=] [default: nixbld]
--nix-build-group-id <NIX_BUILD_GROUP_ID>
The Nix build group GID [env: HARMONIC_NIX_BUILD_GROUP_ID=] [default: 3000]
The Nix build group GID [env: NIX_INSTALLER_NIX_BUILD_GROUP_ID=] [default: 3000]
--nix-build-user-prefix <NIX_BUILD_USER_PREFIX>
The Nix build user prefix (user numbers will be postfixed) [env: HARMONIC_NIX_BUILD_USER_PREFIX=] [default: nixbld]
The Nix build user prefix (user numbers will be postfixed) [env: NIX_INSTALLER_NIX_BUILD_USER_PREFIX=] [default: nixbld]
--nix-build-user-id-base <NIX_BUILD_USER_ID_BASE>
The Nix build user base UID (ascending) [env: HARMONIC_NIX_BUILD_USER_ID_BASE=] [default: 3000]
The Nix build user base UID (ascending) [env: NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=] [default: 3000]
--nix-package-url <NIX_PACKAGE_URL>
The Nix package URL [env: HARMONIC_NIX_PACKAGE_URL=] [default: https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz]
The Nix package URL [env: NIX_INSTALLER_NIX_PACKAGE_URL=] [default: https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-x86_64-linux.tar.xz]
--extra-conf <EXTRA_CONF>
Extra configuration lines for `/etc/nix.conf` [env: HARMONIC_EXTRA_CONF=]
Extra configuration lines for `/etc/nix.conf` [env: NIX_INSTALLER_EXTRA_CONF=]
--force
If Harmonic should forcibly recreate files it finds existing [env: HARMONIC_FORCE=]
Forcibly recreate files it finds existing [env: NIX_INSTALLER_FORCE=]
-h, --help
Print help information
```
@ -141,25 +141,25 @@ Options:
Planners can be configured via environment variable, or by the command arguments.
```bash
$ HARMONIC_DAEMON_USER_COUNT=4 ./harmonic install linux-multi --nix-build-user-id-base 4000 --help
$ NIX_INSTALLER_DAEMON_USER_COUNT=4 ./nix-installer install linux-multi --nix-build-user-id-base 4000 --help
```
## Uninstalling
You can remove a Harmonic-installed Nix by running
You can remove a `nix-installer`-installed Nix by running
```bash
/nix/harmonic uninstall
/nix/nix-installer uninstall
```
## As a library
> We haven't published to [crates.io](https://crates.io/) yet. We plan to for 0.0.1.
Add `harmonic` to your dependencies:
Add `nix-installer` to your dependencies:
```bash
cargo add --git https://github.com/DeterminateSystems/harmonic
cargo add --git https://github.com/DeterminateSystems/nix-installer
```
> **Building a CLI?** Check out the `cli` feature flag for `clap` integration.
@ -167,19 +167,19 @@ cargo add --git https://github.com/DeterminateSystems/harmonic
Then it's possible to review the documentation:
```bash
cargo doc --open -p harmonic
cargo doc --open -p nix-installer
```
Documentation is also available via `nix` build:
```bash
nix build github:DeterminateSystems/harmonic#harmonic.doc
firefox result-doc/harmonic/index.html
nix build github:DeterminateSystems/nix-installer#nix-installer.doc
firefox result-doc/nix-installer/index.html
```
## As a Github Action
You can use Harmonic as a Github action like so:
You can use `nix-installer` as a Github action like so:
```yaml
on:
@ -194,9 +194,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/harmonic@main
uses: DeterminateSystems/nix-installer@main
with:
# Allow the installed Nix to make authenticated Github requests.
# If you skip this, you will likely get rate limited.
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run `nix build`
run: nix build .
```
```

View file

@ -48,18 +48,18 @@ inputs:
mac-root-disk:
description: The root disk of the target (Mac only)
required: false
nix-install-url:
description: A URL pointing to a harmonic `nix-install.sh` script
nix-installer-url:
description: A URL pointing to a `nix-installer.sh` script
required: true
default: https://install.determinate.systems/nix
local-root:
description: A local `harmonic` binary root, overrides the `nix-install` setting (binaries should be named `harmonic-$ARCH`, eg. `harmonic-x86_64-linux`)
description: A local `nix-installer` binary root, overrides the `nix-installer-url` setting (a `nix-installer.sh` should exist, binaries should be named `nix-installer-$ARCH`, eg. `nix-installer-x86_64-linux`)
required: false
logger:
description: The logger to use for install (eg. `pretty`, `json`, `full`, `compact`)
required: false
log-directives:
description: A list of Tracing directives, comma separated (eg. `harmonic=trace`, see https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives)
description: A list of Tracing directives, comma separated, `-`s replaced with `_` (eg. `nix_installer=trace`, see https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives)
required: false
backtrace:
description: The setting for `RUST_BACKTRACE` (see https://doc.rust-lang.org/std/backtrace/index.html#environment-variables)
@ -73,77 +73,77 @@ runs:
shell: bash
run: |
if [ -n "${{ inputs.channels }}" ]; then
export HARMONIC_CHANNELS=${{ inputs.channels }}
echo "Set HARMONIC_CHANNELS=$HARMONIC_CHANNELS"
export NIX_INSTALLER_CHANNELS=${{ inputs.channels }}
echo "Set NIX_INSTALLER_CHANNELS=$NIX_INSTALLER_CHANNELS"
fi
if [ -n "${{ inputs.modify-profile }}" ]; then
export HARMONIC_MODIFY_PROFILE=${{ inputs.modify-profile }}
echo "Set HARMONIC_MODIFY_PROFILE=$HARMONIC_MODIFY_PROFILE"
export NIX_INSTALLER_MODIFY_PROFILE=${{ inputs.modify-profile }}
echo "Set NIX_INSTALLER_MODIFY_PROFILE=$NIX_INSTALLER_MODIFY_PROFILE"
fi
if [ -n "${{ inputs.daemon-user-count }}" ]; then
export HARMONIC_DAEMON_USER_COUNT=${{ inputs.daemon-user-count }}
echo "Set HARMONIC_DAEMON_USER_COUNT=$HARMONIC_DAEMON_USER_COUNT"
export NIX_INSTALLER_DAEMON_USER_COUNT=${{ inputs.daemon-user-count }}
echo "Set NIX_INSTALLER_DAEMON_USER_COUNT=$NIX_INSTALLER_DAEMON_USER_COUNT"
fi
if [ -n "${{ inputs.nix-build-group-name }}" ]; then
export HARMONIC_NIX_BUILD_GROUP_NAME=${{ inputs.nix-build-group-name }}
echo "Set HARMONIC_NIX_BUILD_GROUP_NAME=$HARMONIC_NIX_BUILD_GROUP_NAME"
export NIX_INSTALLER_NIX_BUILD_GROUP_NAME=${{ inputs.nix-build-group-name }}
echo "Set NIX_INSTALLER_NIX_BUILD_GROUP_NAME=$NIX_INSTALLER_NIX_BUILD_GROUP_NAME"
fi
if [ -n "${{ inputs.nix-build-group-id }}" ]; then
export HARMONIC_NIX_BUILD_GROUP_ID=${{ inputs.nix-build-group-id }}
echo "Set HARMONIC_NIX_BUILD_GROUP_ID=$HARMONIC_NIX_BUILD_GROUP_ID"
export NIX_INSTALLER_NIX_BUILD_GROUP_ID=${{ inputs.nix-build-group-id }}
echo "Set NIX_INSTALLER_NIX_BUILD_GROUP_ID=$NIX_INSTALLER_NIX_BUILD_GROUP_ID"
fi
if [ -n "${{ inputs.nix-build-user-prefix }}" ]; then
export HARMONIC_NIX_BUILD_USER_ID_BASE=${{ inputs.nix-build-user-prefix }}
echo "Set HARMONIC_NIX_BUILD_USER_ID_BASE=$HARMONIC_NIX_BUILD_USER_ID_BASE"
export NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=${{ inputs.nix-build-user-prefix }}
echo "Set NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=$NIX_INSTALLER_NIX_BUILD_USER_ID_BASE"
fi
if [ -n "${{ inputs.nix-build-user-base }}" ]; then
export HARMONIC_NIX_BUILD_USER_PREFIX=${{ inputs.nix-build-user-base }}
echo "Set HARMONIC_NIX_BUILD_USER_PREFIX=$HARMONIC_NIX_BUILD_USER_PREFIX"
export NIX_INSTALLER_NIX_BUILD_USER_PREFIX=${{ inputs.nix-build-user-base }}
echo "Set NIX_INSTALLER_NIX_BUILD_USER_PREFIX=$NIX_INSTALLER_NIX_BUILD_USER_PREFIX"
fi
if [ -n "${{ inputs.nix-package-url }}" ]; then
export HARMONIC_NIX_PACKAGE_URL=${{ inputs.nix-package-url }}
echo "Set HARMONIC_NIX_PACKAGE_URL=$HARMONIC_NIX_PACKAGE_URL"
export NIX_INSTALLER_NIX_PACKAGE_URL=${{ inputs.nix-package-url }}
echo "Set NIX_INSTALLER_NIX_PACKAGE_URL=$NIX_INSTALLER_NIX_PACKAGE_URL"
fi
if [ -n "${{ inputs.extra-conf }}" ]; then
if [ -n "${{ inputs.github-token }}" ]; then
export HARMONIC_EXTRA_CONF="${{ inputs.extra-conf }}\naccess-tokens = github.com=${{ inputs.github-token }}"
export NIX_INSTALLER_EXTRA_CONF="${{ inputs.extra-conf }}\naccess-tokens = github.com=${{ inputs.github-token }}"
else
export HARMONIC_EXTRA_CONF="${{ inputs.extra-conf }}"
export NIX_INSTALLER_EXTRA_CONF="${{ inputs.extra-conf }}"
fi
echo "Set HARMONIC_EXTRA_CONF=$HARMONIC_EXTRA_CONF"
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
else
if [ -n "${{ inputs.github-token }}" ]; then
export HARMONIC_EXTRA_CONF="access-tokens = github.com=${{ inputs.github-token }}"
echo "Set HARMONIC_EXTRA_CONF=$HARMONIC_EXTRA_CONF"
export NIX_INSTALLER_EXTRA_CONF="access-tokens = github.com=${{ inputs.github-token }}"
echo "Set NIX_INSTALLER_EXTRA_CONF=$NIX_INSTALLER_EXTRA_CONF"
fi
fi
if [ -n "${{ inputs.mac-encrypt }}" ]; then
export HARMONIC_ENCRYPT=${{ inputs.mac-encrypt }}
echo "Set HARMONIC_ENCRYPT=$HARMONIC_ENCRYPT"
export NIX_INSTALLER_ENCRYPT=${{ inputs.mac-encrypt }}
echo "Set NIX_INSTALLER_ENCRYPT=$NIX_INSTALLER_ENCRYPT"
fi
if [ -n "${{ inputs.mac-case-sensitive }}" ]; then
export HARMONIC_CASE_SENSITIVE=${{ inputs.mac-case-sensitive }}
echo "Set HARMONIC_CASE_SENSITIVE=$HARMONIC_CASE_SENSITIVE"
export NIX_INSTALLER_CASE_SENSITIVE=${{ inputs.mac-case-sensitive }}
echo "Set NIX_INSTALLER_CASE_SENSITIVE=$NIX_INSTALLER_CASE_SENSITIVE"
fi
if [ -n "${{ inputs.mac-volume-label }}" ]; then
export HARMONIC_VOLUME_LABEL=${{ inputs.mac-volume-label }}
echo "Set HARMONIC_VOLUME_LABEL=$HARMONIC_VOLUME_LABEL"
export NIX_INSTALLER_VOLUME_LABEL=${{ inputs.mac-volume-label }}
echo "Set NIX_INSTALLER_VOLUME_LABEL=$NIX_INSTALLER_VOLUME_LABEL"
fi
if [ -n "${{ inputs.mac-root-disk }}" ]; then
export HARMONIC_ROOT_DISK=${{ inputs.mac-root-disk }}
echo "Set HARMONIC_ROOT_DISK=$HARMONIC_ROOT_DISK"
export NIX_INSTALLER_ROOT_DISK=${{ inputs.mac-root-disk }}
echo "Set NIX_INSTALLER_ROOT_DISK=$NIX_INSTALLER_ROOT_DISK"
fi
if [ -n "${{ inputs.local-root }}" ]; then
@ -158,27 +158,27 @@ runs:
while (! (: </dev/tcp/localhost/8000) &> /dev/null); do
sleep 1
done
export NIX_INSTALL_FORCE_ALLOW_HTTP="1"
echo "Set NIX_INSTALL_FORCE_ALLOW_HTTP=$NIX_INSTALL_FORCE_ALLOW_HTTP"
export NIX_INSTALL_URL=0.0.0.0:8000/nix-install.sh
echo "Set NIX_INSTALL_URL=$NIX_INSTALL_URL"
export NIX_INSTALL_BINARY_ROOT=http://0.0.0.0:8000/
echo "Set NIX_INSTALL_BINARY_ROOT=$NIX_INSTALL_BINARY_ROOT"
export NIX_INSTALL_FORCE_ALLOW_HTTP=1
echo "Set NIX_INSTALL_FORCE_ALLOW_HTTP=$NIX_INSTALL_FORCE_ALLOW_HTTP"
export NIX_INSTALLER_FORCE_ALLOW_HTTP="1"
echo "Set NIX_INSTALLER_FORCE_ALLOW_HTTP=$NIX_INSTALLER_FORCE_ALLOW_HTTP"
export NIX_INSTALLER_URL=0.0.0.0:8000/nix-installer.sh
echo "Set NIX_INSTALLER_URL=$NIX_INSTALLER_URL"
export NIX_INSTALLER_BINARY_ROOT=http://0.0.0.0:8000/
echo "Set NIX_INSTALLER_BINARY_ROOT=$NIX_INSTALLER_BINARY_ROOT"
export NIX_INSTALLER_FORCE_ALLOW_HTTP=1
echo "Set NIX_INSTALLER_FORCE_ALLOW_HTTP=$NIX_INSTALLER_FORCE_ALLOW_HTTP"
else
export NIX_INSTALL_URL=${{ inputs.nix-install-url }}
echo "Set NIX_INSTALL_URL=$NIX_INSTALL_URL"
export NIX_INSTALLER_URL=${{ inputs.nix-install-url }}
echo "Set NIX_INSTALLER_URL=$NIX_INSTALLER_URL"
fi
if [ -n "${{ inputs.logger }}" ]; then
export HARMONIC_LOGGER=${{ inputs.logger }}
echo "Set HARMONIC_LOGGER=$HARMONIC_LOGGER"
export NIX_INSTALLER_LOGGER=${{ inputs.logger }}
echo "Set NIX_INSTALLER_LOGGER=$NIX_INSTALLER_LOGGER"
fi
if [ -n "${{ inputs.log-directives }}" ]; then
export HARMONIC_LOG_DIRECTIVES=${{ inputs.log-directives }}
echo "Set HARMONIC_LOG_DIRECTIVES=$HARMONIC_LOG_DIRECTIVES"
export NIX_INSTALLER_LOG_DIRECTIVES=${{ inputs.log-directives }}
echo "Set NIX_INSTALLER_LOG_DIRECTIVES=$NIX_INSTALLER_LOG_DIRECTIVES"
fi
if [ -n "${{ inputs.backtrace }}" ]; then
@ -186,10 +186,10 @@ runs:
echo "Set RUST_BACKTRACE=$RUST_BACKTRACE"
fi
export HARMONIC_NO_CONFIRM=true
echo "Set HARMONIC_NO_CONFIRM=$HARMONIC_NO_CONFIRM"
export NIX_INSTALLER_NO_CONFIRM=true
echo "Set NIX_INSTALLER_NO_CONFIRM=$NIX_INSTALLER_NO_CONFIRM"
curl --retry 20 -L $NIX_INSTALL_URL | sh -s -- install ${{ inputs.planner }} ${{ inputs.extra-args }}
curl --retry 20 -L $NIX_INSTALLER_URL | sh -s -- install ${{ inputs.planner }} ${{ inputs.extra-args }}
if [ -n "$HTTP_PID" ]; then
kill $HTTP_PID

View file

@ -1,5 +1,5 @@
{
description = "harmonic";
description = "A Nix Installer";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
@ -53,7 +53,7 @@
rustc = toolchain;
};
sharedAttrs = {
pname = "harmonic";
pname = "nix-installer";
version = "0.0.0-unreleased";
src = self;
@ -74,21 +74,21 @@
'';
};
postInstall = ''
cp nix-install.sh $out/bin/nix-install.sh
cp nix-installer.sh $out/bin/nix-installer.sh
'';
};
in
rec {
harmonic = naerskLib.buildPackage sharedAttrs;
nix-installer = naerskLib.buildPackage sharedAttrs;
} // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "x86_64-linux") rec {
default = harmonicStatic;
harmonicStatic = naerskLib.buildPackage
default = nix-installer-static;
nix-installer-static = naerskLib.buildPackage
(sharedAttrs // {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
});
} // nixpkgs.lib.optionalAttrs (prev.hostPlatform.system == "aarch64-linux") rec {
default = harmonicStatic;
harmonicStatic = naerskLib.buildPackage
default = nix-installer-static;
nix-installer-static = naerskLib.buildPackage
(sharedAttrs // {
CARGO_BUILD_TARGET = "aarch64-unknown-linux-musl";
});
@ -153,15 +153,15 @@
packages = forAllSystems ({ system, pkgs, ... }:
{
inherit (pkgs) harmonic;
inherit (pkgs) nix-installer;
} // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
inherit (pkgs) harmonicStatic;
default = pkgs.harmonicStatic;
inherit (pkgs) nix-installer-static;
default = pkgs.nix-installer-static;
} // nixpkgs.lib.optionalAttrs (system == "aarch64-linux") {
inherit (pkgs) harmonicStatic;
default = pkgs.harmonicStatic;
inherit (pkgs) nix-installer-static;
default = pkgs.nix-installer-static;
} // nixpkgs.lib.optionalAttrs (pkgs.stdenv.isDarwin) {
default = pkgs.harmonic;
default = pkgs.nix-installer;
});
};
}

View file

@ -4,7 +4,7 @@
# This script is based off https://github.com/rust-lang/rustup/blob/8f6b53628ad996ad86f9c6225fa500cddf860905/rustup-init.sh
# This is just a little script that can be downloaded from the internet to
# install `nix-install`. It just does platform detection, downloads the installer
# install `nix-installer`. It just does platform detection, downloads the installer
# and runs it.
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
@ -14,15 +14,15 @@ if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
# The version of ksh93 that ships with many illumos systems does not
# support the "local" extension. Print a message rather than fail in
# subtle ways later on:
echo 'harmonic does not work with this ksh93 version; please try bash!' >&2
echo 'nix-installer does not work with this ksh93 version; please try bash!' >&2
exit 1
fi
set -u
# If NIX_INSTALL_BINARY_ROOT is unset or empty, default it.
NIX_INSTALL_BINARY_ROOT="${NIX_INSTALL_BINARY_ROOT:-https://install.determinate.systems/nix}"
# If NIX_INSTALLER_FORCE_ALLOW_HTTP is unset or empty, default it.
NIX_INSTALLER_BINARY_ROOT="${NIX_INSTALLER_BINARY_ROOT:-https://install.determinate.systems/nix}"
main() {
downloader --check
@ -44,7 +44,7 @@ main() {
;;
esac
local _url="${NIX_INSTALL_OVERRIDE_URL-${NIX_INSTALL_BINARY_ROOT}/harmonic-${_arch}${_ext}}"
local _url="${NIX_INSTALLER_OVERRIDE_URL-${NIX_INSTALLER_BINARY_ROOT}/nix-installer-${_arch}${_ext}}"
local _dir
if ! _dir="$(ensure mktemp -d)"; then
@ -52,7 +52,7 @@ main() {
# propagate exit status.
exit 1
fi
local _file="${_dir}/nix-install${_ext}"
local _file="${_dir}/nix-installer${_ext}"
local _ansi_escapes_are_valid=false
if [ -t 2 ]; then
@ -77,7 +77,7 @@ main() {
;;
esac
done
if [ "${HARMONIC_NO_CONFIRM-}" ]; then
if [ "${NIX_INSTALLER_NO_CONFIRM-}" ]; then
need_tty=no
fi
@ -92,7 +92,7 @@ main() {
ensure chmod u+x "$_file"
if [ ! -x "$_file" ]; then
printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./nix-install${_ext}." 1>&2
printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./nix-installer${_ext}." 1>&2
exit 1
fi
@ -201,7 +201,7 @@ get_architecture() {
}
say() {
printf 'harmonic: %s\n' "$1"
printf 'nix-installer: %s\n' "$1"
}
err() {
@ -261,7 +261,7 @@ downloader() {
get_ciphersuites_for_curl
_ciphersuites="$RETVAL"
if [ -n "$_ciphersuites" ]; then
if [ -n "${NIX_INSTALL_FORCE_ALLOW_HTTP-}" ]; then
if [ -n "${NIX_INSTALLER_FORCE_ALLOW_HTTP-}" ]; then
_err=$(curl $_retry --silent --show-error --fail --location "$1" --output "$2" 2>&1)
else
_err=$(curl $_retry --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)

View file

@ -129,7 +129,7 @@ impl Action for CreateGroup {
| OperatingSystem::Darwin => {
// TODO(@hoverbear): Make this actually work...
// Right now, our test machines do not have a secure token and cannot delete users.
tracing::warn!("Harmonic currently cannot delete groups on Mac due to https://github.com/DeterminateSystems/harmonic/issues/33. This is a no-op, installing with harmonic again will use the existing group.");
tracing::warn!("`nix-installer` currently cannot delete groups on Mac due to https://github.com/DeterminateSystems/nix-installer/issues/33. This is a no-op, installing with `nix-installer` again will use the existing group.");
// execute_command(Command::new("/usr/bin/dscl").args([
// ".",
// "-delete",

View file

@ -258,7 +258,7 @@ impl Action for CreateUser {
| OperatingSystem::Darwin => {
// TODO(@hoverbear): Make this actually work...
// Right now, our test machines do not have a secure token and cannot delete users.
tracing::warn!("Harmonic currently cannot delete groups on Mac due to https://github.com/DeterminateSystems/harmonic/issues/33. This is a no-op, installing with harmonic again will use the existing user.");
tracing::warn!("`nix-installer` currently cannot delete groups on Mac due to https://github.com/DeterminateSystems/nix-installer/issues/33. This is a no-op, installing with `nix-installer` again will use the existing user.");
// execute_command(Command::new("/usr/bin/dscl").args([
// ".",
// "-delete",

View file

@ -24,7 +24,7 @@ You can manually plan, execute, then revert an [`Action`] like so:
```rust,no_run
# async fn wrapper() {
use harmonic::action::base::CreateDirectory;
use nix_installer::action::base::CreateDirectory;
let mut action = CreateDirectory::plan("/nix", None, None, 0o0755, true).await.unwrap();
action.try_execute().await.unwrap();
action.try_revert().await.unwrap();
@ -46,7 +46,7 @@ A custom [`Action`] can be created then used in a custom [`Planner`](crate::plan
```rust,no_run
use std::{error::Error, collections::HashMap};
use tracing::{Span, span};
use harmonic::{
use nix_installer::{
InstallPlan,
settings::{CommonSettings, InstallSettingsError},
planner::{Planner, PlannerError, linux::SteamDeck},

View file

@ -1,7 +1,7 @@
use std::process::ExitCode;
use clap::Parser;
use harmonic::cli::CommandExecute;
use nix_installer::cli::CommandExecute;
#[tokio::main]
async fn main() -> color_eyre::Result<ExitCode> {
@ -13,7 +13,7 @@ async fn main() -> color_eyre::Result<ExitCode> {
})
.install()?;
let cli = harmonic::cli::HarmonicCli::parse();
let cli = nix_installer::cli::NixInstallerCli::parse();
cli.instrumentation.setup()?;

View file

@ -30,15 +30,15 @@ impl std::fmt::Display for Logger {
#[derive(clap::Args, Debug)]
pub struct Instrumentation {
/// Enable debug logs, -vv for trace
#[clap(short = 'v', env = "HARMONIC_VERBOSITY", long, action = clap::ArgAction::Count, global = true)]
#[clap(short = 'v', env = "NIX_INSTALLER_VERBOSITY", long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,
/// Which logger to use
#[clap(long, env = "HARMONIC_LOGGER", default_value_t = Default::default(), global = true)]
#[clap(long, env = "NIX_INSTALLER_LOGGER", default_value_t = Default::default(), global = true)]
pub logger: Logger,
/// Tracing directives
///
/// See https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives
#[clap(long = "log-directive", global = true, env = "HARMONIC_LOG_DIRECTIVES", value_delimiter = ',', num_args = 0..)]
#[clap(long = "log-directive", global = true, env = "NIX_INSTALLER_LOG_DIRECTIVES", value_delimiter = ',', num_args = 0..)]
pub log_directives: Vec<Directive>,
}
@ -137,7 +137,11 @@ impl<'a> Instrumentation {
_ => return Err(e).wrap_err_with(|| "parsing RUST_LOG directives"),
}
}
EnvFilter::try_new(&format!("{}={}", env!("CARGO_PKG_NAME"), self.log_level()))?
EnvFilter::try_new(&format!(
"{}={}",
env!("CARGO_PKG_NAME").replace("-", "_"),
self.log_level()
))?
},
};

View file

@ -12,7 +12,7 @@ use owo_colors::OwoColorize;
use std::{ffi::CString, process::ExitCode};
use tokio::sync::broadcast::{Receiver, Sender};
use self::subcommand::HarmonicSubcommand;
use self::subcommand::NixInstallerSubcommand;
#[async_trait::async_trait]
pub trait CommandExecute {
@ -24,16 +24,16 @@ pub trait CommandExecute {
/// Plans a Nix install, prompts for confirmation, then executes it
#[derive(Debug, Parser)]
#[clap(version)]
pub struct HarmonicCli {
pub struct NixInstallerCli {
#[clap(flatten)]
pub instrumentation: arg::Instrumentation,
#[clap(subcommand)]
pub subcommand: HarmonicSubcommand,
pub subcommand: NixInstallerSubcommand,
}
#[async_trait::async_trait]
impl CommandExecute for HarmonicCli {
impl CommandExecute for NixInstallerCli {
#[tracing::instrument(level = "debug", skip_all)]
async fn execute(self) -> eyre::Result<ExitCode> {
let Self {
@ -42,9 +42,9 @@ impl CommandExecute for HarmonicCli {
} = self;
match subcommand {
HarmonicSubcommand::Plan(plan) => plan.execute().await,
HarmonicSubcommand::Install(install) => install.execute().await,
HarmonicSubcommand::Uninstall(revert) => revert.execute().await,
NixInstallerSubcommand::Plan(plan) => plan.execute().await,
NixInstallerSubcommand::Install(install) => install.execute().await,
NixInstallerSubcommand::Uninstall(revert) => revert.execute().await,
}
}
}
@ -88,7 +88,7 @@ pub fn ensure_root() -> eyre::Result<()> {
if !is_root() {
eprintln!(
"{}",
"Harmonic needs to run as `root`, attempting to escalate now via `sudo`..."
"`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`..."
.yellow()
.dimmed()
);
@ -106,7 +106,7 @@ pub fn ensure_root() -> eyre::Result<()> {
// CI
"GITHUB_PATH" => true,
// Our own environments
key if key.starts_with("HARMONIC") => true,
key if key.starts_with("NIX_INSTALLER") => true,
_ => false,
};
if preserve {
@ -127,7 +127,7 @@ pub fn ensure_root() -> eyre::Result<()> {
tracing::trace!("Execvp'ing `{sudo_cstring:?}` with args `{arg_vec_cstring:?}`");
nix::unistd::execvp(&sudo_cstring, &arg_vec_cstring)
.wrap_err("Executing Harmonic as `root` via `sudo`")?;
.wrap_err("Executing `nix-installer` as `root` via `sudo`")?;
}
Ok(())
}

View file

@ -18,13 +18,13 @@ use owo_colors::OwoColorize;
/// Execute an install (possibly using an existing plan)
///
/// To pass custom options, select a planner, for example `harmonic install linux-multi --help`
/// To pass custom options, select a planner, for example `nix-installer install linux-multi --help`
#[derive(Debug, Parser)]
#[command(args_conflicts_with_subcommands = true)]
pub struct Install {
#[clap(
long,
env = "HARMONIC_NO_CONFIRM",
env = "NIX_INSTALLER_NO_CONFIRM",
action(ArgAction::SetTrue),
default_value = "false",
global = true
@ -36,13 +36,13 @@ pub struct Install {
#[clap(
long,
env = "HARMONIC_EXPLAIN",
env = "NIX_INSTALLER_EXPLAIN",
action(ArgAction::SetTrue),
default_value = "false",
global = true
)]
pub explain: bool,
#[clap(env = "HARMONIC_PLAN")]
#[clap(env = "NIX_INSTALLER_PLAN")]
pub plan: Option<PathBuf>,
#[clap(subcommand)]

View file

@ -6,7 +6,7 @@ mod uninstall;
use uninstall::Uninstall;
#[derive(Debug, clap::Subcommand)]
pub enum HarmonicSubcommand {
pub enum NixInstallerSubcommand {
Plan(Plan),
Install(Install),
Uninstall(Uninstall),

View file

@ -13,7 +13,7 @@ use crate::cli::CommandExecute;
pub struct Plan {
#[clap(subcommand)]
pub planner: Option<BuiltinPlanner>,
#[clap(env = "HARMONIC_PLAN", default_value = "/dev/stdout")]
#[clap(env = "NIX_INSTALLER_PLAN", default_value = "/dev/stdout")]
pub output: PathBuf,
}

View file

@ -17,12 +17,12 @@ use rand::Rng;
use crate::cli::{interaction, CommandExecute};
/// Uninstall a previously installed Nix (only Harmonic done installs supported)
/// Uninstall a previously installed Nix (only `nix-installer` done installs supported)
#[derive(Debug, Parser)]
pub struct Uninstall {
#[clap(
long,
env = "HARMONIC_NO_CONFIRM",
env = "NIX_INSTALLER_NO_CONFIRM",
action(ArgAction::SetTrue),
default_value = "false",
global = true
@ -30,7 +30,7 @@ pub struct Uninstall {
pub no_confirm: bool,
#[clap(
long,
env = "HARMONIC_EXPLAIN",
env = "NIX_INSTALLER_EXPLAIN",
action(ArgAction::SetTrue),
default_value = "false",
global = true
@ -52,14 +52,14 @@ impl CommandExecute for Uninstall {
ensure_root()?;
// During install, `harmonic` will store a copy of itself in `/nix/harmonic`
// If the user opted to run that particular copy of Harmonic to do this uninstall,
// During install, `nix-installer` will store a copy of itself in `/nix/nix-installer`
// If the user opted to run that particular copy of `nix-installer` to do this uninstall,
// well, we have a problem, since the binary would delete itself.
// Instead, detect if we're in that location, if so, move the binary and `execv` it.
if let Ok(current_exe) = std::env::current_exe() {
if current_exe.as_path() == Path::new("/nix/harmonic") {
if current_exe.as_path() == Path::new("/nix/nix-installer") {
tracing::debug!(
"Detected uninstall from `/nix/harmonic`, moving executable and re-executing"
"Detected uninstall from `/nix/nix-installer`, moving executable and re-executing"
);
let temp = std::env::temp_dir();
let random_trailer: String = {
@ -76,10 +76,10 @@ impl CommandExecute for Uninstall {
})
.collect()
};
let temp_exe = temp.join(&format!("harmonic-{random_trailer}"));
let temp_exe = temp.join(&format!("nix-installer-{random_trailer}"));
tokio::fs::copy(&current_exe, &temp_exe)
.await
.wrap_err("Copying harmonic to tempdir")?;
.wrap_err("Copying nix-installer to tempdir")?;
let args = std::env::args();
let mut arg_vec_cstring = vec![];
for arg in args {
@ -90,24 +90,24 @@ impl CommandExecute for Uninstall {
tracing::trace!("Execv'ing `{temp_exe_cstring:?} {arg_vec_cstring:?}`");
nix::unistd::execv(&temp_exe_cstring, &arg_vec_cstring)
.wrap_err("Executing copied Harmonic")?;
.wrap_err("Executing copied `nix-installer`")?;
}
}
// During install, `harmonic` will store a copy of itself in `/nix/harmonic`
// If the user opted to run that particular copy of Harmonic to do this uninstall,
// During install, `nix-installer` will store a copy of itself in `/nix/nix-installer`
// If the user opted to run that particular copy of `nix-installer` to do this uninstall,
// well, we have a problem, since the binary would delete itself.
// Instead, detect if we're in that location, if so, move the binary and `execv` it.
if let Ok(current_exe) = std::env::current_exe() {
if current_exe.as_path() == Path::new("/nix/harmonic") {
if current_exe.as_path() == Path::new("/nix/nix-installer") {
tracing::debug!(
"Detected uninstall from `/nix/harmonic`, moving executable and re-executing"
"Detected uninstall from `/nix/nix-installer`, moving executable and re-executing"
);
let temp = std::env::temp_dir();
let temp_exe = temp.join("harmonic");
let temp_exe = temp.join("nix-installer");
tokio::fs::copy(&current_exe, &temp_exe)
.await
.wrap_err("Copying harmonic to tempdir")?;
.wrap_err("Copying `nix-installer` to tempdir")?;
let args = std::env::args();
let mut arg_vec_cstring = vec![];
for arg in args {
@ -117,7 +117,7 @@ impl CommandExecute for Uninstall {
.wrap_err("Making C string of executable path")?;
nix::unistd::execv(&temp_exe_cstring, &arg_vec_cstring)
.wrap_err("Executing copied Harmonic")?;
.wrap_err("Executing copied `nix-installer`")?;
}
}

View file

@ -4,7 +4,7 @@ use crate::{action::ActionError, planner::PlannerError, settings::InstallSetting
/// An error occurring during a call defined in this crate
#[derive(thiserror::Error, Debug)]
pub enum HarmonicError {
pub enum NixInstallerError {
/// An error originating from an [`Action`](crate::action::Action)
#[error("Error executing action")]
Action(
@ -16,7 +16,7 @@ pub enum HarmonicError {
#[error("Recording install receipt")]
RecordingReceipt(PathBuf, #[source] std::io::Error),
/// An error while writing copying the binary into the `/nix` folder
#[error("Copying `harmonic` binary into `/nix`")]
#[error("Copying `nix-installer` binary into `/nix`")]
CopyingSelf(
#[source]
#[from]
@ -59,17 +59,17 @@ pub(crate) trait HasExpectedErrors: std::error::Error + Sized + Send + Sync {
fn expected<'a>(&'a self) -> Option<Box<dyn std::error::Error + 'a>>;
}
impl HasExpectedErrors for HarmonicError {
impl HasExpectedErrors for NixInstallerError {
fn expected<'a>(&'a self) -> Option<Box<dyn std::error::Error + 'a>> {
match self {
HarmonicError::Action(action_error) => action_error.expected(),
HarmonicError::RecordingReceipt(_, _) => None,
HarmonicError::CopyingSelf(_) => None,
HarmonicError::SerializingReceipt(_) => None,
this @ HarmonicError::Cancelled => Some(Box::new(this)),
HarmonicError::SemVer(_) => None,
HarmonicError::Planner(planner_error) => planner_error.expected(),
HarmonicError::InstallSettings(_) => None,
NixInstallerError::Action(action_error) => action_error.expected(),
NixInstallerError::RecordingReceipt(_, _) => None,
NixInstallerError::CopyingSelf(_) => None,
NixInstallerError::SerializingReceipt(_) => None,
this @ NixInstallerError::Cancelled => Some(Box::new(this)),
NixInstallerError::SemVer(_) => None,
NixInstallerError::Planner(planner_error) => planner_error.expected(),
NixInstallerError::InstallSettings(_) => None,
}
}
}

View file

@ -1,6 +1,6 @@
/*! A [Nix](https://github.com/NixOS/nix) installer and uninstaller.
Harmonic breaks down into three main concepts:
`nix-installer` breaks down into three main concepts:
* [`Action`]: An executable or revertable step, possibly orcestrating sub-[`Action`]s using things
like [`JoinSet`](tokio::task::JoinSet)s.
@ -10,12 +10,12 @@ Harmonic breaks down into three main concepts:
It is possible to create custom [`Action`]s and [`Planner`](planner::Planner)s to suit the needs of your project, team, or organization.
In the simplest case, Harmonic can be asked to determine a default plan for the platform and install
In the simplest case, `nix-installer` can be asked to determine a default plan for the platform and install
it, uninstalling if anything goes wrong:
```rust,no_run
use std::error::Error;
use harmonic::InstallPlan;
use nix_installer::InstallPlan;
# async fn default_install() -> color_eyre::Result<()> {
let mut plan = InstallPlan::default().await?;
@ -38,7 +38,7 @@ Sometimes choosing a specific plan is desired:
```rust,no_run
use std::error::Error;
use harmonic::{InstallPlan, planner::{Planner, linux::SteamDeck}};
use nix_installer::{InstallPlan, planner::{Planner, linux::SteamDeck}};
# async fn chosen_planner_install() -> color_eyre::Result<()> {
let planner = SteamDeck::default().await?;
@ -81,7 +81,7 @@ use std::{ffi::OsStr, process::Output};
use action::Action;
pub use channel_value::ChannelValue;
pub use error::HarmonicError;
pub use error::NixInstallerError;
pub use plan::InstallPlan;
use planner::BuiltinPlanner;

View file

@ -3,7 +3,7 @@ use std::{path::PathBuf, str::FromStr};
use crate::{
action::{Action, ActionDescription, StatefulAction},
planner::{BuiltinPlanner, Planner},
HarmonicError,
NixInstallerError,
};
use owo_colors::OwoColorize;
use semver::{Version, VersionReq};
@ -27,7 +27,7 @@ pub struct InstallPlan {
}
impl InstallPlan {
pub async fn default() -> Result<Self, HarmonicError> {
pub async fn default() -> Result<Self, NixInstallerError> {
let planner = BuiltinPlanner::default().await?.boxed();
let actions = planner.plan().await?;
@ -38,7 +38,7 @@ impl InstallPlan {
})
}
pub async fn plan<P>(planner: P) -> Result<Self, HarmonicError>
pub async fn plan<P>(planner: P) -> Result<Self, NixInstallerError>
where
P: Planner + 'static,
{
@ -50,7 +50,7 @@ impl InstallPlan {
})
}
#[tracing::instrument(level = "debug", skip_all)]
pub fn describe_install(&self, explain: bool) -> Result<String, HarmonicError> {
pub fn describe_install(&self, explain: bool) -> Result<String, NixInstallerError> {
let Self {
planner,
actions,
@ -111,7 +111,7 @@ impl InstallPlan {
pub async fn install(
&mut self,
cancel_channel: impl Into<Option<Receiver<()>>>,
) -> Result<(), HarmonicError> {
) -> Result<(), NixInstallerError> {
let Self {
version: _,
actions,
@ -130,7 +130,7 @@ impl InstallPlan {
if let Err(err) = write_receipt(self.clone()).await {
tracing::error!("Error saving receipt: {:?}", err);
}
return Err(HarmonicError::Cancelled);
return Err(NixInstallerError::Cancelled);
}
}
@ -139,19 +139,19 @@ impl InstallPlan {
if let Err(err) = write_receipt(self.clone()).await {
tracing::error!("Error saving receipt: {:?}", err);
}
return Err(HarmonicError::Action(err));
return Err(NixInstallerError::Action(err));
}
}
write_receipt(self.clone()).await?;
copy_self_to_nix_store()
.await
.map_err(|e| HarmonicError::CopyingSelf(e))?;
.map_err(|e| NixInstallerError::CopyingSelf(e))?;
Ok(())
}
#[tracing::instrument(level = "debug", skip_all)]
pub fn describe_uninstall(&self, explain: bool) -> Result<String, HarmonicError> {
pub fn describe_uninstall(&self, explain: bool) -> Result<String, NixInstallerError> {
let Self {
version: _,
planner,
@ -213,7 +213,7 @@ impl InstallPlan {
pub async fn uninstall(
&mut self,
cancel_channel: impl Into<Option<Receiver<()>>>,
) -> Result<(), HarmonicError> {
) -> Result<(), NixInstallerError> {
let Self {
version: _,
actions,
@ -232,7 +232,7 @@ impl InstallPlan {
if let Err(err) = write_receipt(self.clone()).await {
tracing::error!("Error saving receipt: {:?}", err);
}
return Err(HarmonicError::Cancelled);
return Err(NixInstallerError::Cancelled);
}
}
@ -241,7 +241,7 @@ impl InstallPlan {
if let Err(err) = write_receipt(self.clone()).await {
tracing::error!("Error saving receipt: {:?}", err);
}
return Err(HarmonicError::Action(err));
return Err(NixInstallerError::Action(err));
}
}
@ -249,22 +249,22 @@ impl InstallPlan {
}
}
async fn write_receipt(plan: InstallPlan) -> Result<(), HarmonicError> {
async fn write_receipt(plan: InstallPlan) -> Result<(), NixInstallerError> {
tokio::fs::create_dir_all("/nix")
.await
.map_err(|e| HarmonicError::RecordingReceipt(PathBuf::from("/nix"), e))?;
.map_err(|e| NixInstallerError::RecordingReceipt(PathBuf::from("/nix"), e))?;
let install_receipt_path = PathBuf::from(RECEIPT_LOCATION);
let self_json =
serde_json::to_string_pretty(&plan).map_err(HarmonicError::SerializingReceipt)?;
serde_json::to_string_pretty(&plan).map_err(NixInstallerError::SerializingReceipt)?;
tokio::fs::write(&install_receipt_path, self_json)
.await
.map_err(|e| HarmonicError::RecordingReceipt(install_receipt_path, e))?;
Result::<(), HarmonicError>::Ok(())
.map_err(|e| NixInstallerError::RecordingReceipt(install_receipt_path, e))?;
Result::<(), NixInstallerError>::Ok(())
}
fn current_version() -> Result<Version, semver::Error> {
let harmonic_version_str = env!("CARGO_PKG_VERSION");
Version::from_str(harmonic_version_str)
let nix_installer_version_str = env!("CARGO_PKG_VERSION");
Version::from_str(nix_installer_version_str)
}
fn ensure_version<'de, D: Deserializer<'de>>(d: D) -> Result<Version, D::Error> {
@ -274,16 +274,16 @@ fn ensure_version<'de, D: Deserializer<'de>>(d: D) -> Result<Version, D::Error>
"Could not parse version `{plan_version}` as a version requirement, please report this",
))
})?;
let harmonic_version = current_version().map_err(|_e| {
let nix_installer_version = current_version().map_err(|_e| {
D::Error::custom(&format!(
"Could not parse Harmonic's version `{}` as a valid version according to Semantic Versioning, therefore the plan version ({plan_version}) compatibility cannot be checked", env!("CARGO_PKG_VERSION")
"Could not parse `nix-installer`'s version `{}` as a valid version according to Semantic Versioning, therefore the plan version ({plan_version}) compatibility cannot be checked", env!("CARGO_PKG_VERSION")
))
})?;
if req.matches(&harmonic_version) {
if req.matches(&nix_installer_version) {
Ok(plan_version)
} else {
Err(D::Error::custom(&format!(
"This version of Harmonic ({harmonic_version}) is not compatible with this plan's version ({plan_version}), check for a compatible version at `/nix/harmonic` or download the matching release from https://github.com/DeterminateSystems/harmonic/releases",
"This version of `nix-installer` ({nix_installer_version}) is not compatible with this plan's version ({plan_version}), check for a compatible version at `/nix/nix-installer` or download the matching release from https://github.com/DeterminateSystems/nix-installer/releases",
)))
}
}
@ -291,7 +291,7 @@ fn ensure_version<'de, D: Deserializer<'de>>(d: D) -> Result<Version, D::Error>
#[tracing::instrument(level = "debug")]
async fn copy_self_to_nix_store() -> Result<(), std::io::Error> {
let path = std::env::current_exe()?;
tokio::fs::copy(path, "/nix/harmonic").await?;
tokio::fs::copy(path, "/nix/nix-installer").await?;
Ok(())
}
@ -299,10 +299,10 @@ async fn copy_self_to_nix_store() -> Result<(), std::io::Error> {
mod test {
use semver::Version;
use crate::{planner::BuiltinPlanner, HarmonicError, InstallPlan};
use crate::{planner::BuiltinPlanner, InstallPlan, NixInstallerError};
#[tokio::test]
async fn ensure_version_allows_compatible() -> Result<(), HarmonicError> {
async fn ensure_version_allows_compatible() -> Result<(), NixInstallerError> {
let planner = BuiltinPlanner::default().await?;
let good_version = Version::parse(env!("CARGO_PKG_VERSION"))?;
let value = serde_json::json!({
@ -316,7 +316,7 @@ mod test {
}
#[tokio::test]
async fn ensure_version_denies_incompatible() -> Result<(), HarmonicError> {
async fn ensure_version_denies_incompatible() -> Result<(), NixInstallerError> {
let planner = BuiltinPlanner::default().await?;
let bad_version = Version::parse("9999999999999.9999999999.99999999")?;
let value = serde_json::json!({

View file

@ -31,7 +31,7 @@ pub struct DarwinMulti {
long,
action(ArgAction::Set),
default_value = "false",
env = "HARMONIC_ENCRYPT"
env = "NIX_INSTALLER_ENCRYPT"
)
)]
pub encrypt: Option<bool>,
@ -42,18 +42,18 @@ pub struct DarwinMulti {
long,
action(ArgAction::SetTrue),
default_value = "false",
env = "HARMONIC_CASE_SENSITIVE"
env = "NIX_INSTALLER_CASE_SENSITIVE"
)
)]
pub case_sensitive: bool,
/// The label for the created APFS volume
#[cfg_attr(
feature = "cli",
clap(long, default_value = "Nix Store", env = "HARMONIC_VOLUME_LABEL")
clap(long, default_value = "Nix Store", env = "NIX_INSTALLER_VOLUME_LABEL")
)]
pub volume_label: String,
/// The root disk of the target
#[cfg_attr(feature = "cli", clap(long, env = "HARMONIC_ROOT_DISK"))]
#[cfg_attr(feature = "cli", clap(long, env = "NIX_INSTALLER_ROOT_DISK"))]
pub root_disk: Option<String>,
}

View file

@ -31,7 +31,7 @@ impl Planner for LinuxMulti {
}
async fn plan(&self) -> Result<Vec<StatefulAction<Box<dyn Action>>>, PlannerError> {
// If on NixOS, running `harmonic` is pointless
// If on NixOS, running `nix_installer` is pointless
// NixOS always sets up this file as part of setting up /etc itself: https://github.com/NixOS/nixpkgs/blob/bdd39e5757d858bd6ea58ed65b4a2e52c8ed11ca/nixos/modules/system/etc/setup-etc.pl#L145
if Path::new("/etc/NIXOS").exists() {
return Err(PlannerError::NixOs);

View file

@ -56,7 +56,7 @@ Repeated step:
-device virtio-net-pci,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22
```
3. **Do your testing!** You can `ssh deck@localhost -p 2222` in and use `rsync -e 'ssh -p 2222' result/bin/harmonic deck@localhost:harmonic` to send a harmonic build.
3. **Do your testing!** You can `ssh deck@localhost -p 2222` in and use `rsync -e 'ssh -p 2222' result/bin/nix-installer deck@localhost:nix-installer` to send a `nix-installer build.
4. Delete `steamos-hack.qcow2`
*/
use std::{collections::HashMap, path::PathBuf};
@ -80,7 +80,7 @@ pub struct SteamDeck {
feature = "cli",
clap(
long,
env = "HARMONIC_STEAM_DECK_PERSISTENCE",
env = "NIX_INSTALLER_STEAM_DECK_PERSISTENCE",
default_value = "/home/nix"
)
)]

View file

@ -13,7 +13,7 @@ A custom [`Planner`] can be created:
```rust,no_run
use std::{error::Error, collections::HashMap};
use harmonic::{
use nix_installer::{
InstallPlan,
settings::{CommonSettings, InstallSettingsError},
planner::{Planner, PlannerError, linux::SteamDeck},
@ -83,7 +83,7 @@ use crate::{
action::{ActionError, StatefulAction},
error::HasExpectedErrors,
settings::{CommonSettings, InstallSettingsError},
Action, HarmonicError, InstallPlan,
Action, InstallPlan, NixInstallerError,
};
/// Something which can be used to plan out an [`InstallPlan`]
@ -154,7 +154,7 @@ impl BuiltinPlanner {
Ok(built)
}
pub async fn plan(self) -> Result<InstallPlan, HarmonicError> {
pub async fn plan(self) -> Result<InstallPlan, NixInstallerError> {
match self {
BuiltinPlanner::LinuxMulti(planner) => InstallPlan::plan(planner).await,
BuiltinPlanner::DarwinMulti(planner) => InstallPlan::plan(planner).await,
@ -173,8 +173,8 @@ impl BuiltinPlanner {
/// An error originating from a [`Planner`]
#[derive(thiserror::Error, Debug)]
pub enum PlannerError {
/// Harmonic does not have a default planner for the target architecture right now
#[error("Harmonic does not have a default planner for the `{0}` architecture right now, pass a specific archetype")]
/// `nix-installer` does not have a default planner for the target architecture right now
#[error("`nix-installer` does not have a default planner for the `{0}` architecture right now, pass a specific archetype")]
UnsupportedArchitecture(target_lexicon::Triple),
/// Error executing action
#[error("Error executing action")]
@ -190,7 +190,7 @@ pub enum PlannerError {
#[error(transparent)]
Plist(#[from] plist::Error),
/// A Linux SELinux related error
#[error("This installer doesn't yet support SELinux in `Enforcing` mode. If SELinux is important to you, please see https://github.com/DeterminateSystems/harmonic/issues/124. You can also try again after setting SELinux to `Permissive` mode with `setenforce Permissive`")]
#[error("This installer doesn't yet support SELinux in `Enforcing` mode. If SELinux is important to you, please see https://github.com/DeterminateSystems/nix-installer/issues/124. You can also try again after setting SELinux to `Permissive` mode with `setenforce Permissive`")]
SelinuxEnforcing,
/// A UTF-8 related error
#[error("UTF-8 error")]

View file

@ -38,7 +38,7 @@ pub struct CommonSettings {
value_parser,
name = "channel",
action = clap::ArgAction::Append,
env = "HARMONIC_CHANNELS",
env = "NIX_INSTALLER_CHANNELS",
default_value = "nixpkgs=https://nixos.org/channels/nixpkgs-unstable",
)
)]
@ -52,7 +52,7 @@ pub struct CommonSettings {
action(ArgAction::SetFalse),
default_value = "true",
global = true,
env = "HARMONIC_NO_MODIFY_PROFILE",
env = "NIX_INSTALLER_NO_MODIFY_PROFILE",
name = "no-modify-profile"
)
)]
@ -64,7 +64,7 @@ pub struct CommonSettings {
clap(
long,
default_value = "32",
env = "HARMONIC_DAEMON_USER_COUNT",
env = "NIX_INSTALLER_DAEMON_USER_COUNT",
global = true
)
)]
@ -76,7 +76,7 @@ pub struct CommonSettings {
clap(
long,
default_value = "nixbld",
env = "HARMONIC_NIX_BUILD_GROUP_NAME",
env = "NIX_INSTALLER_NIX_BUILD_GROUP_NAME",
global = true
)
)]
@ -88,7 +88,7 @@ pub struct CommonSettings {
clap(
long,
default_value_t = 3000,
env = "HARMONIC_NIX_BUILD_GROUP_ID",
env = "NIX_INSTALLER_NIX_BUILD_GROUP_ID",
global = true
)
)]
@ -97,7 +97,7 @@ pub struct CommonSettings {
/// The Nix build user prefix (user numbers will be postfixed)
#[cfg_attr(
feature = "cli",
clap(long, env = "HARMONIC_NIX_BUILD_USER_PREFIX", global = true)
clap(long, env = "NIX_INSTALLER_NIX_BUILD_USER_PREFIX", global = true)
)]
#[cfg_attr(
all(target_os = "macos", feature = "cli"),
@ -112,7 +112,7 @@ pub struct CommonSettings {
/// The Nix build user base UID (ascending)
#[cfg_attr(
feature = "cli",
clap(long, env = "HARMONIC_NIX_BUILD_USER_ID_BASE", global = true)
clap(long, env = "NIX_INSTALLER_NIX_BUILD_USER_ID_BASE", global = true)
)]
#[cfg_attr(all(target_os = "macos", feature = "cli"), clap(default_value_t = 300))]
#[cfg_attr(
@ -124,7 +124,7 @@ pub struct CommonSettings {
/// The Nix package URL
#[cfg_attr(
feature = "cli",
clap(long, env = "HARMONIC_NIX_PACKAGE_URL", global = true)
clap(long, env = "NIX_INSTALLER_NIX_PACKAGE_URL", global = true)
)]
#[cfg_attr(
all(target_os = "macos", target_arch = "x86_64", feature = "cli"),
@ -153,10 +153,10 @@ pub struct CommonSettings {
pub(crate) nix_package_url: Url,
/// Extra configuration lines for `/etc/nix.conf`
#[cfg_attr(feature = "cli", clap(long, action = ArgAction::Set, num_args = 0.., value_delimiter = ',', env = "HARMONIC_EXTRA_CONF", global = true))]
#[cfg_attr(feature = "cli", clap(long, action = ArgAction::Set, num_args = 0.., value_delimiter = ',', env = "NIX_INSTALLER_EXTRA_CONF", global = true))]
pub extra_conf: Vec<String>,
/// If Harmonic should forcibly recreate files it finds existing
/// If `nix-installer` should forcibly recreate files it finds existing
#[cfg_attr(
feature = "cli",
clap(
@ -164,7 +164,7 @@ pub struct CommonSettings {
action(ArgAction::SetTrue),
default_value = "false",
global = true,
env = "HARMONIC_FORCE"
env = "NIX_INSTALLER_FORCE"
)
)]
pub(crate) force: bool,
@ -341,7 +341,7 @@ impl CommonSettings {
self
}
/// If Harmonic should forcibly recreate files it finds existing
/// If `nix-installer` should forcibly recreate files it finds existing
pub fn force(&mut self, force: bool) -> &mut Self {
self.force = force;
self
@ -351,8 +351,8 @@ impl CommonSettings {
/// An error originating from a [`Planner::settings`](crate::planner::Planner::settings)
#[derive(thiserror::Error, Debug)]
pub enum InstallSettingsError {
/// Harmonic does not support the architecture right now
#[error("Harmonic does not support the `{0}` architecture right now")]
/// `nix-installer` does not support the architecture right now
#[error("`nix-installer` does not support the `{0}` architecture right now")]
UnsupportedArchitecture(target_lexicon::Triple),
/// Parsing URL
#[error("Parsing URL")]

View file

@ -1,11 +1,11 @@
use harmonic::InstallPlan;
use nix_installer::InstallPlan;
const LINUX_MULTI: &str = include_str!("./fixtures/linux/linux-multi.json");
const STEAM_DECK: &str = include_str!("./fixtures/linux/steam-deck.json");
const DARWIN_MULTI: &str = include_str!("./fixtures/darwin/darwin-multi.json");
// Ensure existing plans still parse
// If this breaks and you need to update the fixture, disable these tests, bump harmonic to a new version, and update the plans.
// If this breaks and you need to update the fixture, disable these tests, bump `nix_installer` to a new version, and update the plans.
#[test]
fn plan_compat_linux_multi() -> eyre::Result<()> {
let _: InstallPlan = serde_json::from_str(LINUX_MULTI)?;
@ -13,7 +13,7 @@ fn plan_compat_linux_multi() -> eyre::Result<()> {
}
// Ensure existing plans still parse
// If this breaks and you need to update the fixture, disable these tests, bump harmonic to a new version, and update the plans.
// If this breaks and you need to update the fixture, disable these tests, bump `nix_installer` to a new version, and update the plans.
#[test]
fn plan_compat_steam_deck() -> eyre::Result<()> {
let _: InstallPlan = serde_json::from_str(STEAM_DECK)?;
@ -21,7 +21,7 @@ fn plan_compat_steam_deck() -> eyre::Result<()> {
}
// Ensure existing plans still parse
// If this breaks and you need to update the fixture, disable these tests, bump harmonic to a new version, and update the plans.
// If this breaks and you need to update the fixture, disable these tests, bump `nix_installer` to a new version, and update the plans.
#[test]
fn plan_compat_darwin_multi() -> eyre::Result<()> {
let _: InstallPlan = serde_json::from_str(DARWIN_MULTI)?;