{ lib, config, ... }: let inherit (lib) mkEnableOption mkDefault mkOption types; cfg = config.valhalla; mkUsersOption = programs: osConfig: mkOption { type = types.attrsOf (types.submodule ( { ... }: { options = { inherit programs; }; config = { programs = builtins.mapAttrs ( name: config: { enable = mkDefault config.enable; } ) osConfig.programs; }; } )); }; mkPrograms = infos: builtins.foldl' (programs: info: programs // { ${builtins.elemAt info 0} = { enable = mkEnableOption (builtins.elemAt info 1); }; }) { } infos; programs = mkPrograms [ [ "aliae" "aliae" ] [ "brave" "Brave Browser" ] [ "discord" "Discord" ] [ "firefox" "Firefox Web Browser" ] [ "openssh" "OpenSSH" ] [ "osu!lazer" "osu!lazer" ] [ "pennywise" "Pennywise" ] [ "powershell" "PowerShell Core" ] [ "retroarch" "RetroArch" ] [ "steam" "Steam" ] [ "thunderbird" "Thunderbird" ] [ "vscode" "Visual Studio Code" ] [ "zoxide" "zoxide" ] ]; linuxPrograms = mkPrograms [ [ "bash" "Bash" ] [ "fish" "fish" ] [ "icedtea" "IcedTea" ] [ "grub" "GRUB" ] [ "logo-ls" "logo-ls" ] [ "lutris" "Lutris" ] [ "minegrub-theme" "Minegrub Theme" ] [ "nginx" "nginx" ] [ "nodejs-n" "n" ] [ "nuke-usb" "nuke-usb" ] [ "nvidia-dkms" "Nvidia Drivers" ] [ "plasma" "Plasma" ] [ "pyenv" "pyenv" ] [ "sddm" "SDDM" ] [ "vim" "Vim" ] [ "virt-manager" "Virtual Machine Manager" ] [ "waydroid" "Waydroid" ] [ "xone" "xone" ] ]; windowsPrograms = mkPrograms [ [ "lghub" "Logitech G Hub" ] [ "maniaplanet" "ManiaPlanet" ] [ "msedge-redirect" "MSEdgeRedirect" ] [ "nvs" "Node Version Switcher" ] [ "osu!" "Osu!" ] [ "posh-git" "posh-git" ] [ "putty" "PuTTY" ] [ "rewasd" "reWASD" ] [ "terminal-icons" "Terminal Icons" ] [ "tm-nations-forever" "TrackMania Nations Forever" ] [ "tm-united-forever" "TrackMania United Forever" ] [ "tobii-gamehub" "Tobii Game Hub" ] [ "tobii-ghost" "Tobii Ghost" ] [ "ubiquiti-unifi-controller" "Ubiquiti UniFi Controller" ] [ "visualstudio" "Visual Studio" ] [ "winscp" "WinSCP" ] ]; in { imports = [ ./programs/docker.nix ./programs/git.nix ./programs/nextcloud.nix ./programs/oh-my-posh.nix ./programs/rclone.nix ]; options = { valhalla = { users = mkUsersOption programs cfg; linux.users = mkUsersOption linuxPrograms cfg.linux; windows.users = mkUsersOption windowsPrograms cfg.windows; inherit programs; linux.programs = linuxPrograms; windows.programs = windowsPrograms; }; }; }