{ description = "Crane integration with flake-parts"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; parts.url = "github:hercules-ci/flake-parts"; fenix.url = "github:nix-community/fenix"; fenix.inputs.nixpkgs.follows = "nixpkgs"; fenix.inputs.rust-analyzer-src.follows = ""; crane.url = "github:ipetkov/crane"; crane.inputs.nixpkgs.follows = "nixpkgs"; rustManifest = { url = "https://static.rust-lang.org/dist/2023-02-02/channel-rust-nightly.toml"; flake = false; }; }; outputs = inputs: with builtins; with inputs.nixpkgs.lib; inputs.parts.lib.mkFlake { inherit inputs; } { flake.flakeModules = { crane = import ./crane.nix inputs.crane; fenix = import ./fenix.nix inputs.fenix; }; flake.flakeModule = { imports = attrValues inputs.self.flakeModules; }; systems = [ "x86_64-linux" ]; perSystem = { pkgs, system, ... }: { # checks.runExampleChecks = pkgs.stdenv.mkDerivation { # name = "run-example-checks"; # dontUnpack = true; # nestedChecks = # let # examplesDir = ./examples; # children = readDir examplesDir; # exampleDirs = filter (n: children.${n} == "directory") (attrNames children); # exampleChecks = concatMap # (d: # let # flakeDef = import "${examplesDir}/${d}/flake.nix"; # flakeInputs = inputs // { self = outputs; rust = inputs.self; }; # outputs = flakeDef // (flakeDef.outputs flakeInputs) // { _type = "flake"; inputs = flakeInputs; }; # in # attrValues (outputs.checks.${system} or { })) # exampleDirs; # in # map toString exampleChecks; # buildPhase = # '' # echo $nestedChecks # touch $out # ''; # }; checks = let examplesDir = ./. + "/examples"; children = readDir examplesDir; exampleDirs = filter (n: children.${n} == "directory") (attrNames children); exampleChecks = map (dir: let flakeDef = import "${examplesDir}/${dir}/flake.nix"; flakeInputs = inputs // { self = flakeOutputs; rust = inputs.self; }; flakeOutputs = flakeDef // (flakeDef.outputs flakeInputs) // { _type = "flake"; inputs = flakeInputs; }; in flakeOutputs.checks.${system} or { }) exampleDirs; in foldl' (sofar: next: sofar // next) { } exampleChecks; }; }; }