fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Joakim Holmion: Add module (#2625)4e92ec84

master
1.3 KiB59 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.programs.ion;
7
8  aliasesStr = concatStringsSep "\n"
9    (mapAttrsToList (k: v: "alias ${k} = ${escapeShellArg v}")
10      cfg.shellAliases);
11in {
12  meta.maintainers = [ maintainers.jo1gi ];
13
14  options.programs.ion = {
15    enable = mkEnableOption "the Ion Shell. Compatible with Redox and Linux";
16
17    package = mkOption {
18      type = types.package;
19      default = pkgs.ion;
20      defaultText = literalExpression "pkgs.ion";
21      description = ''
22        The ion package to install. May be used to change the version.
23      '';
24    };
25
26    initExtra = mkOption {
27      type = types.lines;
28      default = "";
29      description = ''
30        Ion script which is called during ion initialization.
31      '';
32    };
33
34    shellAliases = mkOption {
35      type = with types; attrsOf str;
36      default = { };
37      example = literalExpression ''
38        {
39          g = "git";
40        }
41      '';
42      description = ''
43        An attribute set that maps aliases (the top level attribute names
44        in this option) to command strings or directly to build outputs.
45      '';
46    };
47  };
48
49  config = mkIf cfg.enable {
50    home.packages = [ cfg.package ];
51
52    xdg.configFile."ion/initrc".text = ''
53      # Aliases
54      ${aliasesStr}
55
56      ${cfg.initExtra}
57    '';
58  };
59}