From f828c1c200ccaf3934d4f0e97576366475e44628 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:13:49 -0400 Subject: [PATCH] add rust programming tooling --- hosts/tempest/default.nix | 1 + modules/common/programming/default.nix | 1 + modules/common/programming/rust.nix | 17 +++++++++++++++++ templates/poetry/flake.nix | 2 +- templates/python/flake.nix | 2 +- templates/rust/flake.nix | 20 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 modules/common/programming/rust.nix create mode 100644 templates/rust/flake.nix diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index 811c2d3..958ba51 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -99,6 +99,7 @@ inputs.nixpkgs.lib.nixosSystem { keybase.enable = true; mullvad.enable = false; nixlang.enable = true; + rust.enable = true; yt-dlp.enable = true; gaming = { dwarf-fortress.enable = true; diff --git a/modules/common/programming/default.nix b/modules/common/programming/default.nix index f8e9f5d..7e2593b 100644 --- a/modules/common/programming/default.nix +++ b/modules/common/programming/default.nix @@ -6,6 +6,7 @@ ./lua.nix ./nix.nix ./python.nix + ./rust.nix ./terraform.nix ]; diff --git a/modules/common/programming/rust.nix b/modules/common/programming/rust.nix new file mode 100644 index 0000000..da28c21 --- /dev/null +++ b/modules/common/programming/rust.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: { + + options.rust.enable = lib.mkEnableOption "Rust programming language."; + + config = lib.mkIf config.rust.enable { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ cargo rustc ]; + + programs.fish.shellAbbrs = { }; + + }; + + }; + +} diff --git a/templates/poetry/flake.nix b/templates/poetry/flake.nix index c03832c..10f1e5f 100644 --- a/templates/poetry/flake.nix +++ b/templates/poetry/flake.nix @@ -5,7 +5,7 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs"; inputs.poetry2nix.url = "github:nix-community/poetry2nix"; - outputs = { nixpkgs, flake-utils, poetry2nix }: + outputs = { self, nixpkgs, flake-utils, poetry2nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { diff --git a/templates/python/flake.nix b/templates/python/flake.nix index 103efdd..f66e5f4 100644 --- a/templates/python/flake.nix +++ b/templates/python/flake.nix @@ -11,7 +11,7 @@ inputs.pypi-deps-db.follows = "pypi-deps-db"; }; - outputs = { nixpkgs, mach-nix }: + outputs = { self, nixpkgs, mach-nix }: let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix new file mode 100644 index 0000000..660f1ba --- /dev/null +++ b/templates/rust/flake.nix @@ -0,0 +1,20 @@ +{ + description = "Basic Rust project"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + outputs = { self, nixpkgs }: + let + forAllSystems = nixpkgs.lib.genAttrs [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + in { + devShells = forAllSystems (system: + let pkgs = import nixpkgs { inherit system; }; + in { + default = + pkgs.mkShell { buildInputs = with pkgs; [ gcc rustc cargo ]; }; + }); + }; +}