fork/nix-index

git clone https://git.julia.blue/fork/nix-index

figsodaMerge pull request #219 from figsoda/dev70a0197

v0.1.7
2.8 KiB102 linesraw
1{
2  description = "A files database for nixpkgs";
3
4  inputs = {
5    nixpkgs.url = "nixpkgs/nixos-unstable";
6    flake-compat = {
7      url = "github:edolstra/flake-compat";
8      flake = false;
9    };
10  };
11
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
19    {
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;
33          };
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 ];
50          };
51        };
52      });
53
54      checks = forAllSystems (system: {
55        nix-index = self.packages.${system}.default;
56      });
57
58      devShells = forAllSystems (system: {
59        minimal = with nixpkgsFor.${system}; mkShell {
60          name = "nix-index";
61
62          nativeBuildInputs = [
63            pkg-config
64          ];
65
66          buildInputs = [
67            openssl
68            sqlite
69          ] ++ lib.optionals stdenv.isDarwin [
70            darwin.apple_sdk.frameworks.Security
71          ];
72
73          env.LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
74        };
75
76        default = with nixpkgsFor.${system}; mkShell {
77          name = "nix-index";
78
79          inputsFrom = [ self.devShells.${system}.minimal ];
80
81          nativeBuildInputs = [ rustc cargo clippy rustfmt ];
82
83          env = {
84            LD_LIBRARY_PATH = lib.makeLibraryPath [ openssl ];
85            RUST_SRC_PATH = rustPlatform.rustLibSrc;
86          };
87        };
88      });
89
90      apps = forAllSystems (system: {
91        nix-index = {
92          type = "app";
93          program = "${self.packages.${system}.default}/bin/nix-index";
94        };
95        nix-locate = {
96          type = "app";
97          program = "${self.packages.${system}.default}/bin/nix-locate";
98        };
99        default = self.apps.${system}.nix-locate;
100      });
101    };
102}