{ 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}; inherit (pkgs) lib; # Check if project has a shell.nix hasShell = dir: builtins.pathExists ./${dir}/shell.nix; # Get all project directories currentDir = builtins.readDir ./.; dirs = builtins.attrNames (lib.filterAttrs (_: v: v == "directory") currentDir); in builtins.foldl' lib.recursiveUpdate {} (builtins.map (dir: { packages.${dir} = pkgs.callPackage ./${dir} {}; } // lib.optionalAttrs (hasShell dir) { devShells.${dir} = pkgs.callPackage ./${dir}/shell.nix {}; }) dirs) ); }