Configure rustup toolchain, cargo credentials, and put dependencies under cargo.
This commit is contained in:
parent
64e735abbf
commit
3ed43b1b8a
@ -1,3 +1,6 @@
|
|||||||
|
# MANUAL: rustup target add x86_64-unknown-linux-musl
|
||||||
|
# MANUAL: rustup target add wasm32-unknown-unknown
|
||||||
|
# MANUAL: rustup component add rustc-codegen-cranelift
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
@ -5,6 +8,14 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
cargo_wrapped =
|
||||||
|
package: prog:
|
||||||
|
pkgs.writeShellScriptBin "${prog}" ''
|
||||||
|
export PATH="$PATH:${lib.makeBinPath [ pkgs.clang ]}"
|
||||||
|
exec ${package}/bin/${prog} "''${@}"
|
||||||
|
'';
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
@ -37,17 +48,89 @@
|
|||||||
".cargo/config.toml" = {
|
".cargo/config.toml" = {
|
||||||
source = ./files/cargo_config.toml;
|
source = ./files/cargo_config.toml;
|
||||||
};
|
};
|
||||||
# # TODO: Figure out what to do with credentials.
|
".rustup/settings.toml" = {
|
||||||
# ".cargo/credentials.toml" = {
|
source = ./files/rustup_settings.toml;
|
||||||
# source = ./files/cargo_credentials.toml;
|
};
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
|
||||||
|
hideMounts = true;
|
||||||
|
users.talexander = {
|
||||||
|
directories = [
|
||||||
|
{
|
||||||
|
directory = ".rustup";
|
||||||
|
user = "talexander";
|
||||||
|
group = "talexander";
|
||||||
|
mode = "0755";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
directory = ".cargo/registry";
|
||||||
|
user = "talexander";
|
||||||
|
group = "talexander";
|
||||||
|
mode = "0755";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.link-rust-creds = {
|
||||||
|
# Contains credentials so it cannot be added to the nix store
|
||||||
|
enable = true;
|
||||||
|
description = "link-rust-creds";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
wants = [ "multi-user.target" ];
|
||||||
|
after = [ "multi-user.target" ];
|
||||||
|
# path = with pkgs; [
|
||||||
|
# zfs
|
||||||
|
# ];
|
||||||
|
unitConfig.DefaultDependencies = "no";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = "yes";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
if [ -e /persist/manual/rust/cargo_credentials.toml ]; then
|
||||||
|
install --directory --owner talexander --group talexander --mode 0755 /home/talexander/.cargo
|
||||||
|
ln -s /persist/manual/rust/cargo_credentials.toml /home/talexander/.cargo/credentials.toml
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
preStop = ''
|
||||||
|
rm -f /home/talexander/.cargo/credentials.toml
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
rustup = pkgs.symlinkJoin {
|
||||||
|
name = "rustup";
|
||||||
|
paths =
|
||||||
|
(builtins.map (cargo_wrapped prev.rustup) [
|
||||||
|
"cargo"
|
||||||
|
"cargo-clippy"
|
||||||
|
"cargo-fmt"
|
||||||
|
"cargo-miri"
|
||||||
|
"clippy-driver"
|
||||||
|
"rls"
|
||||||
|
"rust-analyzer"
|
||||||
|
"rust-gdb"
|
||||||
|
"rust-gdbgui"
|
||||||
|
"rust-lldb"
|
||||||
|
"rustc"
|
||||||
|
"rustdoc"
|
||||||
|
"rustfmt"
|
||||||
|
"rustup"
|
||||||
|
])
|
||||||
|
++ [
|
||||||
|
prev.rustup
|
||||||
|
];
|
||||||
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Install clippy, cranelift, rust-src
|
# TODO: Install clippy, cranelift, rust-src
|
||||||
# TODO: Install rust targets x86_64-unknown-linux-musl and wasm32-unknown-unknown
|
|
||||||
|
5
nix/configuration/roles/rust/files/rustup_settings.toml
Normal file
5
nix/configuration/roles/rust/files/rustup_settings.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
default_toolchain = "nightly-x86_64-unknown-linux-gnu"
|
||||||
|
profile = "default"
|
||||||
|
version = "12"
|
||||||
|
|
||||||
|
[overrides]
|
Loading…
x
Reference in New Issue
Block a user