Skip to content

Commit 45bd031

Browse files
Use flake compat to provide the nix flakes dev shell to non flake users (#2926)
* Use flake compat to provide the nix flakes dev shell to non flake users * Move shell.nix to .nix sub folder
1 parent f184e4a commit 45bd031

File tree

4 files changed

+49
-85
lines changed

4 files changed

+49
-85
lines changed

.nix/flake.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.nix/flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
inputs.nixpkgs.follows = "nixpkgs";
2525
};
2626
flake-utils.url = "github:numtide/flake-utils";
27+
28+
# This is used to provide a identical development shell at `shell.nix` for users that do not use flakes
29+
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
2730
};
2831

2932
outputs = { nixpkgs, nixpkgs-unstable, rust-overlay, flake-utils, ... }:

.nix/shell.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is a helper file for people using NixOS as their operating system.
2+
# If you don't know what this file does, you can safely ignore it.
3+
4+
# If you are using Nix as your package manager, you can run 'nix-shell .nix'
5+
# in the root directory of the project and Nix will open a bash shell
6+
# with all the packages needed to build and run Graphite installed.
7+
# A shell.nix file is used in the Nix ecosystem to define a development
8+
# environment with specific dependencies. When you enter a Nix shell using
9+
# this file, it ensures that all the specified tools and libraries are
10+
# available regardless of the host system's configuration. This provides
11+
# a reproducible development environment across different machines and developers.
12+
13+
# You can enter the Nix shell and run Graphite like normal with:
14+
# > npm start
15+
# Or you can run it like this without needing to first enter the Nix shell:
16+
# > nix-shell .nix --command "npm start"
17+
18+
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
19+
(import
20+
(
21+
let
22+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
23+
nodeName = lock.nodes.root.inputs.flake-compat;
24+
in
25+
fetchTarball {
26+
url = lock.nodes.${nodeName}.locked.url;
27+
sha256 = lock.nodes.${nodeName}.locked.narHash;
28+
}
29+
)
30+
{ src = ./.; }
31+
).shellNix

shell.nix

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)