Skip to content

Commit 6f88ef1

Browse files
nix-env -> nix-shell
- don't recommend `nix-env` any more - add `shell.nix` to allow running the program with `nix-shell --run` - move build instructions to separate files
1 parent 03b8617 commit 6f88ef1

File tree

6 files changed

+199
-120
lines changed

6 files changed

+199
-120
lines changed

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,36 @@ camlistore.out 7,938,952 x /nix/store/xn5ivjdyslx
2929
$ nix run github:nix-community/nix-index#nix-locate -- bin/hello
3030
```
3131

32+
### From Nixpkgs
33+
34+
From your locally configured version Nixpkgs:
35+
36+
```
37+
$ nix-shell -p nix-index
38+
[nix-shell]$ nix-index
39+
[nix-shell]$ nix-locate bin/hello
40+
```
41+
42+
From the latest rolling release of Nixpkgs:
43+
44+
```
45+
$ nix-shell -p nix-index -I nixpkgs=channel:nixpkgs-unstable
46+
```
47+
3248
### Latest Git version
3349

34-
To install the latest development version of nix-index, simply clone the repo and run `nix-env -if.`:
50+
To run the latest development version:
3551

3652
```
37-
$ git clone https://github.com/nix-community/nix-index
38-
$ cd nix-index
39-
$ nix-env -if.
53+
$ nix-shell https://github.com/nix-community/nix-index/tarball/master
4054
```
4155

42-
### Stable
56+
### Stable releases
4357

44-
For the stable version, you can either [checkout](https://git-scm.com/docs/git-checkout) the latest [tag](https://git-scm.com/docs/git-tag) (see the list [here](https://github.com/nix-community/nix-index/tags)) or use Nixpkgs' repositories' and install it with:
58+
To get a specific stable release, use one of the [release tags](https://github.com/nix-community/nix-index/tags):
4559

4660
```
47-
$ nix-env -iA nixos.nix-index
61+
$ nix-shell https://github.com/nix-community/nix-index/tarball/v0.1.8
4862
```
4963

5064
## Usage

default.nix

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,73 @@
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+
{
2+
system ? builtins.currentSystem,
3+
inputs ? import (fetchTarball "https://github.com/fricklerhandwerk/flake-inputs/tarball/1.0") {
4+
root = ./.;
5+
},
6+
nixpkgs-config ? {
7+
inherit system;
8+
config = { };
9+
overlays = [ ];
10+
},
11+
}:
12+
let
13+
# avoid re-importing `nixpkgs` if it comes from `flake.nix`
14+
pkgs =
15+
if inputs.nixpkgs ? lib then
16+
inputs.nixpkgs.legacyPackages.${system}
17+
else
18+
import inputs.nixpkgs nixpkgs-config;
19+
in
20+
rec {
21+
packages = {
22+
default = pkgs.callPackage ./package.nix { };
23+
};
24+
devShells = {
25+
minimal =
26+
with pkgs;
27+
mkShell {
28+
name = "nix-index";
29+
30+
nativeBuildInputs = [
31+
pkg-config
32+
];
33+
34+
buildInputs =
35+
[
36+
openssl
37+
sqlite
38+
]
39+
++ lib.optionals stdenv.isDarwin [
40+
darwin.apple_sdk.frameworks.Security
41+
];
42+
43+
env.LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
44+
};
45+
46+
default =
47+
with pkgs;
48+
mkShell {
49+
name = "nix-index";
50+
51+
inputsFrom = [ devShells.minimal ];
52+
53+
nativeBuildInputs = [
54+
rustc
55+
cargo
56+
clippy
57+
rustfmt
58+
];
59+
60+
env = {
61+
LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
62+
RUST_SRC_PATH = rustPlatform.rustLibSrc;
63+
};
64+
};
65+
66+
};
67+
app-shell =
68+
with pkgs;
69+
mkShellNoCC {
70+
name = "nix-index";
71+
packages = [ packages.default ];
72+
};
73+
}

flake.lock

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

flake.nix

Lines changed: 30 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,44 @@
33

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

12-
outputs = { self, nixpkgs, flake-compat }:
13-
let
14-
inherit (nixpkgs) lib;
15-
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
16-
forAllSystems = lib.genAttrs systems;
17-
nixpkgsFor = nixpkgs.legacyPackages;
18-
in
9+
outputs =
1910
{
20-
packages = forAllSystems (system: {
21-
default = with nixpkgsFor.${system}; rustPlatform.buildRustPackage {
22-
pname = "nix-index";
23-
inherit ((lib.importTOML ./Cargo.toml).package) version;
24-
25-
src = lib.sourceByRegex self [
26-
"(examples|src)(/.*)?"
27-
''Cargo\.(toml|lock)''
28-
''command-not-found\.sh''
29-
];
30-
31-
cargoLock = {
32-
lockFile = ./Cargo.lock;
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
...
15+
}@inputs:
16+
flake-utils.lib.eachDefaultSystem (
17+
system:
18+
let
19+
inherit (nixpkgs) lib;
20+
classic = import ./. { inherit system inputs; };
21+
in
22+
{
23+
24+
inherit (classic) packages devShells;
25+
26+
apps = {
27+
nix-index = {
28+
type = "app";
29+
program = "${self.packages.${system}.default}/bin/nix-index";
3330
};
34-
35-
nativeBuildInputs = [ pkg-config ];
36-
buildInputs = [ openssl curl sqlite ]
37-
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
38-
39-
postInstall = ''
40-
substituteInPlace command-not-found.sh \
41-
--subst-var out
42-
install -Dm555 command-not-found.sh -t $out/etc/profile.d
43-
'';
44-
45-
meta = with lib; {
46-
description = "A files database for nixpkgs";
47-
homepage = "https://github.com/nix-community/nix-index";
48-
license = with licenses; [ bsd3 ];
49-
maintainers = [ maintainers.bennofs ];
31+
nix-locate = {
32+
type = "app";
33+
program = "${self.packages.${system}.default}/bin/nix-locate";
5034
};
35+
default = self.apps.${system}.nix-locate;
5136
};
52-
});
5337

54-
checks = forAllSystems (system:
38+
checks =
5539
let
5640
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self.packages.${system};
5741
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self.devShells.${system};
58-
in packages // devShells
59-
);
60-
61-
devShells = forAllSystems (system: {
62-
minimal = with nixpkgsFor.${system}; mkShell {
63-
name = "nix-index";
64-
65-
nativeBuildInputs = [
66-
pkg-config
67-
];
68-
69-
buildInputs = [
70-
openssl
71-
sqlite
72-
] ++ lib.optionals stdenv.isDarwin [
73-
darwin.apple_sdk.frameworks.Security
74-
];
75-
76-
env.LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
77-
};
78-
79-
default = with nixpkgsFor.${system}; mkShell {
80-
name = "nix-index";
81-
82-
inputsFrom = [ self.devShells.${system}.minimal ];
83-
84-
nativeBuildInputs = [ rustc cargo clippy rustfmt ];
85-
86-
env = {
87-
LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
88-
RUST_SRC_PATH = rustPlatform.rustLibSrc;
89-
};
90-
};
91-
});
92-
93-
apps = forAllSystems (system: {
94-
nix-index = {
95-
type = "app";
96-
program = "${self.packages.${system}.default}/bin/nix-index";
97-
};
98-
nix-locate = {
99-
type = "app";
100-
program = "${self.packages.${system}.default}/bin/nix-locate";
101-
};
102-
default = self.apps.${system}.nix-locate;
103-
});
104-
};
42+
in
43+
packages // devShells;
44+
}
45+
);
10546
}

package.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
lib,
3+
curl,
4+
darwin,
5+
openssl,
6+
pkg-config,
7+
rustPlatform,
8+
sqlite,
9+
stdenv,
10+
}:
11+
rustPlatform.buildRustPackage {
12+
pname = "nix-index";
13+
inherit ((lib.importTOML ./Cargo.toml).package) version;
14+
15+
src = lib.sourceByRegex ./. [
16+
"(examples|src)(/.*)?"
17+
''Cargo\.(toml|lock)''
18+
''command-not-found\.sh''
19+
];
20+
21+
cargoLock = {
22+
lockFile = ./Cargo.lock;
23+
};
24+
25+
nativeBuildInputs = [ pkg-config ];
26+
buildInputs = [
27+
openssl
28+
curl
29+
sqlite
30+
] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
31+
32+
postInstall = ''
33+
substituteInPlace command-not-found.sh \
34+
--subst-var out
35+
install -Dm555 command-not-found.sh -t $out/etc/profile.d
36+
'';
37+
38+
meta = with lib; {
39+
description = "A files database for nixpkgs";
40+
homepage = "https://github.com/nix-community/nix-index";
41+
license = with licenses; [ bsd3 ];
42+
maintainers = [ maintainers.bennofs ];
43+
};
44+
}

shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(import ./. { }).app-shell

0 commit comments

Comments
 (0)