devenv: init module
This commit is contained in:
committed by
Austin Horstman
parent
351959fcdb
commit
6cb9da2a4d
@@ -0,0 +1,63 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkIf
|
||||
mkAfter
|
||||
getExe
|
||||
;
|
||||
|
||||
cfg = config.programs.devenv;
|
||||
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [
|
||||
leiserfg
|
||||
];
|
||||
|
||||
options.programs.devenv = {
|
||||
enable = mkEnableOption "devenv, Fast, Declarative, Reproducible and Composable Developer Environments using Nix";
|
||||
|
||||
package = mkPackageOption pkgs "devenv" { };
|
||||
|
||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
||||
|
||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||
|
||||
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
programs = {
|
||||
bash.initExtra = mkIf cfg.enableBashIntegration (mkAfter ''
|
||||
eval "$(${getExe cfg.package} hook bash)"
|
||||
'');
|
||||
|
||||
fish.interactiveShellInit = mkIf cfg.enableFishIntegration (mkAfter ''
|
||||
${getExe cfg.package} hook fish | source
|
||||
'');
|
||||
|
||||
zsh.initContent = mkIf cfg.enableZshIntegration ''
|
||||
eval "$(${getExe cfg.package} hook zsh)"
|
||||
'';
|
||||
|
||||
nushell = mkIf cfg.enableNushellIntegration {
|
||||
extraConfig = "source ${
|
||||
pkgs.runCommand "devenv-nushell-config.nu" { } ''
|
||||
${getExe cfg.package} hook nu > $out
|
||||
''
|
||||
} ";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -43,6 +43,7 @@ let
|
||||
"cudatext"
|
||||
"darcs"
|
||||
"delta"
|
||||
"devenv"
|
||||
"difftastic"
|
||||
"dircolors"
|
||||
"direnv"
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
programs = {
|
||||
devenv = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableNushellIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "devenv";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/devenv << 'EOF'
|
||||
#! /bin/sh
|
||||
echo "Stub called with args $@"
|
||||
EOF
|
||||
chmod +x $out/bin/devenv
|
||||
'';
|
||||
};
|
||||
};
|
||||
bash.enable = true;
|
||||
fish.enable = true;
|
||||
nushell.enable = true;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
nushellConfigFile =
|
||||
if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
||||
"home-files/Library/Application Support/nushell/config.nu"
|
||||
else
|
||||
"home-files/.config/nushell/config.nu";
|
||||
in
|
||||
# Bash
|
||||
''
|
||||
assertFileRegex home-files/.bashrc \
|
||||
'eval.*devenv hook bash'
|
||||
|
||||
# Test zsh integration
|
||||
assertFileRegex home-files/.zshrc \
|
||||
'eval.*devenv hook zsh'
|
||||
|
||||
# Test fish integration (enabled by default)
|
||||
assertFileRegex home-files/.config/fish/config.fish \
|
||||
'devenv hook fish.*source'
|
||||
|
||||
# Test nushell integration
|
||||
assertFileExists "${nushellConfigFile}"
|
||||
assertFileRegex "${nushellConfigFile}" 'source /nix/store.*devenv-nushell-config.nu'
|
||||
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
devenv = ./basic-config.nix;
|
||||
}
|
||||
Reference in New Issue
Block a user