From 03177b00df8d6d18d92640eb7010ba0d3281277c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Jan 2023 09:37:23 -0800 Subject: [PATCH] Add a shell.nix --- .envrc | 5 +++++ flake.lock | 17 +++++++++++++++++ flake.nix | 16 ++++++++++++++++ shell.nix | 12 ++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..24e67d2 --- /dev/null +++ b/.envrc @@ -0,0 +1,5 @@ +# If we are a computer with nix-shell available, then use that to setup +# the build environment with exactly what we need. +if has nix; then + use nix +fi diff --git a/flake.lock b/flake.lock index 5497768..006ebbc 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1659877975, @@ -33,6 +49,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 466e26a..5f44f27 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,12 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + + # Used for shell.nix + flake-compat = { + url = github:edolstra/flake-compat; + flake = false; + }; }; outputs = { @@ -32,6 +38,16 @@ # nix fmt formatter = pkgs.alejandra; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + curl + jq + ]; + }; + + # For compatibility with older versions of the `nix` binary + devShell = self.devShells.${system}.default; }); in outputs diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..a15057a --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +(import + ( + let + flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat; + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz"; + sha256 = flake-compat.locked.narHash; + } + ) + {src = ./.;}) +.shellNix