1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

flakeModules: Support disabledModules

Requires Nixpkgs > 2023-03-09
This commit is contained in:
Robert Hensing 2023-01-26 20:40:11 +01:00
parent dc531e3a9c
commit f5b6209441
6 changed files with 46 additions and 11 deletions

View file

@ -236,16 +236,15 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1668145650,
"narHash": "sha256-RJsYVz7j6HhXQtcFQJz9bZsgwFG8MblmOt8A4iD1AlY=",
"owner": "hercules-ci",
"lastModified": 1678375184,
"narHash": "sha256-8Cb7fbWhbsd5uleegvkXeGUir9xbSFsW2COVSK4gIzA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b106ff14ede4034f8771025f8ac785144358f3cd",
"rev": "8009798849bc1e8d3540b0dd38e3a3260257bd88",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"ref": "options-markdown-and-errors",
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}

View file

@ -6,7 +6,7 @@
# As a consequence, this flake is a little non-standard, and
# we can't use the `nix` CLI as expected.
nixpkgs.url = "github:hercules-ci/nixpkgs/options-markdown-and-errors";
nixpkgs.url = "github:NixOS/nixpkgs";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";

View file

@ -1,3 +1,7 @@
# Run with
#
# nix build -f dev checks.x86_64-linux.eval-tests
rec {
f-p = builtins.getFlake (toString ../..);
flake-parts = f-p;
@ -48,6 +52,33 @@ rec {
};
};
flakeModulesDeclare = mkFlake
{ inputs.self = { outPath = ./.; }; }
({ config, ... }: {
imports = [ flake-parts.flakeModules.flakeModules ];
systems = [ ];
flake.flakeModules.default = { lib, ... }: {
options.flake.test123 = lib.mkOption { default = "option123"; };
imports = [ config.flake.flakeModules.extra ];
};
flake.flakeModules.extra = {
flake.test123 = "123test";
};
});
flakeModulesImport = mkFlake
{ inputs.self = { }; }
{
imports = [ flakeModulesDeclare.flakeModules.default ];
};
flakeModulesDisable = mkFlake
{ inputs.self = { }; }
{
imports = [ flakeModulesDeclare.flakeModules.default ];
disabledModules = [ flakeModulesDeclare.flakeModules.extra ];
};
nixpkgsWithoutEasyOverlay = import nixpkgs {
system = "x86_64-linux";
overlays = [ ];
@ -113,6 +144,10 @@ rec {
# - `hello_new` shows that the `final` wiring works
assert nixpkgsWithEasyOverlay.hello_new == nixpkgsWithEasyOverlay.hello;
assert flakeModulesImport.test123 == "123test";
assert flakeModulesDisable.test123 == "option123";
ok;
result = runTests "ok";

View file

@ -16,6 +16,7 @@ let
default = { };
apply = mapAttrs (k: v: {
_file = "${toString self.outPath}/flake.nix#flakeModules.${k}";
key = "${toString self.outPath}/flake.nix#flakeModules.${k}";
imports = [ v ];
});
description = ''

View file

@ -3,11 +3,11 @@
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1677407201,
"narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=",
"lastModified": 1678375444,
"narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505",
"rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e",
"type": "github"
},
"original": {

View file

@ -7,7 +7,6 @@
outputs = { self, nixpkgs-lib, ... }: {
lib = import ./lib.nix { inherit (nixpkgs-lib) lib; };
flakeModules.flakeModules = ./modules/flakeModules.nix;
templates = {
default = {
path = ./template/default;
@ -24,6 +23,7 @@
};
flakeModules = {
easyOverlay = ./extras/easyOverlay.nix;
flakeModules = ./extras/flakeModules.nix;
};
};