summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Estep <sam@samestep.com>2025-03-20 11:40:57 -0400
committerGitHub <noreply@github.com>2025-03-20 23:40:57 +0800
commit9b1e10ea2602c76a97ca25c27a0b3842a5bb69de (patch)
treeea86679dca57d7fffe69a10f31ffc77d86f07d69
parentde6cc94e3b7fa5d1b8eeb53993dbf3ca2cec1cc1 (diff)
Add Nix flake for direnv (#6635)
* Add Nix flake for direnv * Use Sai's suggestion for the `description` * Make `.envrc` optional * Move Nix docs to their own section * Tweak wording * Tweak wording more * Add `nixfmt` --------- Co-authored-by: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
-rw-r--r--.gitignore2
-rw-r--r--docs/building.md14
-rw-r--r--flake.lock61
-rw-r--r--flake.nix33
4 files changed, 110 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index c6fa15457..79c3559b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,8 @@
*.zip
*.ini
*.DS_store
+.direnv
+.envrc
.gdb_history
.vimspector
.vimspector.json
diff --git a/docs/building.md b/docs/building.md
index 504e4e10c..6597c5199 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -311,6 +311,20 @@ cmake --preset vs2022 --fresh -A arm64 -DSLANG_GENERATORS_PATH=generators/bin
cmake --build --preset release
```
+### Nix
+
+This repository contains a [Nix](https://nixos.org/)
+[flake](https://wiki.nixos.org/wiki/Flakes) (not officially supported or
+tested), which provides the necessary prerequisites for local development. Also,
+if you use [direnv](https://direnv.net/), you can run the following commands to
+have the Nix environment automatically activate when you enter your clone of
+this repository:
+
+```bash
+echo 'use flake' >> .envrc
+direnv allow
+```
+
## Building with an older CMake
Because older CMake versions don't support all the features we want to use in
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 000000000..c3c585c60
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1742206328,
+ "narHash": "sha256-q+AQ///oMnyyFzzF4H9ShSRENt3Zsx37jTiRkLkXXE0=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "096478927c360bc18ea80c8274f013709cf7bdcd",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "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 000000000..211e5f107
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,33 @@
+{
+ description = "The Slang Shading Language and Compiler";
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+ outputs =
+ {
+ self,
+ nixpkgs,
+ flake-utils,
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ in
+ {
+ devShell =
+ with pkgs;
+ mkShell {
+ buildInputs = [
+ cmake
+ llvm
+ ninja
+ nixfmt-rfc-style
+ python3
+ xorg.libX11
+ ];
+ };
+ }
+ );
+}