Add initial rust template

This commit is contained in:
Sam W 2022-05-20 12:32:45 +01:00
parent be4ad17373
commit ffeb072222
4 changed files with 94 additions and 0 deletions

41
flake.lock Normal file
View File

@ -0,0 +1,41 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1652840887,
"narHash": "sha256-gEK4NNa4GwIgTZE63kt/4WTFAWRTJVSa30+h4ZjFh9U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "52dc75a4fee3fdbcb792cb6fba009876b912bfe0",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1652776076,
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

16
flake.nix Normal file
View File

@ -0,0 +1,16 @@
{
description = "Samw's Nix flake templates";
inputs = { utils.url = "github:numtide/flake-utils"; };
outputs = { self, utils, nixpkgs }:
{
templates = {
rust = {
path = ./rust;
description = "My preferred rust setup.";
};
};
} // utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
in { formatter = pkgs.nixfmt; });
}

1
rust/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

36
rust/flake.nix Normal file
View File

@ -0,0 +1,36 @@
{
description = "Another cool rust disaster from samw.";
inputs = {
utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
naersk.url = "github:nix-community/naersk";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, utils, naersk, devshell, rust-overlay }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
rust = rust-bin.stable.latest.default;
naersk-lib = naersk.lib.${system}.override {
cargo = rust;
rust = rust;
};
in {
defaultPackage = naersk-lib.buildPackage ./.;
defaultApp = utils.lib.mkApp { drv = self.defaultPackage."${system}"; };
# Provide a dev env with rust and rls
devShell = let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay (import rust-overlay) ];
};
in pkgs.devshell.mkShell {
packages = with pkgs; [ (rust.override { extensions = [ "rls" ]; }) ];
};
});
}