From 66dacde4f7a4945eb98d5f1ccb158247961034da Mon Sep 17 00:00:00 2001 From: Xenira <1288524+Xenira@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:10:17 +0200 Subject: [PATCH] build(nix): add dev environment flake Basic flake to enable development under nixos. Not really flushed out, but in a good enough state to add it. Probably needs improvement in the future. Refs: #409 --- .envrc | 1 + .gitignore | 3 ++- flake.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..3550a30f2d --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 89e3a707f6..7010525748 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ Cargo.lock /.vscode /.idea /tmp -expand.rs \ No newline at end of file +/.direnv +expand.rs diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..d9dc302dc8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1749794982, + "narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ee930f9755f58096ac6e8ca94a1887e0534e2d81", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1749955444, + "narHash": "sha256-CllTHvHX8KAdAZ+Lxzd23AmZTxO1Pfy+zC43/5tYkAE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "539ba15741f0e6691a2448743dbc601d8910edce", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..1950ce5a61 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "ext-php-rs dev environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = + { nixpkgs, rust-overlay, ... }: + let + system = "x86_64-linux"; + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + php-dev = pkgs.php.unwrapped.dev; + in + { + devShells.${system} = { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + php + php-dev + libclang.lib + clang + ]; + + nativeBuildInputs = [ pkgs.rust-bin.stable.latest.default ]; + + shellHook = '' + export LIBCLANG_PATH="''$LIBCLANG_PATH ${pkgs.libclang.lib}/lib" + ''; + }; + }; + }; +}