mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-18 14:28:15 +00:00
Due to fish being a non-POSIX shell, granted provides a separate wrapper to be used by fish.
40 lines
928 B
Nix
40 lines
928 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.granted;
|
|
package = pkgs.granted;
|
|
|
|
in {
|
|
meta.maintainers = [ hm.maintainers.wcarlsen ];
|
|
|
|
options.programs.granted = {
|
|
enable = mkEnableOption "granted";
|
|
|
|
enableZshIntegration =
|
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
|
|
|
enableFishIntegration =
|
|
lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ package ];
|
|
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
function assume() {
|
|
export GRANTED_ALIAS_CONFIGURED="true"
|
|
source ${package}/bin/assume "$@"
|
|
unset GRANTED_ALIAS_CONFIGURED
|
|
}
|
|
'';
|
|
|
|
programs.fish.functions.assume = mkIf cfg.enableFishIntegration ''
|
|
set -x GRANTED_ALIAS_CONFIGURED "true"
|
|
source ${package}/share/assume.fish
|
|
set -e GRANTED_ALIAS_CONFIGURED
|
|
'';
|
|
};
|
|
}
|