Initial commit

This commit is contained in:
Sebastien Braun 2024-02-08 22:00:00 +00:00
commit e483f73dd4
12 changed files with 479 additions and 0 deletions

90
flake.nix Normal file
View file

@ -0,0 +1,90 @@
{
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;
};
};
}