1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2025-03-14 04:38:44 +00:00

Dogfooding via partitions

This commit is contained in:
Yang, Bo 2024-09-12 17:19:50 +00:00
parent ebe79a34bb
commit 0bbf4aa352
6 changed files with 50 additions and 52 deletions

View file

@ -44,6 +44,12 @@
- a check with runCommand
'';
};
dogfood = {
path = ./template/dogfood;
description = ''
A minimal flake using flake-parts creating flake modules to build its own outputs.
'';
};
};
flakeModules = {
easyOverlay = ./extras/easyOverlay.nix;
@ -65,12 +71,6 @@
flake = {
inherit lib templates flakeModules;
};
dogfood = {
path = ./template/dogfood;
description = ''
A minimal flake using flake-parts creating flake modules to build its own outputs.
'';
};
};
}

View file

@ -9,13 +9,23 @@
flake-parts.lib.mkFlake
{
inherit inputs;
moduleLocation = ./flake.nix;
}
{
({ config, lib, ... }: {
imports = [
./modules/anotherFlakeModule.nix
./modules/hello.nix
flake-parts.flakeModules.partitions
./modules/dev.nix
];
};
systems = [ "x86_64-linux" "aarch64-darwin" ];
partitionedAttrs.devShells = "dogfood";
partitionedAttrs.packages = "dogfood";
partitions.dogfood = {
module = {
imports = [
config.flake.flakeModules.dev
];
};
};
});
}

View file

@ -1,8 +0,0 @@
{inputs, ...}: {
imports = [
inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.anotherFlakeModule = {
# Define another flake module here
};
}

View file

@ -0,0 +1,19 @@
{ inputs, flake-parts-lib, ... }:
{
imports = [
inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.customHello = {
options.perSystem = flake-parts-lib.mkPerSystemOption ({ pkgs, system, ... }: {
packages.hello =
(inputs.nixpkgs_23_05.legacyPackages.${system}.hello.override {
stdenv = pkgs.gcc11Stdenv;
}).overrideAttrs (oldAttrs: {
meta = oldAttrs.meta // {
description = "A hello package from the `flakeModules.customHello` author's nixpkgs 23.05, built with gcc 11 from `flakeModules.customHello` user's nixpkgs";
};
});
});
};
}

View file

@ -1,28 +1,21 @@
{flake-parts-lib, lib, inputs, ...}@topLevel:
rec {
{ flake-parts-lib, inputs, ... }@topLevel:
{
imports = [
inputs.flake-parts.flakeModules.flakeModules
# Use file name to dogfood a flake module defined from the current flake to avoid infinite recursion
./hello.nix
{
flake.flakeModules.dev.imports = [
# Use attributes to reference the flake module from other flakes
topLevel.config.flake.flakeModules.hello
];
}
# Reference `flake.flakeModules.dev` via `rec` instead of `config` to avoid infinite recursion
flake.flakeModules.dev
# For `topLevel.config.flake.flakeModules.customHello`
./custom-hello.nix
];
flake.flakeModules.dev = {
config.systems = [ "x86_64-linux" "aarch64-darwin" ];
imports = [
# For `perSystem.config.packages.hello
topLevel.config.flake.flakeModules.customHello
];
options.perSystem = flake-parts-lib.mkPerSystemOption ({pkgs, ...}@perSystem: {
options.perSystem = flake-parts-lib.mkPerSystemOption ({ pkgs, ... }@perSystem: {
devShells.default = pkgs.mkShell {
buildInputs = [ perSystem.config.packages.hello_22_11 ];
buildInputs = [ perSystem.config.packages.hello ];
shellHook = ''
hello
'';

View file

@ -1,16 +0,0 @@
{inputs, flake-parts-lib, ...}:
rec {
imports = [
inputs.flake-parts.flakeModules.flakeModules
# Reference `flake.flakeModules.hello` via `rec` instead of `config` to avoid infinite recursion
flake.flakeModules.hello
];
flake.flakeModules.hello = {
options.perSystem = flake-parts-lib.mkPerSystemOption ({ system, ... }: {
packages.hello_22_11 =
inputs.nixpkgs_23_05.legacyPackages.${system}.hello;
});
};
}