From 30de3115f85b2ead0e0b770d2bf132ad6df15f00 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 4 Aug 2024 02:20:02 +0200 Subject: [PATCH 1/2] flake.nix: replace fenix with rust-overlay --- flake.lock | 54 ++++++++++++++++++------------------------------------ flake.nix | 37 +++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/flake.lock b/flake.lock index 7609a89..abb57d9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,33 +1,12 @@ { "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": { "locked": { - "lastModified": 1713248628, - "narHash": "sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U+ISA=", + "lastModified": 1722421184, + "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8", + "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", "type": "github" }, "original": { @@ -39,24 +18,27 @@ }, "root": { "inputs": { - "fenix": "fenix", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" } }, - "rust-analyzer-src": { - "flake": false, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1713373173, - "narHash": "sha256-octd9BFY9G/Gbr4KfwK4itZp4Lx+qvJeRRcYnN+dEH8=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "46702ffc1a02a2ac153f1d1ce619ec917af8f3a6", + "lastModified": 1722651535, + "narHash": "sha256-2uRmNwxe3CO5h7PfvqXrRe8OplXaEdwhqOUtaF13rpU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "56d83ca6f3c557647476f3720426a7615c22b860", "type": "github" }, "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } } diff --git a/flake.nix b/flake.nix index 9bb5cc9..5207955 100644 --- a/flake.nix +++ b/flake.nix @@ -1,36 +1,41 @@ { inputs = { 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, fenix }@inputs: - let + outputs = { self, nixpkgs, rust-overlay }: + let systems = [ "x86_64-linux" "aarch64-linux" + "x86_64-darwin" "aarch64-darwin" + "armv7l-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let - toolchain = fenix.packages.${system}.complete; pkgs = import nixpkgs { inherit system; 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 { - devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell { - packages = [ - (toolchain.withComponents [ - "cargo" "rustc" "rustfmt" "clippy" - ]) - pkgs.mpv - ]; - RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/"; + devShells = forAllSystems (system: pkgs: toolchain: { + default = pkgs.mkShell { + nativeBuildInputs = [ + toolchain + pkgs.mpv + ]; + + RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; + }; }); }; -} +} \ No newline at end of file -- 2.47.0 From 03dd0eb9afacc8e330987aa65ccf8b1bed7015ef Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 4 Aug 2024 02:20:46 +0200 Subject: [PATCH 2/2] .envrc: init --- .envrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file -- 2.47.0