From fcd8050007dabcc7f17a31407882d90f3c10a9c2 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:21:09 +0100 Subject: [PATCH] treewide: disable programs.nix-index.enable option by default Disable the programs.nix-index.enable option by default to align with Nix conventions and streamline configuration sharing. This avoids needing to remember to disable this module across all configurations and avoids highly discouraged conditional imports that often lead to infinite recursions [1]. BREAKING CHANGE: The programs.nix-index.enable option is disabled by default, meaning that this module has no effect unless the following is declared: programs.nix-index.enable = true; [1]: https://discourse.nixos.org/t/conditional-module-imports/34863/2 Link: https://github.com/nix-community/nix-index-database/pull/132 --- README.md | 33 +++++++++++++++++++++++++++------ nix/shared.nix | 2 -- tests.nix | 6 +++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8d3b8485..63e9a526 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,15 @@ Include the nixos module in your configuration: modules = [ ./configuration.nix nix-index-database.nixosModules.nix-index - # optional to also wrap and install comma - # { programs.nix-index-database.comma.enable = true; } + + { + programs = { + # Optionally wrap and install pkgs.comma. + nix-index-database.comma.enable = true; + + nix-index.enable = true; + }; + } ]; }; }; @@ -73,8 +80,15 @@ You can then call `nix-locate` as usual, it will automatically use the database modules = [ ./configuration.nix nix-index-database.darwinModules.nix-index - # optional to also wrap and install comma - # { programs.nix-index-database.comma.enable = true; } + + { + programs = { + # Optionally wrap and install pkgs.comma. + nix-index-database.comma.enable = true; + + nix-index.enable = true; + }; + } ]; }; }; @@ -114,8 +128,15 @@ You can then call `nix-locate` as usual, it will automatically use the database modules = [ nix-index-database.hmModules.nix-index - # optional to also wrap and install comma - # { programs.nix-index-database.comma.enable = true; } + + { + programs = { + # Optionally wrap and install pkgs.comma. + nix-index-database.comma.enable = true; + + nix-index.enable = true; + }; + } ]; }; }; diff --git a/nix/shared.nix b/nix/shared.nix index 7c45580a..3daecd6b 100644 --- a/nix/shared.nix +++ b/nix/shared.nix @@ -2,6 +2,4 @@ options = { programs.nix-index-database.comma.enable = lib.mkEnableOption "wrapping comma with nix-index-database and put it in the PATH"; }; - - config.programs.nix-index.enable = lib.mkDefault true; } diff --git a/tests.nix b/tests.nix index b42fc06d..673baddf 100644 --- a/tests.nix +++ b/tests.nix @@ -17,7 +17,11 @@ { programs.command-not-found.enable = false; - programs.nix-index-database.comma.enable = true; + programs = { + nix-index-database.comma.enable = true; + nix-index.enable = true; + }; + # Point comma at our nixpkgs instance. # Passing --nixpkgs-flake instead seems to fail when nix tries to use the network. nix.nixPath = [ "nixpkgs=${nixpkgs}" ];