blob: 42b7baa5af5c974a3a86e400ba95138d229eb45d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
{ config, lib, pkgs, ... }:
let
cfg = config.libkookie.rustup;
rustupSettings = pkgs.writeTextDir "settings.toml" ''
default_toolchain = "{cfg.defaulttoolchain}"
profile = "default"
version = "12"
[overrides]
# TODO: Add overrides to module
'';
rustupDir = pkgs.symlinkJoin {
name = "rustup-state";
paths = [ rustupSettings ];
};
pkgs.stdenv.mkDerivation {
name = "rustup";
buildInputs = [ pkgs.rustup ];
dontUnpack = true;
installPhase = ''
mkdir -p $out
echo "${(buildSettingsBase cfg.defaultToolchain)}" > $out/settings.toml
export $RUSTUP_HOME=$out
${pkgs.rustup}/bin/rustup default stable
'';
};
in
{
options.libkookie.rustup = with lib; {
enable = mkEnableOption "The Rust version manager";
defaultToolchain = mkOption {
type = types.str;
description = "The default Rust toolchain to use";
default = "stable-x86_64-unknown-linux-gnu";
};
};
config = lib.mkIf cfg.rustup.enable {
home.packages = with pkgs; [
(writeShellScriptBin "rustup" ''
RUSTUP_HOME=${rustupDir} ${rustup}/bin/rustup
'')
];
};
}
|