1

rename options + use of lib.optionals

This commit is contained in:
2022-08-08 12:27:58 +02:00
parent eb658bc76c
commit f3c7954d29

View File

@ -38,19 +38,19 @@ in {
description = "Remove unused packages on nixos-rebuild"; description = "Remove unused packages on nixos-rebuild";
}; };
discord = mkOption { discord.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable Discord"; description = "Enable Discord";
}; };
spotify = mkOption { spotify.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable Spotify"; description = "Enable Spotify";
}; };
flatseal = mkOption { flatseal.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable Flatseal"; description = "Enable Flatseal";
@ -73,7 +73,7 @@ in {
# "${home.homeDirectory}/.local/share/flatpak/exports/share" # "${home.homeDirectory}/.local/share/flatpak/exports/share"
# ]; # ];
home.activation = (mkMerge [ home.activation = mkMerge [
(mkIf cfg.fontFix { (mkIf cfg.fontFix {
# We link like this to be able to address the absolute location, also the fonts won't get copied to store # We link like this to be able to address the absolute location, also the fonts won't get copied to store
# NOTE: This path contains all the fonts because fonts.fontDir.enable is true # NOTE: This path contains all the fonts because fonts.fontDir.enable is true
@ -94,36 +94,27 @@ in {
}) })
{ {
installFlatpak = installFlatpak = let
let to_install = builtins.concatLists [
# For some reason (mkIf ...) evaluates to a set { _type = "if"; condition = ... } so nothing can (optionals cfg.discord.enable [ "com.discordapp.Discord" ])
# be merged. I don't understand why the set isn't evaluated, it worked previously (optionals cfg.spotify.enable [ "com.spotify.Client" ])
to_install = (builtins.concatLists [ (optionals cfg.flatseal.enable [ "com.github.tchx84.Flatseal" ])
# (mkIf cfg.discord [ "com.discordapp.Discord" ]) ];
# (mkIf cfg.spotify [ "com.spotify.Client" ])
# (mkIf cfg.flatseal [ "com.github.tchx84.Flatseal" ])
(if cfg.discord then [ "com.discordapp.Discord" ] else [ ])
(if cfg.spotify then [ "com.spotify.Client" ] else [ ])
(if cfg.flatseal then [ "com.github.tchx84.Flatseal" ] else [ ])
# cfg.extraPackages
]);
to_install_str = (builtins.concatStringsSep " " to_install); to_install_str = builtins.concatStringsSep " " to_install;
in in
lib.hm.dag.entryAfter [ "writeBoundary" ] '' lib.hm.dag.entryAfter [ "writeBoundary" ] ''
sudo flatpak install -y ${to_install_str} sudo flatpak install -y ${to_install_str}
''; '';
# NOTE: This only removes named flatpaks, nothing from extraPackages removeFlatpak = let
removeFlatpak = to_remove = builtins.concatLists [
let (optionals (!cfg.discord.enable) [ "com.discordapp.Discord" ])
to_remove = (builtins.concatLists [ (optionals (!cfg.spotify.enable) [ "com.spotify.Client" ])
(if ! cfg.discord then [ "com.discordapp.Discord" ] else [ ]) (optionals (!cfg.flatseal.enable) [ "com.github.tchx84.Flatseal" ])
(if ! cfg.spotify then [ "com.spotify.Client" ] else [ ]) ];
(if ! cfg.flatseal then [ "com.github.tchx84.Flatseal" ] else [ ])
]);
to_remove_str = (builtins.concatStringsSep " " to_remove); to_remove_str = builtins.concatStringsSep " " to_remove;
in in
lib.hm.dag.entryAfter [ "writeBoundary" ] '' lib.hm.dag.entryAfter [ "writeBoundary" ] ''
sudo flatpak uninstall -y ${to_remove_str} sudo flatpak uninstall -y ${to_remove_str}
@ -141,7 +132,7 @@ in {
sudo flatpak uninstall --unused -y sudo flatpak uninstall --unused -y
''; '';
}) })
]); ];
# TODO: Add option for extra overrides and concatenate this string together # TODO: Add option for extra overrides and concatenate this string together
# Allow access to linked fonts/icons # Allow access to linked fonts/icons