2023-01-30 22:21:14 -05:00
|
|
|
{
|
|
|
|
description = "The Sieve of Eratosthenes implemented in many different languages";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils, ... }:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2023-02-07 14:24:32 -05:00
|
|
|
inherit (pkgs) lib;
|
2023-01-30 22:21:14 -05:00
|
|
|
|
2023-02-07 14:24:32 -05:00
|
|
|
# Check if project has a shell.nix
|
|
|
|
hasShell = dir: (builtins.readDir ./${dir}) ? "shell.nix";
|
|
|
|
|
|
|
|
# Get all project directories
|
2023-01-30 22:21:14 -05:00
|
|
|
currentDir = builtins.readDir ./.;
|
2023-02-07 14:55:16 -05:00
|
|
|
dirs = builtins.attrNames (lib.filterAttrs (_: v: v == "directory") currentDir);
|
2023-02-07 14:24:32 -05:00
|
|
|
in
|
2023-02-07 14:55:16 -05:00
|
|
|
builtins.foldl' lib.recursiveUpdate {} (builtins.map (dir: {
|
2023-02-07 14:24:32 -05:00
|
|
|
packages.${dir} = pkgs.callPackage ./${dir} {};
|
|
|
|
} // lib.optionalAttrs (hasShell dir) {
|
|
|
|
devShells.${dir} = pkgs.callPackage ./${dir}/shell.nix {};
|
2023-02-07 14:55:16 -05:00
|
|
|
}) dirs)
|
2023-02-07 14:24:32 -05:00
|
|
|
);
|
2023-01-30 22:21:14 -05:00
|
|
|
}
|