fork/home-manager
git clone https://git.julia.blue/fork/home-manager
19c6a408
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . emacs ; 8 9# Copied from all-packages.nix, with modifications to support 10# overrides. 11emacsPackages = let epkgs = pkgs . emacsPackagesFor cfg . package ; 12in epkgs . overrideScope' cfg . overrides ; 13 14emacsWithPackages = emacsPackages . emacsWithPackages ; 15 16extraPackages = epkgs : 17let 18packages = cfg . extraPackages epkgs ; 19userConfig = epkgs . trivialBuild { 20pname = "default" ; 21src = pkgs . writeText "default.el" cfg . extraConfig ; 22version = "0.1.0" ; 23packageRequires = packages ; 24}; 25in packages ++ optional ( cfg . extraConfig != "" ) userConfig ; 26 27in { 28meta . maintainers = [ maintainers . rycee ]; 29 30options = { 31programs . emacs = { 32enable = mkEnableOption "Emacs" ; 33 34package = mkOption { 35type = types . package ; 36default = pkgs . emacs ; 37defaultText = literalExpression "pkgs.emacs" ; 38example = literalExpression "pkgs.emacs25-nox" ; 39description = "The Emacs package to use." ; 40}; 41 42# NOTE: The config is placed in default.el instead of ~/.emacs.d so that 43# it won't conflict with Emacs configuration frameworks. Users of these 44# frameworks would still benefit from this option as it would easily allow 45# them to have Nix-computed paths in their configuration. 46extraConfig = mkOption { 47type = types . lines ; 48default = "" ; 49example = '' 50(setq standard-indent 2) 51'' ; 52description = '' 53Configuration to include in the Emacs default init file. See 54<https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html> 55for more. 56 57Note, the `inhibit-startup-message` Emacs option 58cannot be set here since Emacs disallows setting it from the default 59initialization file. 60'' ; 61}; 62 63extraPackages = mkOption { 64default = self :[ ]; 65type = hm . types . selectorFunction ; 66defaultText = "epkgs: []" ; 67example = literalExpression "epkgs: [ epkgs.emms epkgs.magit ]" ; 68description = '' 69Extra packages available to Emacs. To get a list of 70available packages run: 71{command}`nix-env -f '<nixpkgs>' -qaP -A emacsPackages`. 72'' ; 73}; 74 75overrides = mkOption { 76default = self :super :{ }; 77type = hm . types . overlayFunction ; 78defaultText = "self: super: {}" ; 79example = literalExpression '' 80self: super: rec { 81haskell-mode = self.melpaPackages.haskell-mode; 82# ... 83}; 84'' ; 85description = '' 86Allows overriding packages within the Emacs package set. 87'' ; 88}; 89 90finalPackage = mkOption { 91type = types . package ; 92visible = false ; 93readOnly = true ; 94description = '' 95The Emacs package including any overrides and extra packages. 96'' ; 97}; 98}; 99}; 100 101config = mkIf cfg . enable { 102home . packages = [ cfg . finalPackage ]; 103programs . emacs . finalPackage = emacsWithPackages extraPackages ; 104}; 105}