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

Conversation

eureka-cpu
Copy link
Contributor

@eureka-cpu eureka-cpu commented Jul 20, 2023

Adds a fuelup nix subcommand that makes calls into the fuel.nix flake. This does not break the current fuelup, but will ease users into trying out the nix approach to managing toolchains and components.

Closes #457

Process for achieving completion of #457

  • In fuelup-init.sh use check_cmd for nix, if it is installed for the user there is no need to run the installation script.
    • find a way to amend their conf.nix file to include the fuel binary cache from cachix and the necessary unstable features (also check if those features are already enabled) out of the scope of this PR, handled by way of ending message
  • If nix isn't present, run the full fuel.nix install script.
  • Create a fuelup profile to separate fuel binaries from existing users main profile (this can be a follow up issue)
  • Map fuel.nix flake commands to the fuelup CLI commands already available.
    • fuelup nix install: install toolchain and components
      • auto prioritize the newly installed package
      • print child stderr
      • add verbosity flag
      • remove old toolchain or component before installing to avoid duplicate binaries with different priorities (reliant on updates to fuelup nix list)
    • fuelup nix list: list installed toolchains and components (nix default)
      • make fuelup nix list more robust by organizing the display of toolchains and components in a more similar way to the current fuelup
    • fuelup nix remove: remove toolchains and components
    • fuelup nix upgrade: upgrade toolchains and components
    • enable nix shell feat: add fuelup nix shell command #463
  • Run tests to ensure all features work as intended.
    • test locally
    • unit tests where applicable
    • CI tests where applicable

@eureka-cpu eureka-cpu added enhancement enhancement to a current feature fuelup-init Issues related to the Shell script, fuelup-init breaking labels Jul 20, 2023
@eureka-cpu eureka-cpu self-assigned this Jul 20, 2023
@eureka-cpu eureka-cpu changed the title feat: Use fuel.nix flake as the underlying installation method feat: Use fuel.nix flake as the fuelup backend Jul 20, 2023
@JoshuaBatty
Copy link
Member

JoshuaBatty commented Aug 20, 2023

Leaving some more UX feedback.

After installing and running fuelup nix i get the following:

fuelup % fuelup nix
Use the fuel.nix flake to manage toolchains and components. Refer to the fuel.nix book for more info: https://github.com/FuelLabs/fuel.nix/blob/master/book/src/packages.md#packages

Usage: fuelup nix <COMMAND>

Commands:
  install  Install a distributable toolchain or component
  remove   Uninstall a toolchain or component by providing its index, unlocked attribute path or nix store path
  upgrade  Upgrade installed packages by index or unlocked attribute path with the latest version of the fuel.nix flake. Upgrades all installed packages if no index or path is provided
  list     Lists the installed packages by index, unlocked attribute path, locked attribute path and nix store path, respectively
  help     Print this message or the help of the given subcommand(s)

Can we remove this part below and just show the usage...

Use the fuel.nix flake to manage toolchains and components. Refer to the fuel.nix book for more info: https://github.com/FuelLabs/fuel.nix/blob/master/book/src/packages.md#packages

Also, can we keep the existing command descriptions instead of the ones from fuel.nix.

@JoshuaBatty
Copy link
Member

JoshuaBatty commented Aug 20, 2023

I'm running fuelup nix install latest with the latest changes.

fuelup % fuelup nix install latest
downloading and installing fuel latest toolchain, this may take a while...
copying path '/nix/store/jskppgw1xjb1n7bkf6nmmqw6kk2a0c9z-sway-04a5970' from 'https://fuellabs.cachix.org'...
this derivation will be built:
  /nix/store/yds5gwpd5hhglxrzi3mh1pf6m43ipkyb-fuel-latest.drv
these 6 paths will be fetched (86.43 MiB download, 182.03 MiB unpacked):
  /nix/store/r1mwwpd3wjlwgs00h8pzngdwxk9ibl2m-forc-0.44.1
  /nix/store/161rs18wjmpx0vlvgzskc59c4lj8vwv7-forc-client-0.44.1
  /nix/store/wizcks47lf3zzdgfj94h0fs48qkn0bgh-forc-doc-0.44.1
  /nix/store/iagvlp5vlaycw9qgc89v75irr2xr2bb6-forc-fmt-0.44.1

Although I think printing every line to the console is useful, this should be behind a --verbose flag. By default, only one line is used for the installation status and subsequent messages overwrite the single line in the terminal.

@JoshuaBatty
Copy link
Member

JoshuaBatty commented Aug 20, 2023

I also got this message printing to the console

building '/nix/store/yds5gwpd5hhglxrzi3mh1pf6m43ipkyb-fuel-latest.drv'...
error: An existing package already provides the following file:

         /nix/store/d2f5baagzqim9flchiswcpf7z8061h6p-fuel-latest/bin/forc-doc

       This is the conflicting file from the new package:

         /nix/store/ib3lyc87qikp98gx9djd2j6354vnjr7c-fuel-latest/bin/forc-doc

       To remove the existing package:

         nix profile remove github:fuellabs/fuel.nix

       The new package can also be installed next to the existing one by assigning a different priority.
       To prioritise the new package:

         nix profile install github:fuellabs/fuel.nix --priority 4

       To prioritise the existing package:

         nix profile install github:fuellabs/fuel.nix --priority 6

Not sure why this message still got through?

I then ran the command again and this time it just returned to the console with no status message if the installation was successful or had failed..

fuelup % fuelup nix install latest
downloading and installing fuel latest toolchain, this may take a while...
fuelup %

@eureka-cpu
Copy link
Contributor Author

Leaving some more UX feedback.

After installing and running fuelup nix i get the following:

fuelup % fuelup nix
Use the fuel.nix flake to manage toolchains and components. Refer to the fuel.nix book for more info: https://github.com/FuelLabs/fuel.nix/blob/master/book/src/packages.md#packages

Usage: fuelup nix <COMMAND>

Commands:
  install  Install a distributable toolchain or component
  remove   Uninstall a toolchain or component by providing its index, unlocked attribute path or nix store path
  upgrade  Upgrade installed packages by index or unlocked attribute path with the latest version of the fuel.nix flake. Upgrades all installed packages if no index or path is provided
  list     Lists the installed packages by index, unlocked attribute path, locked attribute path and nix store path, respectively
  help     Print this message or the help of the given subcommand(s)

Can we remove this part below and just show the usage...

Use the fuel.nix flake to manage toolchains and components. Refer to the fuel.nix book for more info: https://github.com/FuelLabs/fuel.nix/blob/master/book/src/packages.md#packages

Also, can we keep the existing command descriptions instead of the ones from fuel.nix.

They aren't from the flake, I wrote those because they are accurate to the actual logic behind the command. I can remove them, but it will be less descriptive on how to actually use the commands in some cases

@eureka-cpu
Copy link
Contributor Author

I also got this message printing to the console

building '/nix/store/yds5gwpd5hhglxrzi3mh1pf6m43ipkyb-fuel-latest.drv'...
error: An existing package already provides the following file:

         /nix/store/d2f5baagzqim9flchiswcpf7z8061h6p-fuel-latest/bin/forc-doc

       This is the conflicting file from the new package:

         /nix/store/ib3lyc87qikp98gx9djd2j6354vnjr7c-fuel-latest/bin/forc-doc

       To remove the existing package:

         nix profile remove github:fuellabs/fuel.nix

       The new package can also be installed next to the existing one by assigning a different priority.
       To prioritise the new package:

         nix profile install github:fuellabs/fuel.nix --priority 4

       To prioritise the existing package:

         nix profile install github:fuellabs/fuel.nix --priority 6

Not sure why this message still got through?

I then ran the command again and this time it just returned to the console with no status message if the installation was successful or had failed..

fuelup % fuelup nix install latest
downloading and installing fuel latest toolchain, this may take a while...
fuelup %

The reason the error was still showing up was because I accidentally removed a line that checked for "error:" in one of my commits where I was cleaning up

the reason you don't see it after if you run it again is because it went through the auto prioritize function

Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointed out some stuff that got merged while this PR was cooking so that if we decide to merge this one we do not lose anything

Comment on lines 173 to 189
Ok((match comp.as_str() {
"fuel-core" => Self::FuelCore,
"fuel-core-client" => Self::FuelCoreClient,
"fuel-indexer" => Self::FuelIndexer,
"forc" => Self::Forc,
"forc-client" => Self::ForcClient,
"forc-doc" => Self::ForcDoc,
"forc-explore" => Self::ForcExplore,
"forc-fmt" => Self::ForcFmt,
"forc-index" => Self::ForcIndex,
"forc-lsp" => Self::ForcLsp,
"forc-tx" => Self::ForcTx,
"forc-wallet" => Self::ForcWallet,
"sway-vim" => Self::SwayVim,
_ => bail!(
"available distrubuted components:\n -fuel-core\n -fuel-core-client\n -fuel-indexer\n -forc\n -forc-client\n -forc-doc\n -forc-explore\n -forc-fmt\n -forc-index\n -forc-lsp\n -forc-tx\n -forc-wallet\n -sway-vim\n
available distributed toolchains:\n -latest\n -nightly\n -beta-1\n -beta-2\n -beta-3\n -beta-4-rc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also started to distribute fuel-core-keygen as of #472

Comment on lines 53 to 60
let tool = match tool {
FuelToolchain::Latest => "",
FuelToolchain::Nightly => "-nightly",
FuelToolchain::Beta1 => "-beta-1",
FuelToolchain::Beta2 => "-beta-2",
FuelToolchain::Beta3 => "-beta-3",
FuelToolchain::Beta4rc => "-beta-4-rc",
FuelToolchain::Unknown => bail!("available distributed toolchains:\n -latest\n -nightly\n -beta-1\n -beta-2\n -beta-3\n -beta-4-rc")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have beta-4-rc.2 as of #467

Comment on lines 92 to 101
#[derive(Eq, PartialEq, Debug)]
pub(crate) enum FuelToolchain {
Latest,
Nightly,
Beta1,
Beta2,
Beta3,
Beta4rc,
Unknown,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I guess we should also add Beta4Rc2 to this list as well.

@eureka-cpu
Copy link
Contributor Author

Thanks @kayagokalp I'll update those soon

@eureka-cpu
Copy link
Contributor Author

Closing since we are not using this approach as discussed in #457

@eureka-cpu eureka-cpu closed this Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement to a current feature fuelup-init Issues related to the Shell script, fuelup-init
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use fuel.nix internally and deprecate current work.
4 participants