1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-27 18:31:18 +00:00

Merge pull request #1331 from isabelroses/tools

feat: system tools can be configured individually
This commit is contained in:
Michael Hoang 2025-03-19 17:35:36 +09:00 committed by GitHub
commit 2d9b633169
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 22 deletions

View file

@ -9,39 +9,44 @@ let
darwin-uninstaller = pkgs.callPackage ../../pkgs/darwin-uninstaller { };
inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
mkToolModule = { name, package ? nix-tools.${name} }: { config, ... }: {
options.system.tools.${name}.enable = lib.mkEnableOption "${name} script" // {
default = config.system.tools.enable;
};
config = lib.mkIf config.system.tools.${name}.enable {
environment.systemPackages = [ package ];
};
};
in
{
options.system = {
disableInstallerTools = lib.mkOption {
type = lib.types.bool;
internal = true;
default = false;
description = ''
Disable darwin-rebuild and darwin-option. This is useful to shrink
systems which are not expected to rebuild or reconfigure themselves.
Use at your own risk!
'';
};
includeUninstaller = lib.mkOption {
tools.enable = lib.mkOption {
type = lib.types.bool;
internal = true;
default = true;
description = ''
Disable internal tools, such as darwin-rebuild and darwin-option. This
is useful to shrink systems which are not expected to rebuild or
reconfigure themselves. Use at your own risk!
'';
};
};
config = {
environment.systemPackages =
[ darwin-version ]
++ lib.optionals (!config.system.disableInstallerTools) [
darwin-option
darwin-rebuild
] ++ lib.optional config.system.includeUninstaller darwin-uninstaller;
imports = [
(lib.mkRenamedOptionModule [ "system" "includeUninstaller" ] [ "system" "tools" "darwin-uninstaller" "enable" ])
(lib.mkRemovedOptionModule [ "system" "disableInstallerTools" ] "Please use system.tools.enable instead")
(mkToolModule { name = "darwin-option"; })
(mkToolModule { name = "darwin-rebuild"; })
(mkToolModule { name = "darwin-version"; })
(mkToolModule { name = "darwin-uninstaller"; package = darwin-uninstaller; })
];
config = {
system.build = {
inherit darwin-option darwin-rebuild darwin-version;
inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
};
};
}

View file

@ -8,7 +8,7 @@ let
{
nixpkgs.source = path;
nixpkgs.hostPlatform = stdenv.hostPlatform.system;
system.includeUninstaller = false;
system.tools.darwin-uninstaller.enable = false;
}
];
};