-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodule.nix
More file actions
50 lines (41 loc) · 1.41 KB
/
Copy pathmodule.nix
File metadata and controls
50 lines (41 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.prll;
in
{
options.programs.prll = {
enable = lib.mkEnableOption "prll, a POSIX shell function for parallelizing tasks over multiple CPU cores";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.callPackage ./package.nix { };
defaultText = lib.literalExpression "pkgs.callPackage <prll/package.nix> { }";
description = "The prll package to use.";
};
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
# prll.sh only works in POSIX-function shells (bash, zsh); fish, ion and
# nushell have incompatible function/scripting syntax and can't source it.
# prll.sh only defines a shell function; it has no ordering requirement
# relative to completion, aliases, prompts, etc., so it just needs to
# load after the (unordered) defaults -- hence mkAfter, not a specific
# hand-picked position.
programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration (
lib.mkAfter ''
source ${cfg.package}/share/prll/prll.sh
''
);
programs.zsh.initContent = lib.mkIf cfg.enableZshIntegration (
lib.mkAfter ''
source ${cfg.package}/share/prll/prll.sh
''
);
};
}