From 220e252230461a4b5d75fdc1729ca96c0c4c9d40 Mon Sep 17 00:00:00 2001 From: Kate Temkin Date: Tue, 2 Apr 2024 15:40:06 -0600 Subject: [PATCH] upload a baseline that's been de-detsys'd --- .buildkite/pipeline.yml | 51 --- .github/PULL_REQUEST_TEMPLATE.md | 22 -- .github/dependabot.yml | 10 - .github/workflows/ci.yml | 340 ------------------ .github/workflows/release-branches.yml | 46 --- .github/workflows/release-prs.yml | 55 --- .github/workflows/release-tags.yml | 47 --- .github/workflows/update.yml | 20 -- .gitignore | 3 +- CODE_OF_CONDUCT.md | 3 +- CONTRIBUTING.md | 37 +- Cargo.lock | 88 ++--- Cargo.toml | 11 +- README.md | 252 +++---------- flake.nix | 42 +-- nix-installer.sh | 18 +- nix/tests/container-test/default/Dockerfile | 8 +- src/action/base/create_or_merge_nix_config.rs | 2 +- src/action/common/place_nix_configuration.rs | 2 +- src/action/macos/create_nix_hook_service.rs | 4 +- src/action/mod.rs | 91 +---- .../{nix-installer.rs => lix-installer.rs} | 4 +- src/cli/mod.rs | 9 +- src/cli/subcommand/install.rs | 12 +- src/cli/subcommand/uninstall.rs | 4 +- src/diagnostics.rs | 277 -------------- src/error.rs | 40 +-- src/lib.rs | 12 +- src/plan.rs | 95 +---- src/planner/linux.rs | 13 - src/planner/macos.rs | 14 - src/planner/mod.rs | 49 +-- src/planner/ostree.rs | 13 - src/planner/steam_deck.rs | 14 - src/self_test.rs | 21 -- src/settings.rs | 65 ---- tests/fixtures/linux/linux.json | 2 - tests/fixtures/linux/steam-deck.json | 2 - tests/fixtures/macos/macos.json | 2 - tests/plan.rs | 2 +- upload_s3.sh | 71 ---- 41 files changed, 180 insertions(+), 1693 deletions(-) delete mode 100644 .buildkite/pipeline.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/release-branches.yml delete mode 100644 .github/workflows/release-prs.yml delete mode 100644 .github/workflows/release-tags.yml delete mode 100644 .github/workflows/update.yml rename src/bin/{nix-installer.rs => lix-installer.rs} (87%) delete mode 100644 src/diagnostics.rs delete mode 100755 upload_s3.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index db9c9ca..0000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,51 +0,0 @@ -steps: - - label: nix-installer-x86_64-darwin - agents: - mac: 1 - system: x86_64-darwin - nix: 1 - command: - - nix --extra-experimental-features "nix-command flakes" build .#packages.x86_64-darwin.nix-installer -L - - cp result/bin/nix-installer ./nix-installer-x86_64-darwin - - buildkite-agent artifact upload nix-installer-x86_64-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.nix-installer -L - - cp result/bin/nix-installer ./nix-installer-aarch64-darwin - - buildkite-agent artifact upload nix-installer-aarch64-darwin - - label: nix-installer-x86_64-linux - agents: - system: x86_64-linux - nix: 1 - command: - - nix --extra-experimental-features "nix-command flakes" build .#packages.x86_64-linux.nix-installer-static -L - - cp result/bin/nix-installer ./nix-installer-x86_64-linux - - buildkite-agent artifact upload nix-installer-x86_64-linux - - label: nix-installer-x86_64-linux-variants - agents: - system: x86_64-linux - nix: 1 - command: - - nix --extra-experimental-features "nix-command flakes" develop --store ~/.ci-store --print-build-logs .# --command "cargo" build --no-default-features - - nix --extra-experimental-features "nix-command flakes" develop --store ~/.ci-store --print-build-logs .# --command "cargo" build --all-features - - nix --extra-experimental-features "nix-command flakes" build --store ~/.ci-store --print-build-logs .#packages.x86_64-linux.nix-installer - - label: nix-installer-i686-linux - agents: - system: x86_64-linux - nix: 1 - command: - - nix --extra-experimental-features "nix-command flakes" build .#packages.i686-linux.nix-installer-static -L - - cp result/bin/nix-installer ./nix-installer-i686-linux - - buildkite-agent artifact upload nix-installer-i686-linux - - label: nix-installer-aarch64-linux - agents: - system: aarch64-linux - nix: 1 - command: - - nix --extra-experimental-features "nix-command flakes" build .#packages.aarch64-linux.nix-installer-static -L - - cp result/bin/nix-installer ./nix-installer-aarch64-linux - - buildkite-agent artifact upload nix-installer-aarch64-linux diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 548f3a7..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,22 +0,0 @@ -##### Description - - - -##### Checklist - -- [ ] Formatted with `cargo fmt` -- [ ] Built with `nix build` -- [ ] Ran flake checks with `nix flake check` -- [ ] Added or updated relevant tests (leave unchecked if not applicable) -- [ ] Added or updated relevant documentation (leave unchecked if not applicable) -- [ ] Linked to related issues (leave unchecked if not applicable) - -##### Validating with `install.determinate.systems` - -If a maintainer has added the `upload to s3` label to this PR, it will become available for installation via `install.determinate.systems`: - -```shell -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install -``` diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index dab94ad..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" - - package-ecosystem: "cargo" - directory: "/" - schedule: - interval: "monthly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 683e4e1..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,340 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: [main] - -jobs: - lints: - name: Lints - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Check Nixpkgs input - uses: DeterminateSystems/flake-checker-action@main - with: - fail-mode: true - check-outdated: false # PRs shouldn't fail because main's nixpkgs is out of date - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Check rustfmt - run: nix develop --command check-rustfmt - - name: Check Clippy - run: nix develop --command check-clippy - - name: Check Spelling - run: nix develop --command check-spelling - - name: Check nixpkgs-fmt formatting - run: nix develop --command check-nixpkgs-fmt - - name: Check EditorConfig conformance - run: nix develop --command check-editorconfig - - name: Download Buildkite Artifacts - uses: EnricoMi/download-buildkite-artifact-action@v1.14 - with: - buildkite_token: ${{ secrets.BUILDKITE_TOKEN }} - output_path: artifacts - - name: Output list of Buildkite artifacts - run: | - ls -lah artifacts/ - ls -lah artifacts/**/* - # Mac's can't run this action, so we're forced to do this. - - name: Create Github cache from Buildkite artifacts - id: cache-buildkite-artifacts - uses: actions/cache/save@v3 - with: - path: artifacts - key: buildkite-artifacts-${{ github.sha }} - - run-x86_64-linux: - name: Run x86_64 Linux - runs-on: ubuntu-22.04 - needs: [lints] - steps: - - uses: actions/checkout@v3 - - name: Restore Github cache of Buildkite artifacts - id: cache-buildkite-artifacts - uses: actions/cache/restore@v3 - with: - path: artifacts - key: buildkite-artifacts-${{ github.sha }} - - run: sudo apt install fish zsh - - name: Move & set executable - run: | - mkdir install-root - cp nix-installer.sh install-root/nix-installer.sh - mv ./artifacts/nix-installer-x86_64-linux-*/* install-root/nix-installer-x86_64-linux - chmod +x install-root/nix-installer-x86_64-linux install-root/nix-installer.sh - - name: Initial install - uses: DeterminateSystems/nix-installer-action@main - with: - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Initial uninstall (without a `nix run` first) - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full - - name: Ensure `nix` is removed - run: | - if systemctl is-active nix-daemon.socket; then - echo "nix-daemon.socket was still running" - exit 1 - fi - if systemctl is-active nix-daemon.service; then - echo "nix-daemon.service was still running" - exit 1 - fi - if [ -e /nix ]; then - echo "/nix exists" - exit 1 - fi - - name: Repeated install - uses: DeterminateSystems/nix-installer-action@main - with: - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: echo $PATH - run: echo $PATH - - name: Test `nix` with `$GITHUB_PATH` - if: success() || failure() - run: | - nix run nixpkgs#hello - nix profile install nixpkgs#hello - hello - nix store gc - nix run nixpkgs#hello - - name: Test bash - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: bash --login {0} - - name: Test sh - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: sh -l {0} - - name: Test zsh - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: zsh --login --interactive {0} - - name: Test fish - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: fish --login {0} - - name: Repeated uninstall - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full - - name: Ensure `nix` is removed - run: | - if systemctl is-active nix-daemon.socket; then - echo "nix-daemon.socket was still running" - exit 1 - fi - if systemctl is-active nix-daemon.service; then - echo "nix-daemon.service was still running" - exit 1 - fi - if [ -e /nix ]; then - echo "/nix exists" - exit 1 - fi - - run-x86_64-linux-no-init: - name: Run x86_64 Linux (No init) - runs-on: ubuntu-22.04 - needs: [lints] - steps: - - uses: actions/checkout@v3 - - name: Restore Github cache of Buildkite artifacts - id: cache-buildkite-artifacts - uses: actions/cache/restore@v3 - with: - path: artifacts - key: buildkite-artifacts-${{ github.sha }} - - run: sudo apt install fish zsh - - name: Move & set executable - run: | - mkdir install-root - cp nix-installer.sh install-root/nix-installer.sh - mv ./artifacts/nix-installer-x86_64-linux-*/* install-root/nix-installer-x86_64-linux - chmod +x install-root/nix-installer-x86_64-linux install-root/nix-installer.sh - - name: Initial install - uses: DeterminateSystems/nix-installer-action@main - with: - init: none - planner: linux - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Ensure daemon was not configured with init - run: | - if systemctl is-active nix-daemon.socket; then - echo "nix-daemon.socket was running" - exit 1 - fi - if systemctl is-active nix-daemon.service; then - echo "nix-daemon.service was running" - exit 1 - fi - - name: Initial uninstall (without a `nix run` first) - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full - - name: Ensure `nix` is removed - run: | - if [ -e /nix ]; then - echo "/nix exists" - exit 1 - fi - - name: Repeated install - uses: DeterminateSystems/nix-installer-action@main - with: - init: none - planner: linux - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: echo $PATH - run: echo $PATH - - name: Test `nix` with `$GITHUB_PATH` - if: success() || failure() - run: | - sudo -i nix run nixpkgs#hello - sudo -i nix profile install nixpkgs#hello - hello - sudo -i nix store gc - sudo -i nix run nixpkgs#hello - - name: Test bash - run: sudo -i nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: bash --login {0} - - name: Test sh - run: sudo -i nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: sh -l {0} - - name: Test zsh - run: sudo -i nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: zsh --login --interactive {0} - - name: Test fish - run: sudo -i nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: fish --login {0} - - name: Repeated uninstall - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full - - name: Ensure `nix` is removed - run: | - if systemctl is-active nix-daemon.socket; then - echo "nix-daemon.socket was running" - exit 1 - fi - if systemctl is-active nix-daemon.service; then - echo "nix-daemon.service was running" - exit 1 - fi - if [ -e /nix ]; then - echo "/nix exists" - exit 1 - fi - - run-x86_64-darwin: - name: Run x86_64 Darwin - runs-on: macos-12 - needs: [lints] - steps: - - uses: actions/checkout@v3 - - name: Restore Github cache of Buildkite artifacts - id: cache-buildkite-artifacts - uses: actions/cache/restore@v3 - with: - path: artifacts - key: buildkite-artifacts-${{ github.sha }} - - run: brew install fish coreutils - - name: Move & set executable - run: | - mkdir install-root - cp nix-installer.sh install-root/nix-installer.sh - mv ./artifacts/nix-installer-x86_64-darwin-*/* install-root/nix-installer-x86_64-darwin - chmod +x install-root/nix-installer-x86_64-darwin install-root/nix-installer.sh - - name: Initial install - uses: DeterminateSystems/nix-installer-action@main - with: - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: | - trusted-users = root runner - - name: Initial uninstall (without a `nix run` first) - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full - - name: Repeated install - uses: DeterminateSystems/nix-installer-action@main - with: - local-root: install-root/ - logger: pretty - log-directives: nix_installer=debug - backtrace: full - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: trusted-users = root runner - - name: echo $PATH - run: echo $PATH - - name: Test `nix` with `$GITHUB_PATH` - if: success() || failure() - run: | - nix run nixpkgs#hello - nix profile install nixpkgs#hello - hello - nix store gc - nix run nixpkgs#hello - - name: Test bash - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: bash --login {0} - - name: Test sh - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: sh -l {0} - - name: Test zsh - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: zsh --login --interactive {0} - - name: Test fish - run: nix-instantiate -E 'builtins.currentTime' --eval - if: success() || failure() - shell: fish --login {0} - - name: Repeated uninstall - run: sudo -E /nix/nix-installer uninstall - env: - NIX_INSTALLER_NO_CONFIRM: true - NIX_INSTALLER_LOGGER: pretty - NIX_INSTALLER_LOG_DIRECTIVES: nix_installer=debug - RUST_BACKTRACE: full diff --git a/.github/workflows/release-branches.yml b/.github/workflows/release-branches.yml deleted file mode 100644 index 34771ea..0000000 --- a/.github/workflows/release-branches.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Release Branch - -on: - push: - branches: - # NOTE: make sure any branches here are also valid directory names, - # otherwise creating the directory and uploading to s3 will fail - - 'main' - -jobs: - release: - concurrency: release - runs-on: ubuntu-latest - permissions: - id-token: write # In order to request a JWT for AWS auth - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Download Buildkite Artifacts - uses: EnricoMi/download-buildkite-artifact-action@v1.14 - with: - buildkite_token: ${{ secrets.BUILDKITE_TOKEN }} - output_path: artifacts - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_S3_UPLOAD_ROLE }} - aws-region: us-east-2 - - name: Publish Release (Branch) - env: - AWS_BUCKET: ${{ secrets.AWS_S3_UPLOAD_BUCKET }} - run: | - BRANCH="branch_${{ github.ref_name }}" - GIT_ISH="$GITHUB_SHA" - ./upload_s3.sh "$BRANCH" "$GIT_ISH" "https://install.determinate.systems/nix/rev/$GIT_ISH" - - name: Install Instructions (Branch) - run: | - cat < You may wish to set `-j 4` to some other number. Some OS's (Ubuntu 16.04) exhibit problems rapidly updating their users/groups on a system running dozens of VMs. -For PR review, you can also test arbitrary branches or checkouts like so: - -```bash -nix build github:determinatesystems/nix-installer/${BRANCH}#hydraJobs.vm-test.ubuntu-v22_04.x86_64-linux.install-default -L -``` -
Adding a distro? @@ -249,8 +243,8 @@ These should be visible in `nix flake show`: ``` ❯ nix flake show -warning: Git tree '/home/ana/git/determinatesystems/nix-installer' is dirty -git+file:///home/ana/git/determinatesystems/nix-installer +warning: Git tree '/home/ana/git/detsys/nix-installer' is dirty +git+file:///home/ana/git/detsys/nix-installer # ... ├───hydraJobs │ ├───container-test @@ -291,12 +285,6 @@ To run a specific distribution listed in the `nix flake show` output: nix build .#hydraJobs.container-test.ubuntu-v22_04.x86_64-linux.docker -L ``` -For PR review, you can also test arbitrary branches or checkouts like so: - -```bash -nix build github:determinatesystems/nix-installer/${BRANCH}#hydraJobs.container-test.ubuntu-v22_04.x86_64-linux.podman -L -``` -
Adding a distro? @@ -390,11 +378,6 @@ To cut a release: + **Warning:** While you can re-release Github releases, it is not possible to do the same on `crates.io` * Create a PR bumping the version up one minor in the `Cargo.toml`, `flake.nix`, and fixture JSON files, adding `-unreleased` at the end (`v0.0.2-unreleased`) -# Who maintains `nix-installer` and why? +# Who maintains `lix-installer` and why? -`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 `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. +`lix-installer` is maintained by [the Lix community](https://lix.systems/) as part of the Lix Project. diff --git a/Cargo.lock b/Cargo.lock index b39f183..7af558e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -851,6 +851,50 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lix-installer" +version = "0.17.1" +dependencies = [ + "async-trait", + "bytes 1.5.0", + "clap", + "color-eyre", + "dirs", + "dyn-clone", + "eyre", + "glob", + "indexmap 2.2.3", + "is_ci", + "nix", + "nix-config-parser", + "os-release", + "owo-colors 4.0.0", + "plist", + "rand", + "reqwest", + "semver", + "serde", + "serde_json", + "serde_with", + "strum", + "sysctl", + "tar", + "target-lexicon", + "tempfile", + "term", + "thiserror", + "tokio", + "tracing", + "tracing-error", + "tracing-subscriber", + "typetag", + "url", + "uuid", + "walkdir", + "which", + "xz2", +] + [[package]] name = "lock_api" version = "0.4.11" @@ -941,50 +985,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "nix-installer" -version = "0.17.1" -dependencies = [ - "async-trait", - "bytes 1.5.0", - "clap", - "color-eyre", - "dirs", - "dyn-clone", - "eyre", - "glob", - "indexmap 2.2.3", - "is_ci", - "nix", - "nix-config-parser", - "os-release", - "owo-colors 4.0.0", - "plist", - "rand", - "reqwest", - "semver", - "serde", - "serde_json", - "serde_with", - "strum", - "sysctl", - "tar", - "target-lexicon", - "tempfile", - "term", - "thiserror", - "tokio", - "tracing", - "tracing-error", - "tracing-subscriber", - "typetag", - "url", - "uuid", - "walkdir", - "which", - "xz2", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" diff --git a/Cargo.toml b/Cargo.toml index ad74a77..afeec2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "nix-installer" +name = "lix-installer" description = "The Determinate Nix Installer" version = "0.17.1" edition = "2021" resolver = "2" license = "LGPL-2.1" -repository = "https://github.com/DeterminateSystems/nix-installer" -documentation = "https://docs.rs/nix-installer/latest/nix_installer" +repository = "https://git.lix.systems/lix-project/lix-installer" +documentation = "https://docs.rs/lix-installer/latest/lix_installer" [package.metadata.riff.targets.aarch64-apple-darwin] build-inputs = ["darwin.apple_sdk.frameworks.Security"] @@ -15,12 +15,11 @@ build-inputs = ["darwin.apple_sdk.frameworks.Security"] build-inputs = ["darwin.apple_sdk.frameworks.Security"] [features] -default = ["cli", "diagnostics"] +default = ["cli"] cli = ["eyre", "color-eyre", "clap", "tracing-subscriber", "tracing-error"] -diagnostics = ["is_ci"] [[bin]] -name = "nix-installer" +name = "lix-installer" required-features = [ "cli" ] [dependencies] diff --git a/README.md b/README.md index 1170184..0194d2d 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,39 @@ -# The Determinate Nix Installer +# The Lix Installer -[![Crates.io](https://img.shields.io/crates/v/nix-installer)](https://crates.io/crates/nix-installer) -[![Docs.rs](https://img.shields.io/docsrs/nix-installer)](https://docs.rs/nix-installer/latest/nix_installer/) - -A fast, friendly, and reliable tool to help you use [Nix] with Flakes everywhere. +A fast, friendly, and reliable tool to help you use Lix, the community implementation of the nix tooling. +Based on the [Determinate Installer](https://install.determinate.systems). ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/nix | sh -s -- install ``` -The `nix-installer` has successfully completed over 2,000,000 installs in a number of environments, including [Github Actions](#as-a-github-action) and [GitLab](#on-gitlab): - -| Platform | Multi User | `root` only | Maturity | -|------------------------------|:------------------:|:-----------:|:-----------------:| -| Linux (x86_64 & aarch64) | ✓ (via [systemd]) | ✓ | Stable | -| MacOS (x86_64 & aarch64) | ✓ | | Stable (See note) | -| Valve Steam Deck (SteamOS) | ✓ | | Stable | -| WSL2 (x86_64 & aarch64) | ✓ (via [systemd]) | ✓ | Stable | -| Podman Linux Containers | ✓ (via [systemd]) | ✓ | Stable | -| Docker Containers | | ✓ | Stable | -| Linux (i686) | ✓ (via [systemd]) | ✓ | Unstable | - -> **Note** -> On **MacOS only**, removing users and/or groups may fail if there are no users who are logged in graphically. - - ## Usage Install Nix with the default planner and options: ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install ``` Or, to download a platform specific Installer binary yourself: ```bash -$ curl -sL -o nix-installer https://install.determinate.systems/nix/nix-installer-x86_64-linux -$ chmod +x nix-installer -$ ./nix-installer +$ curl -sL -o lix-installer https://install.lix.systems/lix/lix-installer-x86_64-linux +$ chmod +x lix-installer +$ ./lix-installer ``` -`nix-installer` installs Nix by following a *plan* made by a *planner*. Review the available planners: +`lix-installer` installs Lix by following a *plan* made by a *planner*. Review the available planners: ```bash -$ ./nix-installer install --help +$ ./lix-installer install --help Execute an install (possibly using an existing plan) -To pass custom options, select a planner, for example `nix-installer install linux-multi --help` +To pass custom options, select a planner, for example `lix-installer install linux-multi --help` -Usage: nix-installer install [OPTIONS] [PLAN] - nix-installer install +Usage: lix-installer install [OPTIONS] [PLAN] + lix-installer install Commands: linux @@ -66,10 +48,10 @@ Commands: Planners have their own options and defaults, sharing most of them in common: ```bash -$ ./nix-installer install linux --help +$ ./lix-installer install linux --help A planner for Linux installs -Usage: nix-installer install linux [OPTIONS] +Usage: lix-installer install linux [OPTIONS] Options: # ... @@ -90,74 +72,33 @@ Options: Planners can be configured via environment variable or command arguments: ```bash -$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | NIX_BUILD_GROUP_NAME=nixbuilder sh -s -- install linux-multi --nix-build-group-id 4000 +$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | NIX_BUILD_GROUP_NAME=nixbuilder sh -s -- install linux-multi --nix-build-group-id 4000 # Or... -$ NIX_BUILD_GROUP_NAME=nixbuilder ./nix-installer install linux-multi --nix-build-group-id 4000 +$ NIX_BUILD_GROUP_NAME=nixbuilder ./lix-installer install linux-multi --nix-build-group-id 4000 ``` -### Upgrading Nix +### Upgrading Lix -You can upgrade Nix to the version described in [`DeterminateSystems/nix-upgrade`][nix-upgrade] by running: +You can upgrade Lix with: ``` sudo -i nix upgrade-nix ``` -Alternatively, you can [uninstall](#uninstalling) and [reinstall](#usage) with a different version of the `nix-installer`. +Alternatively, you can [uninstall](#uninstalling) and [reinstall](#usage) with a different version of the `lix-installer`. ### Uninstalling -You can remove a `nix-installer`-installed Nix by running +You can remove a `lix-installer`-installed Nix by running ```bash -/nix/nix-installer uninstall +/nix/lix-installer uninstall ``` - -### As a Github Action - -You can use the [`nix-installer-action`](https://github.com/DeterminateSystems/nix-installer-action) Github Action like so: - -```yaml -on: - pull_request: - push: - branches: [main] - -jobs: - lints: - name: Build - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - - name: Run `nix build` - run: nix build . -``` - -### On GitLab - -GitLab CI runners are typically Docker based and run as the `root` user. This means `systemd` is not present, so the `--init none` option needs to be passed to the Linux planner. - -On the default [GitLab.com](https://gitlab.com/) runners, `nix` can be installed and used like so: - -```yaml -test: - script: - - curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --no-confirm --init none - - . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh - - nix run nixpkgs#hello - - nix profile install nixpkgs#hello - - hello -``` - -If you are using different runners, the above example may need to be adjusted. - ### Without systemd (Linux only) > **Warning** -> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Nix: +> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Lix's nix command: > > ```bash > sudo -i nix run nixpkgs#hello @@ -166,7 +107,7 @@ If you are using different runners, the above example may need to be adjusted. If you don't use [systemd], you can still install Nix by explicitly specifying the `linux` plan and `--init none`: ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install linux --init none ``` ### In a container @@ -176,7 +117,7 @@ In Docker/Podman containers or WSL2 instances where an init (like `systemd`) is For containers (without an init): > **Warning** -> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Nix: +> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Lix's nix command: > > ```bash > sudo -i nix run nixpkgs#hello @@ -187,7 +128,7 @@ For containers (without an init): FROM ubuntu:latest RUN apt update -y RUN apt install curl -y -RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \ +RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install linux \ --extra-conf "sandbox = false" \ --init none \ --no-confirm @@ -212,7 +153,7 @@ For containers with a systemd init: FROM ubuntu:latest RUN apt update -y RUN apt install curl systemd -y -RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \ +RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install linux \ --extra-conf "sandbox = false" \ --no-start-daemon \ --no-confirm @@ -234,11 +175,11 @@ On some container tools, such as `docker`, `sandbox = false` can be omitted. Omi ### In WSL2 -We **strongly recommend** [enabling systemd](https://ubuntu.com/blog/ubuntu-wsl-enable-systemd), then installing Nix as normal: +We **strongly recommend** [enabling systemd](https://ubuntu.com/blog/ubuntu-wsl-enable-systemd), then installing Lix as normal: ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install ``` If [WSLg][wslg] is enabled, you can do things like open a Linux Firefox from Windows on Powershell: @@ -257,7 +198,7 @@ wsl nix run --impure github:guibou/nixGL nix run nixpkgs#obs-studio If enabling systemd is not an option, pass `--init none` at the end of the command: > **Warning** -> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Nix: +> When `--init none` is used, _only_ `root` or users who can elevate to `root` privileges can run Lix's nix commands: > > ```bash > sudo -i nix run nixpkgs#hello @@ -265,7 +206,7 @@ If enabling systemd is not an option, pass `--init none` at the end of the comma ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install linux --init none ``` ### Skip confirmation @@ -273,7 +214,7 @@ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix If you'd like to bypass the confirmation step, you can apply the `--no-confirm` flag: ```bash -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm +curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix | sh -s -- install --no-confirm ``` This is especially useful when using the installer in non-interactive scripts. @@ -281,11 +222,11 @@ This is especially useful when using the installer in non-interactive scripts. ## Quirks -While `nix-installer` tries to provide a comprehensive and unquirky experience, there are unfortunately some issues which may require manual intervention or operator choices. +While `lix-installer` tries to provide a comprehensive and unquirky experience, there are unfortunately some issues which may require manual intervention or operator choices. ### Using MacOS after removing `nix` while `nix-darwin` was still installed, network requests fail -If `nix` was previously uninstalled without uninstalling `nix-darwin` first, users may experience errors similar to this: +If any variant of `nix` was previously uninstalled without uninstalling `nix-darwin` first, users may experience errors similar to this: ```bash $ nix shell nixpkgs#curl @@ -310,56 +251,46 @@ It's possible to resolve this situation by removing the `org.nixos.activate-syst ```bash $ sudo rm /Library/LaunchDaemons/org.nixos.activate-system.plist $ sudo launchctl bootout system/org.nixos.activate-system -$ /nix/nix-installer uninstall +$ /nix/lix-installer uninstall $ sudo rm /etc/ssl/certs/ca-certificates.crt ``` -Then run the `nix-installer` again, and it should work. +Then run the `lix-installer` again, and it should work. -Up-to-date versions of the `nix-installer` will refuse to uninstall until `nix-darwin` is uninstalled first, helping mitigate this problem. +Up-to-date versions of the `lix-installer` will refuse to uninstall until `nix-darwin` is uninstalled first, helping mitigate this problem. ## Building a binary -Since you'll be using `nix-installer` to install Nix on systems without Nix, the default build is a static binary. +Since you'll be using `lix-installer` to install Nix on systems without Nix, the default build is a static binary. Build a portable Linux binary on a system with Nix: ```bash # to build a local copy -nix build -L ".#nix-installer-static" -# to build the remote main development branch -nix build -L "github:determinatesystems/nix-installer#nix-installer-static" -# for a specific version of the installer: -export NIX_INSTALLER_TAG="v0.6.0" -nix build -L "github:determinatesystems/nix-installer/$NIX_INSTALLER_TAG#nix-installer-static" +nix build -L ".#lix-installer-static" ``` On Mac: ```bash # to build a local copy -nix build -L ".#nix-installer" -# to build the remote main development branch -nix build -L "github:determinatesystems/nix-installer#nix-installer" -# for a specific version of the installer: -export NIX_INSTALLER_TAG="v0.6.0" -nix build -L "github:determinatesystems/nix-installer/$NIX_INSTALLER_TAG#nix-installer" +nix build -L ".#lix-installer" ``` -Then copy the `result/bin/nix-installer` to the machine you wish to run it on. +Then copy the `result/bin/lix-installer` to the machine you wish to run it on. -You can also add `nix-installer` to a system without Nix via `cargo`, there are no system dependencies to worry about: +You can also add `lix-installer` to a system without Lix via `cargo`. There are no system dependencies to worry about: ```bash # to build and run a local copy RUSTFLAGS="--cfg tokio_unstable" cargo run -- --help # to build the remote main development branch -RUSTFLAGS="--cfg tokio_unstable" cargo install --git https://github.com/DeterminateSystems/nix-installer -nix-installer --help +RUSTFLAGS="--cfg tokio_unstable" cargo install --git https://git.lix.systems/lix-project/lix-installer +lix-installer --help # for a specific version of the installer: export NIX_INSTALLER_TAG="v0.6.0" -RUSTFLAGS="--cfg tokio_unstable" cargo install --git https://github.com/DeterminateSystems/nix-installer --tag $NIX_INSTALLER_TAG -nix-installer --help +RUSTFLAGS="--cfg tokio_unstable" cargo install --git https://git.lix.systems/lix-project/lix-installer --tag $NIX_INSTALLER_TAG +lix-installer --help ``` To make this build portable, pass ` --target x86_64-unknown-linux-musl`. @@ -373,10 +304,10 @@ To make this build portable, pass ` --target x86_64-unknown-linux-musl`. > **Warning** > Use as a library is still experimental. This feature is likely to be removed in the future without an advocate. If you're using this, please let us know and we can make a path to stabilization. -Add `nix-installer` to your dependencies: +Add `lix-installer` to your dependencies: ```bash -cargo add nix-installer +cargo add lix-installer ``` If you are **building a CLI**, check out the `cli` feature flag for `clap` integration. @@ -389,39 +320,14 @@ You'll also need to edit your `.cargo/config.toml` to use `tokio_unstable` as we rustflags=["--cfg", "tokio_unstable"] ``` -Then it's possible to review the [documentation](https://docs.rs/nix-installer/latest/nix_installer/): +Then it's possible to review the [documentation](https://docs.rs/lix-installer/latest/lix_installer/): ```bash -cargo doc --open -p nix-installer -``` - -Documentation is also available via `nix` build: - -```bash -nix build github:DeterminateSystems/nix-installer#nix-installer.doc -firefox result-doc/nix-installer/index.html +cargo doc --open -p lix-installer ``` ## Accessing other versions -For users who desire version pinning, the version of `nix-installer` to use can be specified in the `curl` command: - -```bash -VERSION="v0.6.0" -curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/${VERSION} | sh -s -- install -``` - -To discover which versions are available, or download the binaries for any release, check the [Github Releases](https://github.com/DeterminateSystems/nix-installer/releases). - -These releases can be downloaded and used directly: - -```bash -VERSION="v0.6.0" -ARCH="aarch64-linux" -curl -sSf -L https://github.com/DeterminateSystems/nix-installer/releases/download/${VERSION}/nix-installer-${ARCH} -o nix-installer -./nix-installer install -``` - Each installer version has an [associated supported nix version](src/settings.rs) -- if you pin the installer version, you'll also indirectly pin to the associated nix version. You can also override the `nix` version via `--nix-package-url` or `NIX_INSTALLER_NIX_PACKAGE_URL=` but doing so is not recommended since we haven't tested that combination. @@ -440,63 +346,13 @@ Differing from the upstream [Nix](https://github.com/NixOS/nix) installer script + `auto-optimise-store` is set to `true` (On Linux only) * `extra-nix-path` is set to `nixpkgs=flake:nixpkgs` * `max-jobs` is set to `auto` - * `upgrade-nix-store-path-url` is set to `https://install.determinate.systems/nix-upgrade/stable/universal` -* an installation receipt (for uninstalling) is stored at `/nix/receipt.json` as well as a copy of the install binary at `/nix/nix-installer` + * `upgrade-nix-store-path-url` is set to `https://install.lix.systems/lix-upgrade/stable/universal` +* an installation receipt (for uninstalling) is stored at `/nix/receipt.json` as well as a copy of the install binary at `/nix/lix-installer` * `nix-channel --update` is not run, `~/.nix-channels` is not provisioned * `ssl-cert-file` is set in `/etc/nix/nix.conf` if the `ssl-cert-file` argument is used. -## Motivations -The existing upstream scripts do a good job, however they are difficult to maintain. +## No Telemetry Included -Subtle differences in the shell implementations and tool used in the scripts make it difficult to make meaningful changes to the installer. +The Lix installer respects user privacy, and thus collects no information. -The Determinate Nix installer has numerous advantages: - -* survives macOS upgrades -* keeping an installation receipt for easy uninstallation -* offering users a chance to review an accurate, calculated install plan -* having 'planners' which can create appropriate install plans for complicated targets -* offering users with a failing install the chance to do a best-effort revert -* improving performance by maximizing parallel operations -* supporting a expanded test suite including 'curing' cases -* supporting SELinux and OSTree based distributions without asking users to make compromises -* operating as a single, static binary with external dependencies such as `openssl`, only calling existing system tools (like `useradd`) where necessary -* As a MacOS remote build target, ensures `nix` is not absent from path - -It has been wonderful to collaborate with other participants in the Nix Installer Working Group and members of the broader community. The working group maintains a [foundation owned fork of the installer](https://github.com/nixos/experimental-nix-installer/). - - -## Diagnostics - -The goal of the Determinate Nix Installer is to successfully and correctly install Nix. -The `curl | sh` pipeline and the installer collects a little bit of diagnostic information to help us make that true. - -Here is a table of the [diagnostic data we collect][diagnosticdata]: - -| Field | Use | -| --------------------- | ----------------------------------------------------------------------------------------------------- | -| `version` | The version of the Determinate Nix Installer. | -| `planner` | The method of installing Nix (`linux`, `macos`, `steam-deck`) | -| `configured_settings` | The names of planner settings which were changed from their default. Does _not_ include the values. | -| `os_name` | The running operating system. | -| `os_version` | The version of the operating system. | -| `triple` | The architecture/operating system/binary format of your system. | -| `is_ci` | Whether the installer is being used in CI (e.g. GitHub Actions). | -| `action` | Either `Install` or `Uninstall`. | -| `status` | One of `Success`, `Failure`, `Pending`, or `Cancelled`. | -| `attribution` | Optionally defined by the user, associate the diagnostics of this run to the provided value. | -| `failure_chain` | A high level description of what the failure was, if any. For example: `Command("diskutil")` if the command `diskutil list` failed. | - -To disable diagnostic reporting, set the diagnostics URL to an empty string by passing `--diagnostic-endpoint=""` or setting `NIX_INSTALLER_DIAGNOSTIC_ENDPOINT=""`. - -You can read the full privacy policy for [Determinate Systems][detsys], the creators of the Determinate Nix Installer, [here][privacy]. - -[detsys]: https://determinate.systems/ -[diagnosticdata]: https://github.com/DeterminateSystems/nix-installer/blob/f9f927840d532b71f41670382a30cfcbea2d8a35/src/diagnostics.rs#L29-L43 -[privacy]: https://determinate.systems/policies/privacy -[systemd]: https://systemd.io -[wslg]: https://github.com/microsoft/wslg -[nixgl]: https://github.com/guibou/nixGL -[Nix]: https://nixos.org -[nix-upgrade]: https://github.com/DeterminateSystems/nix-upgrade/blob/main/versions.nix diff --git a/flake.nix b/flake.nix index 6768079..5f309df 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,11 @@ { - description = "The Determinate Nix Installer"; + description = "The Lix Installer"; inputs = { - nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; fenix = { - url = "https://flakehub.com/f/nix-community/fenix/0.1.1584.tar.gz"; + url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -65,10 +65,10 @@ rustc = toolchain; }; sharedAttrs = { - pname = "nix-installer"; + pname = "lix-installer"; version = "0.17.1"; src = builtins.path { - name = "nix-installer-source"; + name = "lix-installer-source"; path = self; filter = (path: type: baseNameOf path != "nix" && baseNameOf path != ".github"); }; @@ -93,27 +93,27 @@ ''; }; postInstall = '' - cp nix-installer.sh $out/bin/nix-installer.sh + cp lix-installer.sh $out/bin/lix-installer.sh ''; }; in rec { - nix-installer = naerskLib.buildPackage sharedAttrs; + lix-installer = naerskLib.buildPackage sharedAttrs; } // nixpkgs.lib.optionalAttrs (prev.stdenv.system == "x86_64-linux") rec { - default = nix-installer-static; - nix-installer-static = naerskLib.buildPackage + default = lix-installer-static; + lix-installer-static = naerskLib.buildPackage (sharedAttrs // { CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; }); } // nixpkgs.lib.optionalAttrs (prev.stdenv.system == "i686-linux") rec { - default = nix-installer-static; - nix-installer-static = naerskLib.buildPackage + default = lix-installer-static; + lix-installer-static = naerskLib.buildPackage (sharedAttrs // { CARGO_BUILD_TARGET = "i686-unknown-linux-musl"; }); } // nixpkgs.lib.optionalAttrs (prev.stdenv.system == "aarch64-linux") rec { - default = nix-installer-static; - nix-installer-static = naerskLib.buildPackage + default = lix-installer-static; + lix-installer-static = naerskLib.buildPackage (sharedAttrs // { CARGO_BUILD_TARGET = "aarch64-unknown-linux-musl"; }); @@ -190,18 +190,18 @@ packages = forAllSystems ({ system, pkgs, ... }: { - inherit (pkgs) nix-installer; + inherit (pkgs) lix-installer; } // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") { - inherit (pkgs) nix-installer-static; - default = pkgs.nix-installer-static; + inherit (pkgs) lix-installer-static; + default = pkgs.lix-installer-static; } // nixpkgs.lib.optionalAttrs (system == "i686-linux") { - inherit (pkgs) nix-installer-static; - default = pkgs.nix-installer-static; + inherit (pkgs) lix-installer-static; + default = pkgs.lix-installer-static; } // nixpkgs.lib.optionalAttrs (system == "aarch64-linux") { - inherit (pkgs) nix-installer-static; - default = pkgs.nix-installer-static; + inherit (pkgs) lix-installer-static; + default = pkgs.lix-installer-static; } // nixpkgs.lib.optionalAttrs (pkgs.stdenv.isDarwin) { - default = pkgs.nix-installer; + default = pkgs.lix-installer; }); hydraJobs = { diff --git a/nix-installer.sh b/nix-installer.sh index 22f847c..620a373 100755 --- a/nix-installer.sh +++ b/nix-installer.sh @@ -1,11 +1,11 @@ #!/bin/sh # shellcheck shell=dash -# If you need an offline install, or you'd prefer to run the binary directly, head to -# https://github.com/DeterminateSystems/nix-installer/releases then pick the version and platform +# If you need an offline install, or you'd prefer to run the binary directly, head to +# https://git.lix.systems/lix-project/lix-installer/releases then pick the version and platform # most appropriate for your deployment target. # -# This is just a little script that selects and downloads the right `nix-installer`. It does +# This is just a little script that selects and downloads the right `lix-installer`. It does # platform detection, downloads the installer, and runs it; that's it. # # It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local` @@ -17,7 +17,7 @@ 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 'nix-installer does not work with this ksh93 version; please try bash!' >&2 + echo 'lix-installer does not work with this ksh93 version; please try bash!' >&2 exit 1 fi @@ -25,7 +25,7 @@ fi set -u # 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}" +NIX_INSTALLER_BINARY_ROOT="${NIX_INSTALLER_BINARY_ROOT:-https://install.lix.systems/lix}" main() { downloader --check @@ -47,7 +47,7 @@ main() { ;; esac - local _url="${NIX_INSTALLER_OVERRIDE_URL-${NIX_INSTALLER_BINARY_ROOT}/nix-installer-${_arch}${_ext}}" + local _url="${NIX_INSTALLER_OVERRIDE_URL-${NIX_INSTALLER_BINARY_ROOT}/lix-installer-${_arch}${_ext}}" local _dir if ! _dir="$(ensure mktemp -d)"; then @@ -55,7 +55,7 @@ main() { # propagate exit status. exit 1 fi - local _file="${_dir}/nix-installer${_ext}" + local _file="${_dir}/lix-installer${_ext}" local _ansi_escapes_are_valid=false if [ -t 2 ]; then @@ -95,7 +95,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-installer${_ext}." 1>&2 + printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./lix-installer${_ext}." 1>&2 exit 1 fi @@ -229,7 +229,7 @@ get_architecture() { } say() { - printf 'nix-installer: %s\n' "$1" + printf 'lix-installer: %s\n' "$1" } err() { diff --git a/nix/tests/container-test/default/Dockerfile b/nix/tests/container-test/default/Dockerfile index fe2ba75..97b5228 100644 --- a/nix/tests/container-test/default/Dockerfile +++ b/nix/tests/container-test/default/Dockerfile @@ -1,9 +1,9 @@ FROM default -COPY nix-installer /nix-installer -RUN chmod +x /nix-installer +COPY lix-installer /lix-installer +RUN chmod +x /lix-installer COPY binary-tarball /binary-tarball RUN mv /binary-tarball/nix-*.tar.xz nix.tar.xz -RUN /nix-installer/bin/nix-installer install linux --logger pretty --log-directive nix_installer=debug --nix-package-url file:///nix.tar.xz --init none --extra-conf "sandbox = false" --no-confirm -vvv +RUN /nix-installer/bin/lix-installer install linux --logger pretty --log-directive nix_installer=debug --nix-package-url file:///nix.tar.xz --init none --extra-conf "sandbox = false" --no-confirm -vvv ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin" RUN nix-build --no-substitute -E 'derivation { name = "foo"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo foobar > $out"]; }' -RUN /nix/nix-installer uninstall --no-confirm \ No newline at end of file +RUN /nix/lix-installer uninstall --no-confirm \ No newline at end of file diff --git a/src/action/base/create_or_merge_nix_config.rs b/src/action/base/create_or_merge_nix_config.rs index ae0585e..9e97290 100644 --- a/src/action/base/create_or_merge_nix_config.rs +++ b/src/action/base/create_or_merge_nix_config.rs @@ -410,7 +410,7 @@ impl Action for CreateOrMergeNixConfig { } new_config - .push_str("# Generated by https://github.com/DeterminateSystems/nix-installer.\n"); + .push_str("# Generated by https://install.lix.systems/.\n"); new_config.push_str("# See `/nix/nix-installer --version` for the version details.\n"); new_config.push('\n'); diff --git a/src/action/common/place_nix_configuration.rs b/src/action/common/place_nix_configuration.rs index fe91355..820f937 100644 --- a/src/action/common/place_nix_configuration.rs +++ b/src/action/common/place_nix_configuration.rs @@ -131,7 +131,7 @@ impl PlaceNixConfiguration { ); settings.insert( "upgrade-nix-store-path-url".to_string(), - "https://install.determinate.systems/nix-upgrade/stable/universal".to_string(), + "https://install.lix.systems/lix-upgrade/stable/universal".to_string(), ); let create_directory = CreateDirectory::plan(NIX_CONF_FOLDER, None, None, 0o0755, force) diff --git a/src/action/macos/create_nix_hook_service.rs b/src/action/macos/create_nix_hook_service.rs index 6ae5d1d..b30f056 100644 --- a/src/action/macos/create_nix_hook_service.rs +++ b/src/action/macos/create_nix_hook_service.rs @@ -27,9 +27,9 @@ impl CreateNixHookService { pub async fn plan() -> Result, ActionError> { let mut this = Self { path: PathBuf::from( - "/Library/LaunchDaemons/systems.determinate.nix-installer.nix-hook.plist", + "/Library/LaunchDaemons/systems.lix.nix-installer.nix-hook.plist", ), - service_label: "systems.determinate.nix-installer.nix-hook".into(), + service_label: "systems.lix.nix-installer.nix-hook".into(), needs_bootout: false, }; diff --git a/src/action/mod.rs b/src/action/mod.rs index c9ef099..d120765 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -24,7 +24,7 @@ You can manually plan, execute, then revert an [`Action`] like so: ```rust,no_run # async fn wrapper() { -use nix_installer::action::base::CreateDirectory; +use lix_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 nix_installer::{ +use lix_installer::{ InstallPlan, settings::{CommonSettings, InstallSettingsError}, planner::{Planner, PlannerError}, @@ -152,20 +152,6 @@ impl Planner for MyPlanner { Ok(settings) } - - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(nix_installer::diagnostics::DiagnosticData::new( - self.common.diagnostic_attribution.clone(), - self.common.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.common.ssl_cert_file.clone(), - )?) - } } # async fn custom_planner_install() -> color_eyre::Result<()> { @@ -329,12 +315,6 @@ impl ActionError { pub fn action_tag(&self) -> &ActionTag { &self.action_tag } - - #[cfg(feature = "diagnostics")] - pub fn diagnostic(&self) -> String { - use crate::diagnostics::ErrorDiagnostic; - self.kind.diagnostic() - } } impl std::fmt::Display for ActionError { @@ -493,8 +473,6 @@ pub enum ActionErrorKind { command = .command, )] Command { - #[cfg(feature = "diagnostics")] - program: String, command: String, #[source] error: std::io::Error, @@ -511,8 +489,6 @@ pub enum ActionErrorKind { } )] CommandOutput { - #[cfg(feature = "diagnostics")] - program: String, command: String, output: Output, }, @@ -555,7 +531,7 @@ pub enum ActionErrorKind { MissingRemoveUserFromGroupCommand, #[error("\ Could not detect systemd; you may be able to get up and running without systemd with `nix-installer install linux --init none`.\n\ - See https://github.com/DeterminateSystems/nix-installer#without-systemd-linux-only for documentation on usage and drawbacks.\ + See https://git.lix.systems/lix-project/lix-installer#without-systemd-linux-only for documentation on usage and drawbacks.\ ")] SystemdMissing, #[error("`{command}` failed, message: {message}")] @@ -575,16 +551,12 @@ pub enum ActionErrorKind { impl ActionErrorKind { pub fn command(command: &tokio::process::Command, error: std::io::Error) -> Self { Self::Command { - #[cfg(feature = "diagnostics")] - program: command.as_std().get_program().to_string_lossy().into(), command: format!("{:?}", command.as_std()), error, } } pub fn command_output(command: &tokio::process::Command, output: std::process::Output) -> Self { Self::CommandOutput { - #[cfg(feature = "diagnostics")] - program: command.as_std().get_program().to_string_lossy().into(), command: format!("{:?}", command.as_std()), output, } @@ -602,60 +574,3 @@ impl HasExpectedErrors for ActionErrorKind { } } } - -#[cfg(feature = "diagnostics")] -impl crate::diagnostics::ErrorDiagnostic for ActionErrorKind { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - let context = match self { - Self::Child(child) => vec![child.diagnostic()], - Self::MultipleChildren(children) => { - children.iter().map(|child| child.diagnostic()).collect() - }, - Self::Read(path, _) - | Self::Open(path, _) - | Self::Write(path, _) - | Self::Flush(path, _) - | Self::SetPermissions(_, path, _) - | Self::GettingMetadata(path, _) - | Self::CreateDirectory(path, _) - | Self::PathWasNotFile(path) - | Self::Remove(path, _) => { - vec![path.to_string_lossy().to_string()] - }, - Self::Rename(first_path, second_path, _) - | Self::Copy(first_path, second_path, _) - | Self::Symlink(first_path, second_path, _) => { - vec![ - first_path.to_string_lossy().to_string(), - second_path.to_string_lossy().to_string(), - ] - }, - Self::NoGroup(name) | Self::NoUser(name) => { - vec![name.clone()] - }, - Self::Command { - program, - command: _, - error: _, - } - | Self::CommandOutput { - program, - command: _, - output: _, - } => { - vec![program.clone()] - }, - _ => vec![], - }; - format!( - "{}({})", - static_str, - context - .iter() - .map(|v| format!("\"{v}\"")) - .collect::>() - .join(", ") - ) - } -} diff --git a/src/bin/nix-installer.rs b/src/bin/lix-installer.rs similarity index 87% rename from src/bin/nix-installer.rs rename to src/bin/lix-installer.rs index 892820f..c52f92c 100644 --- a/src/bin/nix-installer.rs +++ b/src/bin/lix-installer.rs @@ -1,7 +1,7 @@ use std::{io::IsTerminal, process::ExitCode}; use clap::Parser; -use nix_installer::cli::CommandExecute; +use lix_installer::cli::CommandExecute; #[tokio::main] async fn main() -> eyre::Result { @@ -17,7 +17,7 @@ async fn main() -> eyre::Result { }) .install()?; - let cli = nix_installer::cli::NixInstallerCli::parse(); + let cli = lix_installer::cli::NixInstallerCli::parse(); cli.instrumentation.setup()?; diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 37ded73..4f485d2 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -20,7 +20,7 @@ pub trait CommandExecute { } /** -The Determinate Nix installer +The Determinate Nix installer (lix variant) A fast, friendly, and reliable tool to help you use Nix with Flakes everywhere. */ @@ -122,13 +122,6 @@ pub fn ensure_root() -> eyre::Result<()> { } } - #[cfg(feature = "diagnostics")] - if is_ci::cached() { - // Normally `sudo` would erase those envs, so we detect and pass that along specifically to avoid having to pass around - // a bunch of environment variables - env_list.push("NIX_INSTALLER_CI=1".to_string()); - } - if !env_list.is_empty() { arg_vec_cstring .push(CString::new("env").wrap_err("Building a `env` argument for `sudo`")?); diff --git a/src/cli/subcommand/install.rs b/src/cli/subcommand/install.rs index a72c05b..73cdfe2 100644 --- a/src/cli/subcommand/install.rs +++ b/src/cli/subcommand/install.rs @@ -25,13 +25,13 @@ use color_eyre::{ use owo_colors::OwoColorize; const EXISTING_INCOMPATIBLE_PLAN_GUIDANCE: &str = "\ - If you are trying to upgrade Nix, try running `sudo -i nix upgrade-nix` instead.\n\ - If you are trying to install Nix over an existing install (from an incompatible `nix-installer` install), try running `/nix/nix-installer uninstall` then try to install again.\n\ - If you are using `nix-installer` in an automated curing process and seeing this message, consider pinning the version you use via https://github.com/DeterminateSystems/nix-installer#accessing-other-versions.\ + If you are trying to upgrade Lix, try running `sudo -i nix upgrade-nix` instead.\n\ + If you are trying to install Lix over an existing install (from an incompatible `nix-installer` install), try running `/nix/nix-installer uninstall` then try to install again.\n\ + If you are using `lix-installer` in an automated curing process and seeing this message, consider pinning the version you use via https://git.lix.systems/lix-project/lix-installer#accessing-other-versions.\ "; /** -Install Nix using a planner +Install Lix-Nix using a planner By default, an appropriate planner is heuristically determined based on the system. @@ -90,7 +90,7 @@ impl CommandExecute for Install { .wrap_err("Reading plan")?; Some( serde_json::from_str(&install_plan_string).wrap_err_with(|| { - format!("Unable to parse existing receipt `{RECEIPT_LOCATION}`, it may be from an incompatible version of `nix-installer`. Try running `/nix/nix-installer uninstall`, then installing again.") + format!("Unable to parse existing receipt `{RECEIPT_LOCATION}`, it may be from an incompatible version of `nix-installer` or `lix-installer`. Try running `/nix/nix-installer uninstall`, then installing again.") })?, ) }, @@ -99,7 +99,7 @@ impl CommandExecute for Install { let uninstall_command = match Path::new("/nix/nix-installer").exists() { true => "/nix/nix-installer uninstall".into(), - false => format!("curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v{} | sh -s -- uninstall", env!("CARGO_PKG_VERSION")), + false => format!("curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix/tag/v{} | sh -s -- uninstall", env!("CARGO_PKG_VERSION")), }; let mut install_plan = match (planner, plan) { diff --git a/src/cli/subcommand/uninstall.rs b/src/cli/subcommand/uninstall.rs index 158fa0d..e3a07b2 100644 --- a/src/cli/subcommand/uninstall.rs +++ b/src/cli/subcommand/uninstall.rs @@ -129,7 +129,7 @@ impl CommandExecute for Uninstall { format!( "\ Unable to parse plan, this plan was created by `nix-installer` version `{plan_version}`, this is `nix-installer` version `{current_version}`\n\ - To uninstall, either run `/nix/nix-installer uninstall` or `curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v{plan_version} | sh -s -- uninstall`\ + To uninstall, either run `/nix/nix-installer uninstall` or `curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix/tag/v{plan_version} | sh -s -- uninstall`\ ").red().to_string() }); }, @@ -147,7 +147,7 @@ impl CommandExecute for Uninstall { \n\ Found existing plan in `{RECEIPT_LOCATION}` which was created by a version incompatible `nix-installer`.\n\ \n - To uninstall, either run `/nix/nix-installer uninstall` or `curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v${version} | sh -s -- uninstall`\n\ + To uninstall, either run `/nix/nix-installer uninstall` or `curl --proto '=https' --tlsv1.2 -sSf -L https://install.lix.systems/lix/tag/v${version} | sh -s -- uninstall`\n\ \n\ ").red() ); diff --git a/src/diagnostics.rs b/src/diagnostics.rs deleted file mode 100644 index dbd86c8..0000000 --- a/src/diagnostics.rs +++ /dev/null @@ -1,277 +0,0 @@ -/*! Diagnostic reporting functionality - -When enabled with the `diagnostics` feature (default) this module provides automated install success/failure reporting to an endpoint. - -That endpoint can be a URL such as `https://our.project.org/nix-installer/diagnostics` or `file:///home/$USER/diagnostic.json` which receives a [`DiagnosticReport`] in JSON format. -*/ - -use std::{path::PathBuf, time::Duration}; - -use os_release::OsRelease; -use reqwest::Url; - -use crate::{ - action::ActionError, parse_ssl_cert, planner::PlannerError, settings::InstallSettingsError, - CertificateError, NixInstallerError, -}; - -/// The static of an action attempt -#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] -pub enum DiagnosticStatus { - Cancelled, - Success, - Pending, - Failure, -} - -/// The action attempted -#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Copy)] -pub enum DiagnosticAction { - Install, - Uninstall, -} - -/// A report sent to an endpoint -#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] -pub struct DiagnosticReport { - pub attribution: Option, - pub version: String, - pub planner: String, - pub configured_settings: Vec, - pub os_name: String, - pub os_version: String, - pub triple: String, - pub is_ci: bool, - pub action: DiagnosticAction, - pub status: DiagnosticStatus, - /// Generally this includes the [`strum::IntoStaticStr`] representation of the error, we take special care not to include parameters of the error (which may include secrets) - pub failure_chain: Option>, -} - -/// A preparation of data to be sent to the `endpoint`. -#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Default)] -pub struct DiagnosticData { - attribution: Option, - version: String, - planner: String, - configured_settings: Vec, - os_name: String, - os_version: String, - triple: String, - is_ci: bool, - endpoint: Option, - ssl_cert_file: Option, - /// Generally this includes the [`strum::IntoStaticStr`] representation of the error, we take special care not to include parameters of the error (which may include secrets) - failure_chain: Option>, -} - -impl DiagnosticData { - pub fn new( - attribution: Option, - endpoint: Option, - planner: String, - configured_settings: Vec, - ssl_cert_file: Option, - ) -> Result { - let endpoint = match endpoint { - Some(endpoint) => diagnostic_endpoint_parser(&endpoint)?, - None => None, - }; - let (os_name, os_version) = match OsRelease::new() { - Ok(os_release) => (os_release.name, os_release.version), - Err(_) => ("unknown".into(), "unknown".into()), - }; - let is_ci = is_ci::cached() - || std::env::var("NIX_INSTALLER_CI").unwrap_or_else(|_| "0".into()) == "1"; - Ok(Self { - attribution, - endpoint, - version: env!("CARGO_PKG_VERSION").into(), - planner, - configured_settings, - os_name, - os_version, - triple: target_lexicon::HOST.to_string(), - is_ci, - ssl_cert_file: ssl_cert_file.and_then(|v| v.canonicalize().ok()), - failure_chain: None, - }) - } - - pub fn failure(mut self, err: &NixInstallerError) -> Self { - let mut failure_chain = vec![]; - let diagnostic = err.diagnostic(); - failure_chain.push(diagnostic); - - let mut walker: &dyn std::error::Error = &err; - while let Some(source) = walker.source() { - if let Some(downcasted) = source.downcast_ref::() { - let downcasted_diagnostic = downcasted.kind().diagnostic(); - failure_chain.push(downcasted_diagnostic); - } - if let Some(downcasted) = source.downcast_ref::>() { - let downcasted_diagnostic = downcasted.kind().diagnostic(); - failure_chain.push(downcasted_diagnostic); - } - if let Some(downcasted) = source.downcast_ref::() { - let downcasted_diagnostic = downcasted.diagnostic(); - failure_chain.push(downcasted_diagnostic); - } - if let Some(downcasted) = source.downcast_ref::() { - let downcasted_diagnostic = downcasted.diagnostic(); - failure_chain.push(downcasted_diagnostic); - } - if let Some(downcasted) = source.downcast_ref::() { - let downcasted_diagnostic = downcasted.diagnostic(); - failure_chain.push(downcasted_diagnostic); - } - - walker = source; - } - - self.failure_chain = Some(failure_chain); - self - } - - pub fn report(&self, action: DiagnosticAction, status: DiagnosticStatus) -> DiagnosticReport { - let Self { - attribution, - version, - planner, - configured_settings, - os_name, - os_version, - triple, - is_ci, - endpoint: _, - ssl_cert_file: _, - failure_chain, - } = self; - DiagnosticReport { - attribution: attribution.clone(), - version: version.clone(), - planner: planner.clone(), - configured_settings: configured_settings.clone(), - os_name: os_name.clone(), - os_version: os_version.clone(), - triple: triple.clone(), - is_ci: *is_ci, - action, - status, - failure_chain: failure_chain.clone(), - } - } - - #[tracing::instrument(level = "debug", skip_all)] - pub async fn send( - self, - action: DiagnosticAction, - status: DiagnosticStatus, - ) -> Result<(), DiagnosticError> { - let serialized = serde_json::to_string_pretty(&self.report(action, status))?; - - let endpoint = match self.endpoint { - Some(endpoint) => endpoint, - None => return Ok(()), - }; - - match endpoint.scheme() { - "https" | "http" => { - tracing::debug!("Sending diagnostic to `{endpoint}`"); - let mut buildable_client = reqwest::Client::builder(); - if let Some(ssl_cert_file) = &self.ssl_cert_file { - let ssl_cert = parse_ssl_cert(ssl_cert_file).await.ok(); - if let Some(ssl_cert) = ssl_cert { - buildable_client = buildable_client.add_root_certificate(ssl_cert); - } - } - let client = buildable_client.build().map_err(DiagnosticError::Reqwest)?; - - let res = client - .post(endpoint.clone()) - .body(serialized) - .header("Content-Type", "application/json") - .timeout(Duration::from_millis(3000)) - .send() - .await; - - if let Err(_err) = res { - tracing::info!("Failed to send diagnostic to `{endpoint}`, continuing") - } - }, - "file" => { - let path = endpoint.path(); - tracing::debug!("Writing diagnostic to `{path}`"); - let res = tokio::fs::write(path, serialized).await; - - if let Err(_err) = res { - tracing::info!("Failed to send diagnostic to `{path}`, continuing") - } - }, - _ => return Err(DiagnosticError::UnknownUrlScheme), - }; - Ok(()) - } -} - -#[non_exhaustive] -#[derive(thiserror::Error, Debug, strum::IntoStaticStr)] -pub enum DiagnosticError { - #[error("Unknown url scheme")] - UnknownUrlScheme, - #[error("Request error")] - Reqwest( - #[from] - #[source] - reqwest::Error, - ), - /// Parsing URL - #[error("Parsing URL")] - Parse( - #[source] - #[from] - url::ParseError, - ), - #[error("Write path `{0}`")] - Write(std::path::PathBuf, #[source] std::io::Error), - #[error("Serializing receipt")] - Serializing( - #[from] - #[source] - serde_json::Error, - ), - #[error(transparent)] - Certificate(#[from] CertificateError), -} - -pub trait ErrorDiagnostic { - fn diagnostic(&self) -> String; -} - -impl ErrorDiagnostic for DiagnosticError { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - static_str.to_string() - } -} - -pub fn diagnostic_endpoint_parser(input: &str) -> Result, DiagnosticError> { - match Url::parse(input) { - Ok(v) => match v.scheme() { - "https" | "http" | "file" => Ok(Some(v)), - _ => Err(DiagnosticError::UnknownUrlScheme), - }, - Err(url::ParseError::RelativeUrlWithoutBase) => { - match Url::parse(&format!("file://{input}")) { - Ok(v) => Ok(Some(v)), - Err(file_error) => Err(file_error)?, - } - }, - Err(url_error) => Err(url_error)?, - } -} - -pub fn diagnostic_endpoint_validator(input: &str) -> Result { - let _ = diagnostic_endpoint_parser(input)?; - Ok(input.to_string()) -} diff --git a/src/error.rs b/src/error.rs index ab8f376..26225b3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -74,14 +74,6 @@ pub enum NixInstallerError { InstallSettingsError, ), - #[cfg(feature = "diagnostics")] - /// Diagnostic error - #[error("Diagnostic error")] - Diagnostic( - #[from] - #[source] - crate::diagnostics::DiagnosticError, - ), /// Could not parse the value as a version requirement in order to ensure it's compatible #[error("Could not parse `{0}` as a version requirement in order to ensure it's compatible")] InvalidVersionRequirement(String, semver::Error), @@ -115,36 +107,6 @@ impl HasExpectedErrors for NixInstallerError { this @ NixInstallerError::IncompatibleVersion { binary: _, plan: _ } => { Some(Box::new(this)) }, - #[cfg(feature = "diagnostics")] - NixInstallerError::Diagnostic(_) => None, } } -} - -#[cfg(feature = "diagnostics")] -impl crate::diagnostics::ErrorDiagnostic for NixInstallerError { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - let context = match self { - Self::SelfTest(self_tests) => self_tests - .iter() - .map(|self_test| self_test.diagnostic()) - .collect::>(), - Self::Action(action_error) => vec![action_error.diagnostic()], - Self::ActionRevert(action_errors) => action_errors - .iter() - .map(|action_error| action_error.diagnostic()) - .collect(), - _ => vec![], - }; - format!( - "{}({})", - static_str, - context - .iter() - .map(|v| format!("\"{v}\"")) - .collect::>() - .join(", ") - ) - } -} +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 2ecd8e4..f3c3e2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ -/*! The Determinate [Nix](https://github.com/NixOS/nix) Installer +/*! The [Lix](https://lix.systems) Installer -`nix-installer` breaks down into three main concepts: +`lix-installer` breaks down into three main concepts: * [`Action`]: An executable or revertable step, possibly orchestrating sub-[`Action`]s using things like [`JoinSet`](tokio::task::JoinSet)s. @@ -10,12 +10,12 @@ 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, `nix-installer` can be asked to determine a default plan for the platform and install +In the simplest case, `lix-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 nix_installer::InstallPlan; +use lix_installer::InstallPlan; # async fn default_install() -> color_eyre::Result<()> { let mut plan = InstallPlan::default().await?; @@ -38,7 +38,7 @@ Sometimes choosing a specific planner is desired: ```rust,no_run use std::error::Error; -use nix_installer::{InstallPlan, planner::Planner}; +use lix_installer::{InstallPlan, planner::Planner}; # async fn chosen_planner_install() -> color_eyre::Result<()> { #[cfg(target_os = "linux")] @@ -72,8 +72,6 @@ match plan.install(None).await { pub mod action; #[cfg(feature = "cli")] pub mod cli; -#[cfg(feature = "diagnostics")] -pub mod diagnostics; mod error; mod os; mod plan; diff --git a/src/plan.rs b/src/plan.rs index 6543f0c..3d52a0c 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -22,18 +22,12 @@ pub struct InstallPlan { pub(crate) actions: Vec>>, pub(crate) planner: Box, - - #[cfg(feature = "diagnostics")] - pub(crate) diagnostic_data: Option, } impl InstallPlan { pub async fn default() -> Result { let planner = BuiltinPlanner::default().await?; - #[cfg(feature = "diagnostics")] - let diagnostic_data = Some(planner.diagnostic_data().await?); - let planner = planner.boxed(); let actions = planner.plan().await?; @@ -41,8 +35,6 @@ impl InstallPlan { planner, actions, version: current_version()?, - #[cfg(feature = "diagnostics")] - diagnostic_data, }) } @@ -50,9 +42,6 @@ impl InstallPlan { where P: Planner + 'static, { - #[cfg(feature = "diagnostics")] - let diagnostic_data = Some(planner.diagnostic_data().await?); - // Some Action `plan` calls may fail if we don't do these checks planner.pre_install_check().await?; @@ -61,8 +50,6 @@ impl InstallPlan { planner: planner.boxed(), actions, version: current_version()?, - #[cfg(feature = "diagnostics")] - diagnostic_data, }) } @@ -101,7 +88,7 @@ impl InstallPlan { let buf = format!( "\ - Nix install plan (v{version})\n\ + Lix install plan (v{version})\n\ Planner: {planner}{maybe_default_setting_note}\n\ \n\ {maybe_plan_settings}\ @@ -173,17 +160,6 @@ impl InstallPlan { tracing::error!("Error saving receipt: {:?}", err); } - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .send( - crate::diagnostics::DiagnosticAction::Install, - crate::diagnostics::DiagnosticStatus::Cancelled, - ) - .await?; - } - return Err(NixInstallerError::Cancelled); } } @@ -194,17 +170,6 @@ impl InstallPlan { tracing::error!("Error saving receipt: {:?}", err); } let err = NixInstallerError::Action(err); - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .failure(&err) - .send( - crate::diagnostics::DiagnosticAction::Install, - crate::diagnostics::DiagnosticStatus::Failure, - ) - .await?; - } return Err(err); } @@ -216,30 +181,7 @@ impl InstallPlan { .await .map_err(NixInstallerError::SelfTest) { - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .failure(&err) - .send( - crate::diagnostics::DiagnosticAction::Install, - crate::diagnostics::DiagnosticStatus::Failure, - ) - .await?; - } - tracing::warn!("{err:?}") - } else { - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .send( - crate::diagnostics::DiagnosticAction::Install, - crate::diagnostics::DiagnosticStatus::Success, - ) - .await?; - } } Ok(()) @@ -270,7 +212,7 @@ impl InstallPlan { let buf = format!( "\ - Nix uninstall plan (v{version})\n\ + Lix uninstall plan (v{version})\n\ \n\ Planner: {planner}{maybe_default_setting_note}\n\ \n\ @@ -345,16 +287,6 @@ impl InstallPlan { tracing::error!("Error saving receipt: {:?}", err); } - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .send( - crate::diagnostics::DiagnosticAction::Uninstall, - crate::diagnostics::DiagnosticStatus::Cancelled, - ) - .await?; - } return Err(NixInstallerError::Cancelled); } } @@ -366,32 +298,9 @@ impl InstallPlan { } if errors.is_empty() { - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .send( - crate::diagnostics::DiagnosticAction::Uninstall, - crate::diagnostics::DiagnosticStatus::Success, - ) - .await?; - } - Ok(()) } else { let error = NixInstallerError::ActionRevert(errors); - #[cfg(feature = "diagnostics")] - if let Some(diagnostic_data) = &self.diagnostic_data { - diagnostic_data - .clone() - .failure(&error) - .send( - crate::diagnostics::DiagnosticAction::Uninstall, - crate::diagnostics::DiagnosticStatus::Failure, - ) - .await?; - } - Err(error) } } diff --git a/src/planner/linux.rs b/src/planner/linux.rs index 9fc3487..7f97a5f 100644 --- a/src/planner/linux.rs +++ b/src/planner/linux.rs @@ -126,19 +126,6 @@ impl Planner for Linux { Ok(settings) } - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(crate::diagnostics::DiagnosticData::new( - self.settings.diagnostic_attribution.clone(), - self.settings.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.settings.ssl_cert_file.clone(), - )?) - } async fn pre_uninstall_check(&self) -> Result<(), PlannerError> { check_not_wsl1()?; diff --git a/src/planner/macos.rs b/src/planner/macos.rs index 347e4bb..6a58d5a 100644 --- a/src/planner/macos.rs +++ b/src/planner/macos.rs @@ -238,20 +238,6 @@ impl Planner for Macos { Ok(settings) } - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(crate::diagnostics::DiagnosticData::new( - self.settings.diagnostic_attribution.clone(), - self.settings.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.settings.ssl_cert_file.clone(), - )?) - } - async fn pre_uninstall_check(&self) -> Result<(), PlannerError> { check_nix_darwin_not_installed().await?; diff --git a/src/planner/mod.rs b/src/planner/mod.rs index 97e7250..47070a1 100644 --- a/src/planner/mod.rs +++ b/src/planner/mod.rs @@ -12,7 +12,7 @@ A custom [`Planner`] can be created: ```rust,no_run use std::{error::Error, collections::HashMap}; -use nix_installer::{ +use lix_installer::{ InstallPlan, settings::{CommonSettings, InstallSettingsError}, planner::{Planner, PlannerError}, @@ -69,19 +69,6 @@ impl Planner for MyPlanner { Ok(settings) } - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(nix_installer::diagnostics::DiagnosticData::new( - self.common.diagnostic_attribution.clone(), - self.common.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.common.ssl_cert_file.clone(), - )?) - } } # async fn custom_planner_install() -> color_eyre::Result<()> { @@ -154,9 +141,6 @@ pub trait Planner: std::fmt::Debug + Send + Sync + dyn_clone::DynClone { async fn pre_install_check(&self) -> Result<(), PlannerError> { Ok(()) } - - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result; } dyn_clone::clone_trait_object!(Planner); @@ -309,21 +293,6 @@ impl BuiltinPlanner { } } - #[cfg(feature = "diagnostics")] - pub async fn diagnostic_data( - &self, - ) -> Result { - match self { - #[cfg(target_os = "linux")] - BuiltinPlanner::Linux(i) => i.diagnostic_data().await, - #[cfg(target_os = "linux")] - BuiltinPlanner::SteamDeck(i) => i.diagnostic_data().await, - #[cfg(target_os = "linux")] - BuiltinPlanner::Ostree(i) => i.diagnostic_data().await, - #[cfg(target_os = "macos")] - BuiltinPlanner::Macos(i) => i.diagnostic_data().await, - } - } } #[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] @@ -392,8 +361,8 @@ impl Default for FishShellProfileLocations { #[non_exhaustive] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)] pub enum PlannerError { - /// `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")] + /// `lix-installer` does not have a default planner for the target architecture right now + #[error("`lix-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")] @@ -433,9 +402,6 @@ pub enum PlannerError { /// Failed to execute command #[error("Failed to execute command `{0}`")] Command(String, #[source] std::io::Error), - #[cfg(feature = "diagnostics")] - #[error(transparent)] - Diagnostic(#[from] crate::diagnostics::DiagnosticError), } impl HasExpectedErrors for PlannerError { @@ -465,16 +431,7 @@ impl HasExpectedErrors for PlannerError { this @ PlannerError::NixExists => Some(Box::new(this)), this @ PlannerError::Wsl1 => Some(Box::new(this)), PlannerError::Command(_, _) => None, - #[cfg(feature = "diagnostics")] - PlannerError::Diagnostic(diagnostic_error) => Some(Box::new(diagnostic_error)), } } } -#[cfg(feature = "diagnostics")] -impl crate::diagnostics::ErrorDiagnostic for PlannerError { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - static_str.to_string() - } -} diff --git a/src/planner/ostree.rs b/src/planner/ostree.rs index fa246a4..a2ea670 100644 --- a/src/planner/ostree.rs +++ b/src/planner/ostree.rs @@ -266,19 +266,6 @@ impl Planner for Ostree { Ok(settings) } - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(crate::diagnostics::DiagnosticData::new( - self.settings.diagnostic_attribution.clone(), - self.settings.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.settings.ssl_cert_file.clone(), - )?) - } async fn pre_uninstall_check(&self) -> Result<(), PlannerError> { check_not_wsl1()?; diff --git a/src/planner/steam_deck.rs b/src/planner/steam_deck.rs index 915da62..da269df 100644 --- a/src/planner/steam_deck.rs +++ b/src/planner/steam_deck.rs @@ -385,20 +385,6 @@ impl Planner for SteamDeck { Ok(settings) } - #[cfg(feature = "diagnostics")] - async fn diagnostic_data(&self) -> Result { - Ok(crate::diagnostics::DiagnosticData::new( - self.settings.diagnostic_attribution.clone(), - self.settings.diagnostic_endpoint.clone(), - self.typetag_name().into(), - self.configured_settings() - .await? - .into_keys() - .collect::>(), - self.settings.ssl_cert_file.clone(), - )?) - } - async fn pre_uninstall_check(&self) -> Result<(), PlannerError> { super::linux::check_not_wsl1()?; diff --git a/src/self_test.rs b/src/self_test.rs index be04dfa..0615b19 100644 --- a/src/self_test.rs +++ b/src/self_test.rs @@ -26,27 +26,6 @@ pub enum SelfTestError { SystemTime(#[from] std::time::SystemTimeError), } -#[cfg(feature = "diagnostics")] -impl crate::diagnostics::ErrorDiagnostic for SelfTestError { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - let context = match self { - Self::ShellFailed { shell, .. } => vec![shell.to_string()], - Self::Command { shell, .. } => vec![shell.to_string()], - Self::SystemTime(_) => vec![], - }; - format!( - "{}({})", - static_str, - context - .iter() - .map(|v| format!("\"{v}\"")) - .collect::>() - .join(", ") - ) - } -} - #[derive(Clone, Copy, Debug)] pub enum Shell { Sh, diff --git a/src/settings.rs b/src/settings.rs index 6d7de4d..8101ed9 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -203,48 +203,6 @@ pub struct CommonSettings { ) )] pub force: bool, - - #[cfg(feature = "diagnostics")] - /// Relate the install diagnostic to a specific value - #[cfg_attr( - feature = "cli", - clap( - long, - default_value = None, - env = "NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION", - global = true - ) - )] - pub diagnostic_attribution: Option, - - #[cfg(feature = "diagnostics")] - /// The URL or file path for an installation diagnostic to be sent - /// - /// Sample of the data sent: - /// - /// { - /// "attribution": null, - /// "version": "0.4.0", - /// "planner": "linux", - /// "configured_settings": [ "modify_profile" ], - /// "os_name": "Ubuntu", - /// "os_version": "22.04.1 LTS (Jammy Jellyfish)", - /// "triple": "x86_64-unknown-linux-gnu", - /// "is_ci": false, - /// "action": "Install", - /// "status": "Success" - /// } - /// - /// To disable diagnostic reporting, unset the default with `--diagnostic-endpoint ""`, or `NIX_INSTALLER_DIAGNOSTIC_ENDPOINT=""` - #[clap( - long, - env = "NIX_INSTALLER_DIAGNOSTIC_ENDPOINT", - global = true, - value_parser = crate::diagnostics::diagnostic_endpoint_validator, - num_args = 0..=1, // Required to allow `--diagnostic-endpoint` or `NIX_INSTALLER_DIAGNOSTIC_ENDPOINT=""` - default_value = "https://install.determinate.systems/nix/diagnostic" - )] - pub diagnostic_endpoint: Option, } impl CommonSettings { @@ -313,10 +271,6 @@ impl CommonSettings { extra_conf: Default::default(), force: false, ssl_cert_file: Default::default(), - #[cfg(feature = "diagnostics")] - diagnostic_attribution: None, - #[cfg(feature = "diagnostics")] - diagnostic_endpoint: Some("https://install.determinate.systems/nix/diagnostic".into()), }) } @@ -334,10 +288,6 @@ impl CommonSettings { extra_conf, force, ssl_cert_file, - #[cfg(feature = "diagnostics")] - diagnostic_attribution: _, - #[cfg(feature = "diagnostics")] - diagnostic_endpoint, } = self; let mut map = HashMap::default(); @@ -373,13 +323,6 @@ impl CommonSettings { map.insert("ssl_cert_file".into(), serde_json::to_value(ssl_cert_file)?); map.insert("extra_conf".into(), serde_json::to_value(extra_conf)?); map.insert("force".into(), serde_json::to_value(force)?); - - #[cfg(feature = "diagnostics")] - map.insert( - "diagnostic_endpoint".into(), - serde_json::to_value(diagnostic_endpoint)?, - ); - Ok(map) } } @@ -665,14 +608,6 @@ impl clap::builder::TypedValueParser for UrlOrPathOrString { } } -#[cfg(feature = "diagnostics")] -impl crate::diagnostics::ErrorDiagnostic for InstallSettingsError { - fn diagnostic(&self) -> String { - let static_str: &'static str = (self).into(); - static_str.to_string() - } -} - #[cfg(test)] mod tests { use super::{FromStr, PathBuf, Url, UrlOrPath, UrlOrPathOrString}; diff --git a/tests/fixtures/linux/linux.json b/tests/fixtures/linux/linux.json index e30c6e5..30a1b62 100644 --- a/tests/fixtures/linux/linux.json +++ b/tests/fixtures/linux/linux.json @@ -416,7 +416,6 @@ "ssl_cert_file": null, "extra_conf": [], "force": false, - "diagnostic_endpoint": "https://install.determinate.systems/nix/diagnostic" }, "init": { "init": "Systemd", @@ -431,7 +430,6 @@ "os_version": "22.04.2 LTS (Jammy Jellyfish)", "triple": "x86_64-unknown-linux-musl", "is_ci": false, - "endpoint": "https://install.determinate.systems/nix/diagnostic", "ssl_cert_file": null, "failure_chain": null } diff --git a/tests/fixtures/linux/steam-deck.json b/tests/fixtures/linux/steam-deck.json index 311ab87..b93a2a4 100644 --- a/tests/fixtures/linux/steam-deck.json +++ b/tests/fixtures/linux/steam-deck.json @@ -400,7 +400,6 @@ "ssl_cert_file": null, "extra_conf": [], "force": false, - "diagnostic_endpoint": "https://install.determinate.systems/nix/diagnostic" } }, "diagnostic_data": { @@ -411,7 +410,6 @@ "os_version": "22.04.2 LTS (Jammy Jellyfish)", "triple": "x86_64-unknown-linux-musl", "is_ci": false, - "endpoint": "https://install.determinate.systems/nix/diagnostic", "ssl_cert_file": null, "failure_chain": null } diff --git a/tests/fixtures/macos/macos.json b/tests/fixtures/macos/macos.json index 6efbfe2..0b35279 100644 --- a/tests/fixtures/macos/macos.json +++ b/tests/fixtures/macos/macos.json @@ -427,7 +427,6 @@ "ssl_cert_file": null, "extra_conf": [], "force": false, - "diagnostic_endpoint": "https://install.determinate.systems/nix/diagnostic" }, "encrypt": null, "case_sensitive": false, @@ -442,7 +441,6 @@ "os_version": "unknown", "triple": "aarch64-apple-darwin", "is_ci": false, - "endpoint": "https://install.determinate.systems/nix/diagnostic", "ssl_cert_file": null, "failure_chain": null } diff --git a/tests/plan.rs b/tests/plan.rs index e34ad0f..7997894 100644 --- a/tests/plan.rs +++ b/tests/plan.rs @@ -1,4 +1,4 @@ -use nix_installer::InstallPlan; +use lix_installer::InstallPlan; #[cfg(target_os = "linux")] const LINUX: &str = include_str!("./fixtures/linux/linux.json"); diff --git a/upload_s3.sh b/upload_s3.sh deleted file mode 100755 index f7045b7..0000000 --- a/upload_s3.sh +++ /dev/null @@ -1,71 +0,0 @@ -set -eu - -DEST="$1" -GIT_ISH="$2" -DEST_INSTALL_URL="$3" - -is_tag() { - if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then - return 0 - else - return 1 - fi -} - -# If the revision directory has already been created in S3 somehow, we don't want to reupload -if aws s3 ls "$AWS_BUCKET"/"$GIT_ISH"/; then - # Only exit if it's not a tag (since we're tagging a commit previously pushed to main) - if ! is_tag; then - echo "Revision $GIT_ISH was already uploaded; exiting" - exit 1 - fi -fi - -sudo chown $USER: -R artifacts/ - -mkdir "$DEST" -mkdir "$GIT_ISH" - -cp nix-installer.sh "$DEST"/ -cp nix-installer.sh "$GIT_ISH"/ - -for artifact in $(find artifacts/ -type f); do - chmod +x "$artifact" - cp "$artifact" "$DEST"/ - cp "$artifact" "$GIT_ISH"/ -done - -sed -i "s@https://install.determinate.systems/nix@$DEST_INSTALL_URL@" "$DEST/nix-installer.sh" -sed -i "s@https://install.determinate.systems/nix@https://install.determinate.systems/nix/rev/$GIT_ISH@" "$GIT_ISH/nix-installer.sh" - -if is_tag; then - cp "$DEST/nix-installer.sh" ./nix-installer.sh -fi - -# If any artifact already exists in S3 and the hash is the same, we don't want to reupload -check_reupload() { - dest="$1" - - for file in $(find "$dest" -type f); do - artifact_path="$dest"/"$(basename "$artifact")" - md5="$(md5sum "$artifact" | cut -d' ' -f1)" - obj="$(aws s3api head-object --bucket "$AWS_BUCKET" --key "$artifact_path" || echo '{}')" - obj_md5="$(jq -r .ETag <<<"$obj" | jq -r)" # head-object call returns ETag quoted, so `jq -r` again to unquote it - - if [[ "$md5" == "$obj_md5" ]]; then - echo "Artifact $artifact was already uploaded; exiting" - # If we already uploaded to a tag, that's probably bad - is_tag && exit 1 || exit 0 - fi - done -} - -check_reupload "$DEST" -if ! is_tag; then - check_reupload "$GIT_ISH" -fi - -aws s3 sync "$DEST"/ s3://"$AWS_BUCKET"/"$DEST"/ --acl public-read -if ! is_tag; then - aws s3 sync "$GIT_ISH"/ s3://"$AWS_BUCKET"/"$GIT_ISH"/ --acl public-read -fi