From 4ed398b5e556ecfedea48a93f24c45bb12106477 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Tue, 4 Feb 2025 15:55:40 -0600 Subject: [PATCH] add rust-dev --- components/nix/rust-dev.nix | 50 +++++++++++++++++++++++++++++++++++++ hosts/oren/flake.nix | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 components/nix/rust-dev.nix diff --git a/components/nix/rust-dev.nix b/components/nix/rust-dev.nix new file mode 100644 index 0000000..06df1a2 --- /dev/null +++ b/components/nix/rust-dev.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: + +with lib; + +let + rustChannel = config.programs.rust.channel; + rustVersion = config.programs.rust.version; +in +{ + options.components.rust = { + enable = mkOption { + type = types.bool; + default = true; + description = "Enable Rust programming language support."; + }; + + repl = mkOption { + type = types.bool; + default = true; + description = "Enable the evcxr repl for `rust` command."; + }; + + channel = mkOption { + type = types.str; + default = "stable"; + description = "The Rust release channel to use (e.g., stable, beta, nightly)."; + }; + + version = mkOption { + type = types.str; + default = "latest"; + description = "The specific version of Rust to use. Use 'latest' for the latest stable release."; + }; + }; + + config = mkIf config.components.rust.enable { + environment.systemPackages = [ + pkgs.rustup + ] ++ (if config.components.rust.repl then [ pkgs.evcxr ] else [ ]); + + environment.shellAliases = mkIf config.components.rust.repl { + rust = "evcxr"; + }; + }; +} diff --git a/hosts/oren/flake.nix b/hosts/oren/flake.nix index f119800..d2b754b 100644 --- a/hosts/oren/flake.nix +++ b/hosts/oren/flake.nix @@ -47,7 +47,7 @@ { imports = [ ../../components/nix/lua.nix - ../../components/nix/rust-repl.nix + ../../components/nix/rust-dev.nix ../../components/nix/qflipper.nix ../../components/nix/qdirstat.nix ];