{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; poetry2nix.url = "github:nix-community/poetry2nix"; poetry2nix.inputs.nixpkgs.follows = "nixpkgs"; poetry2nix.inputs.flake-utils.follows = "flake-utils"; wd2.url = "git+https://git.pleshevski.ru/pleshevskiy/wd2"; wd2.inputs.nixpkgs.follows = "nixpkgs"; wd2.inputs.flake-utils.follows = "flake-utils"; }; outputs = { nixpkgs, flake-utils, poetry2nix, ... } @ inputs: let inherit (builtins) listToAttrs mapAttrs; allPackageNames = [ "d2" "d2plugin-tala" "d2full" "wd2" "fawltydeps" ]; mkAllPackages = pkgs': let d2-unwrapped = pkgs'.callPackage ./pkgs/d2/d2-unwrapped.nix { }; d2plugin-tala = pkgs'.callPackage ./pkgs/d2/d2plugin-tala.nix { }; d2 = pkgs'.callPackage ./pkgs/d2 { inherit d2-unwrapped d2plugin-tala; }; fawltydeps = pkgs'.callPackage ./pkgs/fawltydeps { }; wd2 = pkgs'.callPackage "${inputs.wd2}/wd2.nix" { inherit d2; }; in { inherit d2 d2plugin-tala wd2 fawltydeps; d2-full = d2.override { withTala = true; }; }; mkApp = drv: flake-utils.lib.mkApp { inherit drv; }; mkOverlay = name: final: prev: final.filterAttrs (n: v: n == name) (mkAllPackages prev) // { poetry2nix = nixpkgs.legacyPackages.${final.system}.poetry2nix; }; in { overlays = (listToAttrs (map (name: { inherit name; value = mkOverlay name; }) allPackageNames ) ) // { all = final: prev: mkAllPackages prev // { poetry2nix = nixpkgs.legacyPackages.${final.system}.poetry2nix; }; }; } // flake-utils.lib.eachDefaultSystem (system: let overlays = [ poetry2nix.overlay ]; pkgs = import nixpkgs { inherit system overlays; }; packages = mkAllPackages pkgs; in { check = packages; inherit packages; apps = mapAttrs (name: mkApp) packages; }); }