opam: add module

(cherry picked from commit 7afefcf75d)
This commit is contained in:
Mario Rodas 2018-12-28 07:00:00 -05:00 committed by Robert Helgesson
parent 82ed4dae2a
commit c67d2a916f
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 60 additions and 0 deletions

View file

@ -922,6 +922,13 @@ in
when activating your Home Manager configuration. when activating your Home Manager configuration.
''; '';
} }
{
time = "2018-12-28T12:32:30+00:00";
message = ''
A new module is available: 'programs.opam'.
'';
}
]; ];
}; };
} }

View file

@ -69,6 +69,7 @@ let
(loadModule ./programs/notmuch.nix { }) (loadModule ./programs/notmuch.nix { })
(loadModule ./programs/obs-studio.nix { }) (loadModule ./programs/obs-studio.nix { })
(loadModule ./programs/offlineimap.nix { }) (loadModule ./programs/offlineimap.nix { })
(loadModule ./programs/opam.nix { })
(loadModule ./programs/pidgin.nix { }) (loadModule ./programs/pidgin.nix { })
(loadModule ./programs/rofi.nix { }) (loadModule ./programs/rofi.nix { })
(loadModule ./programs/ssh.nix { }) (loadModule ./programs/ssh.nix { })

52
modules/programs/opam.nix Normal file
View file

@ -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)"
'';
};
}