home-manager/suites/desktop: improve code

This commit is contained in:
Gabriel Arazas 2024-02-23 20:36:27 +08:00
parent 9e8b271b65
commit 6acc1507ba
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -3,6 +3,7 @@
let let
cfg = config.suites.desktop; cfg = config.suites.desktop;
nixosCfg = attrs.nixosConfig;
in in
{ {
options.suites.desktop = { options.suites.desktop = {
@ -13,7 +14,7 @@ in
enable = lib.mkEnableOption "installations of audio-related apps"; enable = lib.mkEnableOption "installations of audio-related apps";
pipewire.enable = lib.mkOption { pipewire.enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = attrs ? nixosConfig && lib.attrByPath [ "services" "pipewire" "enable" ] false attrs.nixosConfig; default = nixosCfg.services.pipewire.enable or false;
description = '' description = ''
Enable whether to install Pipewire-related applications. Enable whether to install Pipewire-related applications.
@ -43,7 +44,7 @@ in
] ]
++ ( ++ (
let let
hasBlenderNixOSModule = attrs ? nixosConfig && lib.attrByPath [ "programs" "blender" "enable" ] false attrs.nixosConfig; hasBlenderNixOSModule = nixosCfg.programs.blender.enable or false;
in in
lib.optional (!hasBlenderNixOSModule) pkgs.blender lib.optional (!hasBlenderNixOSModule) pkgs.blender
); );
@ -53,7 +54,7 @@ in
home.packages = with pkgs; [ home.packages = with pkgs; [
audacity # EGADS!!! audacity # EGADS!!!
musescore # You won't find muses to score, only music: a common misconception. musescore # You won't find muses to score, only music: a common misconception.
zrythm # The freer FL Studio (if you're sailing by the high seven seas). #zrythm # The freer FL Studio (if you're sailing by the high seven seas).
supercollider # Not to be confused with the other Super Collider. supercollider # Not to be confused with the other Super Collider.
sonic-pi # The only pie you'll get from this is worms which I heard is addicting. sonic-pi # The only pie you'll get from this is worms which I heard is addicting.
@ -61,9 +62,9 @@ in
] ]
++ ( ++ (
let let
hasWineProfile = attrs ? nixosConfig && lib.attrByPath [ "profiles" "desktop" "wine" "enable" ] false attrs.nixosConfig; hasDesktopSuiteEnabled = nixosCfg.suites.desktop.enable or false;
in in
lib.optionals hasWineProfile (with pkgs; [ lib.optionals hasDesktopSuiteEnabled (with pkgs; [
yabridge # Building bridges to Windows and Linux audio tools. yabridge # Building bridges to Windows and Linux audio tools.
yabridgectl # The bridge controller. yabridgectl # The bridge controller.
]) ])
@ -77,7 +78,7 @@ in
enable = true; enable = true;
soundService = soundService =
let let
hasNixOSPipewirePulseEnabled = attrs ? nixosConfig && lib.attrByPath [ "services" "pipewire" "pulse" "enable" ] false attrs.nixosConfig; hasNixOSPipewirePulseEnabled = attrs.nixosConfig.services.pipewire.enable or false;
in in
lib.mkIf hasNixOSPipewirePulseEnabled "pipewire-pulse"; lib.mkIf hasNixOSPipewirePulseEnabled "pipewire-pulse";
}; };