1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-04-09 10:34:44 +00:00

nix-your-shell: remove with lib

This commit is contained in:
Austin Horstman 2025-03-19 14:57:27 -05:00
parent ebf4c552ba
commit 029ba1aa9f
No known key found for this signature in database

View file

@ -1,20 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.nix-your-shell;
let cfg = config.programs.nix-your-shell;
in {
meta.maintainers = [ maintainers.terlar ];
meta.maintainers = [ lib.maintainers.terlar ];
options.programs.nix-your-shell = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
{command}`nix-your-shell`, a wrapper for `nix develop` or `nix-shell`
to retain the same shell inside the new environment'';
package = mkPackageOption pkgs "nix-your-shell" { };
package = lib.mkPackageOption pkgs "nix-your-shell" { };
enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };
@ -25,23 +19,23 @@ in {
enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
enableNom = mkEnableOption "nom (nix-output-monitor) integration";
enableNom = lib.mkEnableOption "nom (nix-output-monitor) integration";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]
++ (optionals cfg.enableNom [ pkgs.nix-output-monitor ]);
++ (lib.optionals cfg.enableNom [ pkgs.nix-output-monitor ]);
programs = let
argsForShell = shell:
concatStringsSep " "
([ ] ++ (optional cfg.enableNom "--nom") ++ [ "${shell}" ]);
lib.concatStringsSep " "
([ ] ++ (lib.optional cfg.enableNom "--nom") ++ [ "${shell}" ]);
in {
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
${cfg.package}/bin/nix-your-shell ${argsForShell "fish"} | source
'';
nushell = mkIf cfg.enableNushellIntegration {
nushell = lib.mkIf cfg.enableNushellIntegration {
extraEnv = ''
mkdir ${config.xdg.cacheHome}/nix-your-shell
${cfg.package}/bin/nix-your-shell ${
@ -54,7 +48,7 @@ in {
'';
};
zsh.initExtra = mkIf cfg.enableZshIntegration ''
zsh.initExtra = lib.mkIf cfg.enableZshIntegration ''
${cfg.package}/bin/nix-your-shell ${
argsForShell "zsh"
} | source /dev/stdin