-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathflake.nix
105 lines (88 loc) · 3.02 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
description = "A files database for nixpkgs";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, flake-compat }:
let
inherit (nixpkgs) lib;
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
forAllSystems = lib.genAttrs systems;
nixpkgsFor = nixpkgs.legacyPackages;
in
{
packages = forAllSystems (system: {
default = with nixpkgsFor.${system}; rustPlatform.buildRustPackage {
pname = "nix-index";
inherit ((lib.importTOML ./Cargo.toml).package) version;
src = lib.sourceByRegex self [
"(examples|src)(/.*)?"
''Cargo\.(toml|lock)''
''command-not-found\.sh''
];
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl curl sqlite ]
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
postInstall = ''
substituteInPlace command-not-found.sh \
--subst-var out
install -Dm555 command-not-found.sh -t $out/etc/profile.d
'';
meta = with lib; {
description = "A files database for nixpkgs";
homepage = "https://github.com/nix-community/nix-index";
license = with licenses; [ bsd3 ];
maintainers = [ maintainers.bennofs ];
};
};
});
checks = forAllSystems (system:
let
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self.packages.${system};
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self.devShells.${system};
in packages // devShells
);
devShells = forAllSystems (system: {
minimal = with nixpkgsFor.${system}; mkShell {
name = "nix-index";
nativeBuildInputs = [
pkg-config
];
buildInputs = [
openssl
sqlite
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
env.LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
};
default = with nixpkgsFor.${system}; mkShell {
name = "nix-index";
inputsFrom = [ self.devShells.${system}.minimal ];
nativeBuildInputs = [ rustc cargo clippy rustfmt ];
env = {
LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
};
});
apps = forAllSystems (system: {
nix-index = {
type = "app";
program = "${self.packages.${system}.default}/bin/nix-index";
};
nix-locate = {
type = "app";
program = "${self.packages.${system}.default}/bin/nix-locate";
};
default = self.apps.${system}.nix-locate;
});
};
}