Add Rust development shell

This commit is contained in:
foo-dogsquared 2021-12-26 17:33:00 +08:00
parent 405fd9f1e1
commit 6bbad11fa0
4 changed files with 98 additions and 22 deletions

92
flake.lock generated
View File

@ -81,6 +81,21 @@
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1637014545,
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -88,11 +103,11 @@
]
},
"locked": {
"lastModified": 1639774225,
"narHash": "sha256-pdXvYneQVzB14fD+Q283s17tXRyQMs2JMx4mZ4JeSYg=",
"lastModified": 1640296831,
"narHash": "sha256-Mu32vTcfZru4VrvgnpvQKmwC4uY0oF3vnnC2o9SgnRU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8b44e81978a2bef60c83ecc0199ab2523310214a",
"rev": "f15b151ca1c4aea23515c241051d71f1b5cf97c8",
"type": "github"
},
"original": {
@ -104,18 +119,15 @@
"neovim-flake": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
]
"nixpkgs": "nixpkgs"
},
"locked": {
"dir": "contrib",
"lastModified": 1639795113,
"narHash": "sha256-pVBNbtpamfSOM3eBZWn/Xx9V9FwRaYw7WZ+yOUyz2UA=",
"lastModified": 1640212476,
"narHash": "sha256-479GRRtuk0JL0aQLvfAx+R1DvuNke1W3Fe8hTcuPUno=",
"owner": "neovim",
"repo": "neovim",
"rev": "818ae74eaf6f4538ca61ee4ba703543b0caaff10",
"rev": "7b8fbbdebe90a2dbf0d57464c93c7d5bfc3da449",
"type": "github"
},
"original": {
@ -129,14 +141,14 @@
"inputs": {
"flake-compat": "flake-compat",
"neovim-flake": "neovim-flake",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1639815237,
"narHash": "sha256-sSJdAQgF1F59BmlyRkXPlfZr2eic/AXcIAX+23p8V4M=",
"lastModified": 1640247287,
"narHash": "sha256-LjWjopWwbwdLN6Fmct59aJK0LYsUwbIgcQ5sY+n4N0g=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "368cdc561097d7d6ff67ada5feff818bef86a4d4",
"rev": "f8886b6b3cedf8a38dd6daa6dfe64df9c710bd65",
"type": "github"
},
"original": {
@ -147,11 +159,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1639525045,
"narHash": "sha256-z4GXFNzO+5V4CAUm2DDMAryLOWUKEbQif2ifvv1Ypg4=",
"lastModified": 1640233012,
"narHash": "sha256-DNKMmWZ/RLoh5IVJLAa5HYOy4IW28mBBYDMgMxzzom8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a2e281f5770247855b85d70c43454ba5bff34613",
"rev": "611f29bedadfb2aa4c9c26c4af65f05dd35f2f3f",
"type": "github"
},
"original": {
@ -163,11 +175,27 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1639713555,
"narHash": "sha256-w1TacWjnqhC19n+rheyOif3JxwvWMbyxfgqYCY0FLdQ=",
"lastModified": 1640139330,
"narHash": "sha256-Nkp3wUOGwtoQ7EH28RLVJ7EqB/e0TU7VcsM7GLy+SdY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "81cef6b70fb5d5cdba5a0fef3f714c2dadaf0d6d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1640269308,
"narHash": "sha256-vBVwv3+kPrxbNyfo48cB5cc5/4tq5zlJGas/qw8XNBE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "45a3f9d7725c7e21b252c223676cc56fb2ed5d6d",
"rev": "0c408a087b4751c887e463e3848512c12017be25",
"type": "github"
},
"original": {
@ -184,7 +212,29 @@
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs_3",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1640313506,
"narHash": "sha256-O7s/aV5xjhYV98Bw2/CR7zMwi+DLTEGiahpAJ9BAlgw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "203dc4fc3fe2a5df1aa481a3fc8a1bb27074d677",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},

View File

@ -19,6 +19,8 @@
# Overlays.
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
@ -29,6 +31,9 @@
# Neovim nightly!
inputs.neovim-nightly-overlay.overlay
# Rust overlay for them ease of setting up Rust toolchains.
inputs.rust-overlay.overlay
];
forAllSystems = f:
@ -133,6 +138,8 @@
# more preferable than installing all of the packages at the system
# configuration (or even home environment).
devShells = forAllSystems (system:
import ./shells { pkgs = import nixpkgs { inherit system; }; });
import ./shells {
pkgs = import nixpkgs { inherit system overlays; };
});
};
}

View File

@ -3,4 +3,5 @@
with pkgs; {
flatpak = callPackage ./flatpak.nix { };
hugo = callPackage ./hugo.nix { };
rust = callPackage ./rust.nix { };
}

18
shells/rust.nix Normal file
View File

@ -0,0 +1,18 @@
# This is just for a quick development setup. Otherwise, I recommend
# to use the `rust` template from `nixpkgs` or whatever you prefer.
{ mkShell, openssl, pkgconfig, cargo, rustc, rustfmt, rust-analyzer, rustPackages, rustPlatform }:
mkShell {
buildInputs = [
openssl # In case some package needs it.
pkgconfig # In case some other package needs it.
# Rust platform.
cargo
rustc
rustfmt
rust-analyzer
];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
}