flake.nix: replace fenix with rust-overlay

This commit is contained in:
Oystein Kristoffer Tveit 2024-07-10 17:08:53 +02:00
parent 2b056942eb
commit e6e05df77e
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 33 additions and 45 deletions

View File

@ -1,26 +1,5 @@
{ {
"nodes": { "nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1713421495,
"narHash": "sha256-5vVF9W1tJT+WdfpWAEG76KywktKDAW/71mVmNHEHjac=",
"owner": "nix-community",
"repo": "fenix",
"rev": "fd47b1f9404fae02a4f38bd9f4b12bad7833c96b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1713297878, "lastModified": 1713297878,
@ -39,24 +18,27 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"fenix": "fenix", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs" "rust-overlay": "rust-overlay"
} }
}, },
"rust-analyzer-src": { "rust-overlay": {
"flake": false, "inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1713373173, "lastModified": 1720577957,
"narHash": "sha256-octd9BFY9G/Gbr4KfwK4itZp4Lx+qvJeRRcYnN+dEH8=", "narHash": "sha256-RZuzLdB/8FaXaSzEoWLg3au/mtbuH7MGn2LmXUKT62g=",
"owner": "rust-lang", "owner": "oxalica",
"repo": "rust-analyzer", "repo": "rust-overlay",
"rev": "46702ffc1a02a2ac153f1d1ce619ec917af8f3a6", "rev": "a434177dfcc53bf8f1f348a3c39bfb336d760286",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "rust-lang", "owner": "oxalica",
"ref": "nightly", "repo": "rust-overlay",
"repo": "rust-analyzer",
"type": "github" "type": "github"
} }
} }

View File

@ -1,37 +1,43 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs"; rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { self, nixpkgs, rust-overlay }@inputs:
outputs = { self, nixpkgs, fenix }@inputs:
let let
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
"x86_64-darwin"
"aarch64-darwin" "aarch64-darwin"
"armv7l-linux"
]; ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
toolchain = fenix.packages.${system}.complete;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [
(_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${system}; in fenix.overlays.default pkgs pkgs) (import rust-overlay)
]; ];
}; };
rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages;
toolchain = rust-bin.stable.latest.default;
in f system pkgs toolchain); in f system pkgs toolchain);
in { in {
devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell { devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell {
packages = [ nativeBuildInputs = [
(toolchain.withComponents [ toolchain
"cargo" "rustc" "rustfmt" "clippy"
])
pkgs.openssl
pkgs.pkg-config pkgs.pkg-config
]; ];
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
buildInputs = [
pkgs.openssl
];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
}); });
}; };
} }