# nixos-config - My current NixOS configuration # # Copyright (C) 2025 Benedikt Peetz # SPDX-License-Identifier: GPL-3.0-or-later # # This file is part of my nixos-config. # # You should have received a copy of the License along with this program. # If not, see . { config, lib, pkgs, sources, ... }: let cfg = config.soispha.programs.direnv; direnvCfg = config.home-manager.users.soispha.programs.direnv; inherit (sources) devshells nixpkgs; pre-cache = pkgs.runCommand "pre-cache.sh" {} '' cat "${./pre-cache.sh}" > $out substituteInPlace $out \ --replace-fail "%DEVSHELLS_REPO%" "${devshells}" \ --replace-fail "%DEVSHELLS_REPO_REF%" "${devshells.sourceInfo.rev}.${builtins.readFile "${nixpkgs}/.git-revision"}" ''; landrun-fish = pkgs.writeShellApplication { name = "landrun-fish"; text = builtins.readFile ./landrun-fish.sh; inheritPath = true; runtimeInputs = [ pkgs.landrun ]; }; in { options.soispha.programs.direnv = { enable = lib.mkEnableOption "direnv"; }; config = lib.mkIf cfg.enable { soispha.programs.fish.integrations.direnv = # fish '' function __direnv_export_eval ${lib.getExe direnvCfg.package} export fish | source; end if test -z "$NO_DIRENV_LOAD" function _direnv_hook if test -f ".env" -o -f ".envrc" -o -f ".nenvrc" ${lib.getExe landrun-fish} --interactive --command='__direnv_export_eval' end end function __direnv_on_prompt --on-event fish_prompt; _direnv_hook end function _direnv_on_preexec --on-event fish_preexec; _direnv_hook end end ''; home-manager.users.soispha = { programs.direnv = { enable = true; package = pkgs.direnv-patched; nix-direnv = { enable = true; package = pkgs.nix-direnv.override {nix = config.nix.package;}; }; # Handled by myself (and the script is overridden) enableBashIntegration = true; enableZshIntegration = true; enableFishIntegration = false; config = { warn_timeout = 0; # NOTE: Something variable is undeclared in the my default loaded stuff :/. <2026-08-18> # strict_env = true; # disable_stdin = true; }; }; xdg.configFile = { "direnv/lib/hm-pre-cache.sh" = { source = pre-cache; }; }; }; }; }