From 4319a48063f916761d240db7334cf3ed2ca93ede Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Thu, 3 Oct 2024 23:21:53 +0200 Subject: [PATCH] Add flake configuration --- flake.lock | 82 +++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 58 ++++++++++++++++++++++++++++++++ rust-toolchain.toml | 2 ++ 3 files changed, 142 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 rust-toolchain.toml diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e405cd7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1727937504, + "narHash": "sha256-LArYFBmjtUeoCyrVM5volpdqeRczRnYH20AZaeTMD+o=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2497fcbfa209055362f1029dcbd6bf9c928e937b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727922550, + "narHash": "sha256-pJoN5Qd83coaoEJmpkxw+cuh89IJORvLm8qyw3GMLIQ=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "5e3eee4bc42a2504653bedfe95bceda9a1e85ae7", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b0e5f96 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "DRM test rust configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + + rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform { + rustc = rust; + cargo = rust; + }); + + libs = with pkgs; [ ] + ++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isDarwin [ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ]; + in + { + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + (rust.override { extensions = ["rust-src" "rust-analyzer"]; }) + pkg-config + ]; + + buildInputs = libs; + }; + }; + + packages = { + default = rustPlatform.buildRustPackage { + pname = "drm_test"; + version = "0.1.0"; + + src = ./.; + + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = libs; + + cargoLock = { + lockFile = ./Cargo.lock; + }; + }; + }; + }); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..1de01fa --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.81.0"