From f3e42486330ae2f63f2935cfa379e3eb8cda9d75 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Mon, 11 Nov 2024 14:06:54 +0100 Subject: [PATCH] add rust, rust-overlay --- modules/jetbrains-ide.nix | 6 ++++++ modules/nur-and-unstable.nix | 12 ++++++++++-- modules/rust.nix | 22 ++++++++++++++++++++++ nix/sources.json | 12 ++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 modules/rust.nix diff --git a/modules/jetbrains-ide.nix b/modules/jetbrains-ide.nix index 903bef3..021f535 100644 --- a/modules/jetbrains-ide.nix +++ b/modules/jetbrains-ide.nix @@ -14,6 +14,12 @@ in # - .env run configuration: https://github.com/NixOS/nix-idea/issues/1#issuecomment-590851686 # - nix-shell IDE-wide: https://github.com/NixOS/nix-idea/issues/1#issuecomment-734997521 + imports = + [ + # Rust programming lang + ./rust.nix + ]; + allowUnfree = [ version ]; diff --git a/modules/nur-and-unstable.nix b/modules/nur-and-unstable.nix index a108b58..47be825 100644 --- a/modules/nur-and-unstable.nix +++ b/modules/nur-and-unstable.nix @@ -1,4 +1,7 @@ { config, pkgs, lib, ... }: +let + sources = import ../nix/sources.nix; +in { # How NUR (or unstable) can be imported without `niv`. #nixpkgs.config.packageOverrides = pkgs: { @@ -9,11 +12,11 @@ nixpkgs.config.packageOverrides = pkgs: { # Import NUR with niv. - nur = import (import ../nix/sources.nix).NUR { + nur = import sources.NUR { inherit pkgs; }; # Import unstable with niv. - unstable = import (import ../nix/sources.nix).unstable { + unstable = import sources.unstable { inherit pkgs; # "unstable" `nixpkgs.config` has to be configured here where we import it. @@ -33,6 +36,11 @@ }; }; + nixpkgs.overlays = [ + # Import rust-overlay with niv. + (import sources.rust-overlay) + ]; + #environment.systemPackages = with pkgs; [ # # Example NUR usage: # nur.repos.mic92.hello-nur diff --git a/modules/rust.nix b/modules/rust.nix new file mode 100644 index 0000000..173d2b1 --- /dev/null +++ b/modules/rust.nix @@ -0,0 +1,22 @@ +{ config, pkgs, ... }: +let + #rustVersion = pkgs.rust-bin.stable."1.81.0".default.override { + rustVersion = pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + #targets = [ + # "x86_64-unknown-linux-musl" + # #"arm-unknown-linux-gnueabihf" + # #"wasm32-wasi" + # #"wasm32-unknown-unknown" + #]; + }; + rustPlatform = pkgs.makeRustPlatform { + cargo = rustVersion; + rustc = rustVersion; + }; +in +{ + environment.systemPackages = with pkgs; [ + rustPlatform.rust.cargo + ]; +} diff --git a/nix/sources.json b/nix/sources.json index a7fc28e..8b8a2af 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -35,6 +35,18 @@ "url": "https://github.com/NixOS/nixpkgs/archive/83fb6c028368e465cd19bb127b86f971a5e41ebc.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "rust-overlay": { + "branch": "master", + "description": "Pure and reproducible nix overlay of binary distributed rust toolchains", + "homepage": "", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7c4cd99ed7604b79e8cb721099ac99c66f656b3a", + "sha256": "00h0j10d1zxg03gjzzfj22s14fs0apmd2cvxmk7dcsaj9d8ni1bx", + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/7c4cd99ed7604b79e8cb721099ac99c66f656b3a.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "unstable": { "branch": "nixpkgs-unstable", "description": "Nix Packages collection & NixOS",