From 2da25058fc2622efeee2c4392a4cb9d3855cf9d1 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Thu, 18 Apr 2024 23:27:33 +0100 Subject: [PATCH] Added a nix-shell template and a rust dev shell --- nix-shells/rust.nix | 29 +++++++++++++++++++++++++++++ nix-shells/template.nix | 21 +++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 nix-shells/rust.nix create mode 100644 nix-shells/template.nix diff --git a/nix-shells/rust.nix b/nix-shells/rust.nix new file mode 100644 index 00000000..06ace200 --- /dev/null +++ b/nix-shells/rust.nix @@ -0,0 +1,29 @@ +# Rust development. + +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/master"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + # Rust packages + rustc + cargo + + # Shell utils + strace + wget + curl + ]; + + shellHook = '' + echo + PS1='\n\[\e[2m\][RUST]\[\e[0m\] \[\e[1m\]\w\[\e[0m\] \[\e[3m\]$(git branch --show-current 2>/dev/null)\n\[\e[0m\]\$ ' + echo -e "\e[31m[NIX-SHELL • RUST DEVELOPMENT ENVIRONMENT] \e[0m" + echo -ne "\e[1mVersion: \e[0m" + rustc --version + echo -ne " " + cargo --version + ''; +} diff --git a/nix-shells/template.nix b/nix-shells/template.nix new file mode 100644 index 00000000..cef59db5 --- /dev/null +++ b/nix-shells/template.nix @@ -0,0 +1,21 @@ +# https://nix.dev/tutorials/declarative-and-reproducible-developer-environments +let + # nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11"; + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/master"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + cowsay + lolcat + ]; + + # Environment Variables + GREETING = "Hello, Nix!"; + + # Startup command + shellHook = '' + echo $GREETING | cowsay | lolcat + ''; +}