Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds nix subcommand that uses the fuel.nix flake to manage binaries #461

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
98b549d
add process for fuelup deprecation
eureka-cpu Jul 20, 2023
185335d
wip add check_cmd nix
eureka-cpu Jul 20, 2023
530d00b
fix accidental change
eureka-cpu Jul 20, 2023
88a2a55
fix spacing
eureka-cpu Jul 20, 2023
fa4b52b
test CI & nix
eureka-cpu Jul 24, 2023
c7dcccc
fix legacy wrap
eureka-cpu Jul 24, 2023
ee02880
wrap curl command in function
eureka-cpu Jul 24, 2023
bef8881
test check_cmd nix
eureka-cpu Jul 24, 2023
47fa38d
rm nix -v from ci check
eureka-cpu Jul 25, 2023
e6a5215
wrap curl cmd, add nix -v back to ci
eureka-cpu Jul 25, 2023
d159bab
test fuel nix fn
eureka-cpu Jul 25, 2023
ee77239
add --no-confirm to accept default nix installation
eureka-cpu Jul 25, 2023
8f18c7b
add --no-confirm to accept default nix installation v2
eureka-cpu Jul 25, 2023
e75eca1
add init nix after install
eureka-cpu Jul 25, 2023
bc19339
try running daemon on new line
eureka-cpu Jul 25, 2023
ce74266
try direct use
eureka-cpu Jul 25, 2023
e88169e
try opening new shell
eureka-cpu Jul 25, 2023
fce2e22
rm need_cmd nix
eureka-cpu Jul 25, 2023
0c96b83
remove failing nix check for now
eureka-cpu Jul 25, 2023
575c1ce
handle found nix
eureka-cpu Jul 25, 2023
c3005a9
fix spacing
eureka-cpu Jul 25, 2023
3d4ef1e
rm unused readonly
eureka-cpu Jul 25, 2023
3002d80
fix check_cmd nix
eureka-cpu Jul 25, 2023
dc0ccf6
add links for configuring nix
eureka-cpu Jul 25, 2023
9810ad5
make pre configured nix install a warning
eureka-cpu Jul 25, 2023
966f345
add important to msg
eureka-cpu Jul 25, 2023
45761b0
wip install toolchain cmd
eureka-cpu Jul 25, 2023
e181e6c
wip list cmd
eureka-cpu Jul 25, 2023
f2b32c6
mv msg
eureka-cpu Jul 25, 2023
6ea71cc
fix fuelup component list
eureka-cpu Jul 25, 2023
02141ed
update install info and list formatting
eureka-cpu Jul 26, 2023
9daf7b8
fix installing toolchain msg
eureka-cpu Jul 31, 2023
903604f
add temp shell command
eureka-cpu Jul 31, 2023
6063fa3
add priority to install method
eureka-cpu Aug 7, 2023
f3b973c
refactor nix commands
eureka-cpu Aug 7, 2023
47e0ffc
remove shell command
eureka-cpu Aug 7, 2023
73e2f55
remove shell impls
eureka-cpu Aug 7, 2023
62e7237
Merge branch 'master' into eureka-cpu/457
eureka-cpu Aug 7, 2023
f554d33
wip ci nix check
eureka-cpu Aug 10, 2023
69f8b6d
rm cachix secret
eureka-cpu Aug 10, 2023
db4c1a4
run fuelup bin via cargo with nix args
eureka-cpu Aug 10, 2023
d18a233
fix usage of fuelup bin
eureka-cpu Aug 10, 2023
aa78119
try fix fuelup bin path
eureka-cpu Aug 10, 2023
2586830
try adding fuelup to PATH
eureka-cpu Aug 10, 2023
7f328f2
find cargo path
eureka-cpu Aug 10, 2023
e20600d
test
eureka-cpu Aug 10, 2023
b95bb4e
trying to get fuelup to install via cargo
eureka-cpu Aug 10, 2023
0ee1872
fix preinstall message
eureka-cpu Aug 10, 2023
4c282dd
fix found nix message
eureka-cpu Aug 10, 2023
13df2af
Merge branch 'master' into eureka-cpu/457
eureka-cpu Aug 10, 2023
7ced739
add nix.conf file
eureka-cpu Aug 10, 2023
6244855
add cachix auth token
eureka-cpu Aug 16, 2023
2da057a
auto prioritize packages
eureka-cpu Aug 16, 2023
b320188
add stdout inherit to upgrade command, update nix_info macro with iss…
eureka-cpu Aug 17, 2023
20007b1
clippy
eureka-cpu Aug 17, 2023
1bf2b04
update info message for upgrade command
eureka-cpu Aug 17, 2023
568cddb
Merge branch 'master' into eureka-cpu/457
eureka-cpu Aug 17, 2023
8489142
fix stdout and add handling message for auto prioritization
eureka-cpu Aug 17, 2023
8b27520
Merge branch 'master' into eureka-cpu/457
eureka-cpu Aug 18, 2023
f3ef82a
wip remove error from log
eureka-cpu Aug 19, 2023
54eccc2
Merge branch 'master' into eureka-cpu/457
eureka-cpu Aug 19, 2023
0156f2c
finalize auto prioritize pkgs, fix stderr output
eureka-cpu Aug 20, 2023
ea29b85
abstract command filter function
eureka-cpu Aug 20, 2023
0613918
rename prio msg consts
eureka-cpu Aug 20, 2023
c5100db
update docstring for filter_command
eureka-cpu Aug 20, 2023
d46db1e
clippy
eureka-cpu Aug 20, 2023
70b84ff
fix error handling of install, wip list
eureka-cpu Aug 21, 2023
854278b
more wip list
eureka-cpu Aug 21, 2023
abdfa24
list command debug internals are more concise
eureka-cpu Aug 23, 2023
7cdd51e
update docs, adjust naming conventions, refactor comp err msg
eureka-cpu Aug 24, 2023
7c520b4
remove unused impl
eureka-cpu Aug 24, 2023
90f4966
clean up stray comments
eureka-cpu Aug 24, 2023
b24e74e
update all err msgs
eureka-cpu Aug 24, 2023
9a92823
make utils available to crate
eureka-cpu Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 46 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ jobs:
- name: Attempt to install fuelup through fuelup-init.sh
run: ./fuelup-init.sh

test-fuelup-nix:
needs: cancel-previous-runs
if: github.event_name != 'release' || github.event.action != 'published'
name: Test fuelup nix
strategy:
matrix:
job:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Attempt to install fuelup through cargo
run: cargo install --path .
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Copy nix.conf to /etc/nix/nix.conf
run: sudo cp -f /etc/nix/nix.conf ./nix.conf
- name: Test fuelup nix install
run: ~/.cargo/bin/fuelup nix install latest
- name: Test fuelup nix list
run: ~/.cargo/bin/fuelup nix list
- name: Test fuelup nix upgrade
run: ~/.cargo/bin/fuelup nix upgrade
- name: Test fuelup nix remove
run: ~/.cargo/bin/fuelup nix remove 0

cargo-clippy:
needs: cancel-previous-runs
runs-on: ubuntu-latest
Expand All @@ -59,7 +90,7 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v1

- name: Check Clippy Linter
Expand All @@ -73,10 +104,10 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Check Formatting
run: cargo fmt --all -- --check

cargo-test-workspace:
needs: cancel-previous-runs
runs-on: ubuntu-latest
Expand All @@ -85,10 +116,10 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run tests
run: cargo test --locked --workspace

lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
Expand All @@ -99,7 +130,7 @@ jobs:

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
Expand Down Expand Up @@ -269,16 +300,16 @@ jobs:
# Re-generate the channel TOML file
- name: Rebuild channel with updated components
run: |
mkdir -p ${{ env.LATEST_CHANNEL_DIR }}
CHANNEL_TOML="channel-fuel-latest.toml"
mkdir -p ${{ env.LATEST_CHANNEL_DIR }}
CHANNEL_TOML="channel-fuel-latest.toml"

FORC_VERSION=$(grep -A1 '\[pkg.forc\]' ./gh-pages/channel-fuel-latest.toml | cut -d "\"" -f2)
FUEL_CORE_VERSION=$(grep -A1 '\[pkg.fuel-core\]' ./gh-pages/channel-fuel-latest.toml | cut -d "\"" -f2)
FORC_VERSION=$(grep -A1 '\[pkg.forc\]' ./gh-pages/channel-fuel-latest.toml | cut -d "\"" -f2)
FUEL_CORE_VERSION=$(grep -A1 '\[pkg.fuel-core\]' ./gh-pages/channel-fuel-latest.toml | cut -d "\"" -f2)

PUBLISHED_DATE=$(date +'%Y-%m-%d')
build-channel $CHANNEL_TOML $PUBLISHED_DATE --github-run-id $GITHUB_RUN_ID forc=$FORC_VERSION fuel-core=$FUEL_CORE_VERSION
PUBLISHED_DATE=$(date +'%Y-%m-%d')
build-channel $CHANNEL_TOML $PUBLISHED_DATE --github-run-id $GITHUB_RUN_ID forc=$FORC_VERSION fuel-core=$FUEL_CORE_VERSION

cp $CHANNEL_TOML ${{ env.LATEST_CHANNEL_DIR }}
cp $CHANNEL_TOML ${{ env.LATEST_CHANNEL_DIR }}

- name: Deploy latest channel
if: ${{ env.LATEST_COMPATIBLE_FORC && env.LATEST_COMPATIBLE_FUEL_CORE }}
Expand All @@ -288,8 +319,8 @@ jobs:
publish_dir: ${{ env.LATEST_CHANNEL_DIR }}
keep_files: true
destination_dir: ./
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"

post-release-checks:
name: Do post-release checks
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.showUnlinkedFileNotification": false
}
32 changes: 32 additions & 0 deletions fuelup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ main() {
check_cargo_bin forc-lsp
check_cargo_bin fuel-core

local _found_nix=false
if check_cmd nix; then
_found_nix=true
else
run_fuel_nix_install_script
fi

get_architecture || return 1
local _arch="$RETVAL"
assert_nz "$_arch" "arch"
Expand Down Expand Up @@ -150,6 +157,10 @@ main() {
add_path_message
fi

if [ "$_found_nix" = true ]; then
found_nix_message
fi

return "$_retval"
}

Expand All @@ -158,6 +169,8 @@ preinstall_confirmation() {

fuelup uses "$FUELUP_DIR" as its home directory to manage the Fuel toolchain, and will install binaries there.

Using the fuelup nix subcommands will manage installed binaries at /nix/store.

To use the toolchain, you will have to configure your PATH, which tells your machine where to locate fuelup and the Fuel toolchain.

If permitted, fuelup-init will configure your PATH for you by running the following:
Expand All @@ -183,6 +196,20 @@ fish_add_path ~/.fuelup/bin
EOF
}

found_nix_message() {
cat 1>&2 <<EOF

Found pre-configured nix installation.

IMPORTANT: Certain nix features must be enabled for fuelup nix to work.

Please follow the instructions below to finish your setup, as fuelup will not amend nix config files for you at this time.

- Nix : https://github.com/FuelLabs/fuel.nix/blob/master/book/src/nix-setup.md#configuring-an-existing-nix-installation
- NixOS : https://github.com/FuelLabs/fuel.nix/blob/master/book/src/nix-setup.md#configuring-nixos
EOF
}

get_architecture() {
local _ostype _cputype
_ostype="$(uname -s)"
Expand Down Expand Up @@ -330,6 +357,11 @@ downloader() {
fi
}

run_fuel_nix_install_script() {
echo "running fuel.nix install script..."
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.9.0 | sh -s -- install --no-confirm --extra-conf "extra-substituters = https://fuellabs.cachix.org" --extra-conf "extra-trusted-public-keys = fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8="
}

# Check if curl supports the --retry flag, then pass it to the curl invocation.
check_curl_for_retry_support() {
local _retry_supported=""
Expand Down
9 changes: 9 additions & 0 deletions nix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by https://github.com/DeterminateSystems/nix-installer, version 0.9.0.
experimental-features = nix-command flakes auto-allocate-uids
extra-trusted-public-keys = fuellabs.cachix.org-1:3gOmll82VDbT7EggylzOVJ6dr0jgPVU/KMN6+Kf8qx8=
extra-nix-path = nixpkgs=flake:nixpkgs
auto-optimise-store = true
extra-substituters = https://fuellabs.cachix.org
auto-allocate-uids = true
build-users-group = nixbld
bash-prompt-prefix = (nix:$name)\040
2 changes: 1 addition & 1 deletion src/commands/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct RemoveCommand {
}

#[derive(Debug, Parser)]
pub struct ListCommand {}
pub struct ListCommand;

pub fn exec(command: ComponentCommand) -> Result<()> {
match command {
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod completions;
pub mod component;
pub mod default;
pub mod fuelup;
pub mod nix;
pub mod show;
pub mod toolchain;
pub mod update;
Loading
Loading