From 8fe87559a9040cba66cbacfc60f6f1b1fc84cf1c Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 1 Dec 2024 18:27:19 +0100 Subject: [PATCH] nixos/lib: Add disablePackageByName We do this in multiple DE modules and the behaviour was not consistent. --- nixos/lib/utils.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nixos/lib/utils.nix b/nixos/lib/utils.nix index 82bbfae0178b..a0518660a511 100644 --- a/nixos/lib/utils.nix +++ b/nixos/lib/utils.nix @@ -343,6 +343,25 @@ utils = rec { in filter (x: !(elem (getName x) namesToRemove)) packages; + /* Returns false if a package with the same name as the `package` is present in `packagesToDisable`. + + Type: + disablePackageByName :: package -> [package] -> bool + + Example: + disablePackageByName file-roller [ file-roller totem ] + => false + + Example: + disablePackageByName nautilus [ file-roller totem ] + => true + */ + disablePackageByName = package: packagesToDisable: + let + namesToDisable = map getName packagesToDisable; + in + !elem (getName package) namesToDisable; + systemdUtils = { lib = import ./systemd-lib.nix { inherit lib config pkgs utils; }; unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };