diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1ef1fe13..4af6d6aa 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -922,6 +922,13 @@ in when activating your Home Manager configuration. ''; } + + { + time = "2018-12-28T12:32:30+00:00"; + message = '' + A new module is available: 'programs.opam'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 45ab16a3..45cb8d51 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -69,6 +69,7 @@ let (loadModule ./programs/notmuch.nix { }) (loadModule ./programs/obs-studio.nix { }) (loadModule ./programs/offlineimap.nix { }) + (loadModule ./programs/opam.nix { }) (loadModule ./programs/pidgin.nix { }) (loadModule ./programs/rofi.nix { }) (loadModule ./programs/ssh.nix { }) diff --git a/modules/programs/opam.nix b/modules/programs/opam.nix new file mode 100644 index 00000000..d62b50dd --- /dev/null +++ b/modules/programs/opam.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.opam; + +in + +{ + meta.maintainers = [ maintainers.marsam ]; + + options.programs.opam = { + enable = mkEnableOption "Opam"; + + package = mkOption { + type = types.package; + default = pkgs.opam; + defaultText = "pkgs.opam"; + description = "Opam package to install."; + }; + + enableBashIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Bash integration. + ''; + }; + + enableZshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Zsh integration. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + eval "$(${cfg.package}/bin/opam env --shell=bash)" + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${cfg.package}/bin/opam env --shell=zsh)" + ''; + }; +}