summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 9421eed2bc9fb74f5f1e5ab6b9ab28bae239bc5b (plain)
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
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, ... }@inputs:
    inputs.flake-utils.lib.eachDefaultSystem
      (system:
        let
          pkgs = nixpkgs.legacyPackages.${system};
          subpackages = pkgs.lib.filterAttrs (nm: _: builtins.pathExists ./${nm}/packages.nix) (builtins.readDir ./.);
          lcq = builtins.mapAttrs (nm: _: (import ./${nm}/packages.nix) pkgs lcq) subpackages;
          defaultShell = {
            nativeBuildInputs = [
              pkgs.musl
              pkgs.valgrind
              pkgs.universal-ctags
            ];
            buildInputs = [];
          };
          shells = builtins.mapAttrs (nm: d: pkgs.mkShell {
            hardeningDisable = ["all"];
            NIX_ENFORCE_NO_NATIVE = "0";
            nativeBuildInputs = defaultShell.nativeBuildInputs ++ d.native.nativeBuildInputs;
            buildInputs = defaultShell.buildInputs ++ d.native.buildInputs;
          }) lcq;
        in {
          isPackage = p: (builtins.readDir ./${p}) ? "packages.nix";
          packages = lcq;
          devShells = {
            default = pkgs.mkShell {
              hardeningDisable = ["all"];
              NIX_ENFORCE_NO_NATIVE = "0";
              inherit (defaultShell) nativeBuildInputs buildInputs;
            };
          } // shells;
        }
      );
}