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:
parent
ebe79a34bb
commit
0bbf4aa352
6 changed files with 50 additions and 52 deletions
12
flake.nix
12
flake.nix
|
@ -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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
{inputs, ...}: {
|
||||
imports = [
|
||||
inputs.flake-parts.flakeModules.flakeModules
|
||||
];
|
||||
flake.flakeModules.anotherFlakeModule = {
|
||||
# Define another flake module here
|
||||
};
|
||||
}
|
19
template/dogfood/modules/custom-hello.nix
Normal file
19
template/dogfood/modules/custom-hello.nix
Normal 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";
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
|
@ -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
|
||||
'';
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue