Skip to content

Commit 9560e59

Browse files
add shell.nix and nix-community's flake-compat
- `shell.nix` allows running the package with `nix-shell --run` - taking the version from `flake.lock` is more explicit and uniform
1 parent ddb3a25 commit 9560e59

File tree

5 files changed

+35
-22
lines changed

5 files changed

+35
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ nix-shell -p nix-index -I nixpkgs=channel:nixpkgs-unstable
4747

4848
### Latest Git version
4949

50-
To run the latest development version of nix-index:
50+
To run the latest development version:
5151

5252
```
5353
$ nix-shell https://github.com/nix-community/nix-index/tarball/master

default.nix

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat
2-
# See flake.nix for details
3-
(import (
4-
let
5-
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
6-
in fetchTarball {
7-
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
8-
sha256 = lock.nodes.flake-compat.locked.narHash; }
9-
) {
10-
src = ./.;
11-
}).defaultNix
1+
{ system ? builtins.currentSystem }:
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
5+
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
6+
7+
flake-compat = fetchTarball {
8+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
9+
sha256 = narHash;
10+
};
11+
12+
flake = import flake-compat { inherit system; src = ./.; };
13+
in
14+
flake.defaultNix

flake.lock

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

flake.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
inputs = {
55
nixpkgs.url = "nixpkgs/nixos-unstable";
6-
flake-compat = {
7-
url = "github:edolstra/flake-compat";
8-
flake = false;
9-
};
6+
flake-compat.url = "github:nix-community/flake-compat";
107
};
118

129
outputs = { self, nixpkgs, flake-compat }:

shell.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ system ? builtins.currentSystem }:
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
5+
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
6+
7+
flake-compat = fetchTarball {
8+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
9+
sha256 = narHash;
10+
};
11+
12+
flake = import flake-compat { inherit system; src = ./.; };
13+
in
14+
flake.shellNix

0 commit comments

Comments
 (0)