Defined Type: rustup

Defined in:
manifests/init.pp

Summary

Manage a user’s Rust installation with `rustup`

Overview

The name should be the username.

Examples:

Standard usage

rustup { 'daniel': }

Parameters:

  • ensure (Enum[present, latest, absent]) (defaults to: present)
    • ‘present` - install rustup, but don’t update it.

    • ‘latest` - install rustup and update it on every puppet run.

    • ‘absent` - uninstall rustup and the tools it manages.

  • user (String[1]) (defaults to: $name)

    The user to own and manage rustup.

  • default_toolchain (Optional[String[1]]) (defaults to: undef)

    Which toolchain should be the default.

  • toolchains (Array[String[1]]) (defaults to: [])

    The toolchains to install.

  • purge_toolchains (Boolean) (defaults to: false)

    Whether or not to uninstall toolchains that aren’t managed by Puppet.

  • targets (Array[String[1]]) (defaults to: [])

    The targets to install. These can take two forms:

    * `"$target $toolchain"`: Install `$target` for `$toolchain`.
    * `"$target"`: Install `$target` for the default toolchain.
    

    You can use ‘’default’‘ to indicate the target for the current host.

  • purge_targets (Boolean) (defaults to: false)

    Whether or not to uninstall targets that aren’t managed by Puppet.

  • dist_server (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    Override ‘RUSTUP_DIST_SERVER`. Set to `’dev-static.rust-lang.org’‘ to install pre-release toolchains.

  • home (Stdlib::Absolutepath) (defaults to: rustup::home($user))

    The user’s home directory. This defaults to ‘/home/$user` on Linux and `/Users/$user` on macOS.

  • rustup_home (Stdlib::Absolutepath) (defaults to: "${home}/.rustup")

    Where toolchains are installed. Generally you shouldn’t change this.

  • cargo_home (Stdlib::Absolutepath) (defaults to: "${home}/.cargo")

    Where ‘cargo` installs executables. Generally you shouldn’t change this.

  • modify_path (Boolean) (defaults to: true)

    Whether or not to let ‘rustup` modify the user’s `PATH` in their shell init scripts. This only affects the initial installation and removal.

  • installer_source (Stdlib::HTTPUrl) (defaults to: 'https://sh.rustup.rs')

    URL of the rustup installation script. Changing this will have no effect after the initial installation.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'manifests/init.pp', line 45

define rustup (
  Enum[present, latest, absent] $ensure            = present,
  String[1]                     $user              = $name,
  Optional[String[1]]           $default_toolchain = undef,
  Array[String[1]]              $toolchains        = [],
  Boolean                       $purge_toolchains  = false,
  Array[String[1]]              $targets           = [],
  Boolean                       $purge_targets     = false,
  Optional[Stdlib::HTTPUrl]     $dist_server       = undef,
  Stdlib::Absolutepath          $home              = rustup::home($user),
  Stdlib::Absolutepath          $rustup_home       = "${home}/.rustup",
  Stdlib::Absolutepath          $cargo_home        = "${home}/.cargo",
  Boolean                       $modify_path       = true,
  Stdlib::HTTPUrl               $installer_source  = 'https://sh.rustup.rs',
) {
  if $ensure == absent {
    $_toolchains = []
    $_targets = []
  } else {
    $_toolchains = $toolchains.map |$toolchain| {
      {
        ensure  => present,
        name    => $toolchain,
        profile => 'default',
      }
    }

    $_targets = $targets.map |$target| {
      {
        ensure    => present,
        name      => $target.split(' ')[0],
        toolchain => $target.split(' ')[1],
      }
    }
  }

  rustup_internal { $name:
    ensure            => $ensure,
    user              => $user,
    default_toolchain => $default_toolchain,
    toolchains        => $_toolchains,
    purge_toolchains  => $purge_toolchains,
    targets           => $_targets,
    purge_targets     => $purge_targets,
    dist_server       => $dist_server,
    home              => $home,
    rustup_home       => $rustup_home,
    cargo_home        => $cargo_home,
    modify_path       => $modify_path,
    installer_source  => $installer_source,
  }
}