From 91e551aaf90d0050cca4ecfdcc459a390b9b4d88 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 18 Apr 2024 21:33:02 +0200 Subject: [PATCH] nix support --- flake.lock | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 +++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7609a89 --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "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=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1713373173, + "narHash": "sha256-octd9BFY9G/Gbr4KfwK4itZp4Lx+qvJeRRcYnN+dEH8=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "46702ffc1a02a2ac153f1d1ce619ec917af8f3a6", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9bb5cc9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + + outputs = { self, nixpkgs, fenix }@inputs: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + 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) + ]; + }; + 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/"; + }); + }; +}