1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2025-03-16 13:28:20 +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

11
dev/flake.lock generated
View file

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

View file

@ -6,7 +6,7 @@
# As a consequence, this flake is a little non-standard, and # As a consequence, this flake is a little non-standard, and
# we can't use the `nix` CLI as expected. # 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.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs"; pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects"; 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 { rec {
f-p = builtins.getFlake (toString ../..); f-p = builtins.getFlake (toString ../..);
flake-parts = f-p; 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 { nixpkgsWithoutEasyOverlay = import nixpkgs {
system = "x86_64-linux"; system = "x86_64-linux";
overlays = [ ]; overlays = [ ];
@ -113,6 +144,10 @@ rec {
# - `hello_new` shows that the `final` wiring works # - `hello_new` shows that the `final` wiring works
assert nixpkgsWithEasyOverlay.hello_new == nixpkgsWithEasyOverlay.hello; assert nixpkgsWithEasyOverlay.hello_new == nixpkgsWithEasyOverlay.hello;
assert flakeModulesImport.test123 == "123test";
assert flakeModulesDisable.test123 == "option123";
ok; ok;
result = runTests "ok"; result = runTests "ok";

View file

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

6
flake.lock generated
View file

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

View file

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