🔨 add fenix for rust toolchain + nix

This commit is contained in:
James Walker 2022-12-08 18:08:45 -05:00
parent 1468631245
commit e47b088f90
Signed by: walkah
GPG Key ID: 3C127179D6086E93
2 changed files with 104 additions and 46 deletions

View File

@ -1,8 +1,46 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1670480689,
"narHash": "sha256-DADoR6R7DpnQaZjuUr6Z5EeNxr9ClP6u3Oqf7PpS9yA=",
"owner": "nix-community",
"repo": "fenix",
"rev": "e7941faba7f6cd0a6058330ad8c40d8dc52d741c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1662220400,
@ -20,25 +58,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1669597967,
"narHash": "sha256-R+2NaDkXsYkOpFOhmVR8jBZ77Pq55Z6ilaqwFLLn000=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "be9e3762e719211368d186f547f847737baad720",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1669909918,
"narHash": "sha256-oPW5SoN/5Wd2kGj/djK4WjDn8vleZu+k3RdtDauE64M=",
"lastModified": 1670531464,
"narHash": "sha256-+tqcl3GRfO/z8lAQJiC+TSxYmW2qKhTRgxL6S3+D68U=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0b819d1aafef96f494c14f9a0bb22d0e3132926f",
"rev": "1e66c9ebcb4176bc38782ad33069ca4fb4a32bff",
"type": "github"
},
"original": {
@ -50,23 +74,26 @@
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
"nixpkgs": "nixpkgs"
}
},
"utils": {
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"lastModified": 1670426523,
"narHash": "sha256-Zh+pAuj4PmBmISXCz+54yVSwSXZwbn+ZELgM85xVUE0=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "6e8a54d0f68702cf7981c8299357838eb0f4d5b2",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}

View File

@ -3,34 +3,65 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-22.11";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, utils, naersk }:
utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-utils, fenix, naersk }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
naersk-lib = naersk.lib."${system}";
in
rec {
# `nix build`
packages.marvin = naersk-lib.buildPackage {
pname = "marvin";
root = ./.;
};
packages.default = packages.marvin;
# `nix run`
apps.marvin = utils.lib.mkApp {
drv = packages.marvin;
mkToolchain = fenix.packages.${system}.combine;
toolchain = fenix.packages.${system}.stable;
buildToolchain = mkToolchain (with toolchain; [
cargo
rustc
]);
devToolchain = mkToolchain (with toolchain; [
cargo
clippy
rust-src
rustc
rust-analyzer
# Always use nightly rustfmt because most of its options are unstable
fenix.packages.${system}.latest.rustfmt
]);
in
{
packages.default = (pkgs.callPackage naersk {
cargo = buildToolchain;
rustc = buildToolchain;
}).buildPackage {
src = ./.;
};
apps.default = apps.marvin;
# `nix develop`
devShells.default = pkgs.mkShell {
name = "marvin";
nativeBuildInputs = with pkgs; [ libiconv rustup rust-analyzer ];
RUST_SRC_PATH = "${devToolchain}/lib/rustlib/src/rust/library";
nativeBuildInputs = [ devToolchain pkgs.nixpkgs-fmt pkgs.libiconv ];
};
checks = {
packagesDefault = self.packages.${system}.default;
devShellsDefault = self.devShells.${system}.default;
};
});
}