Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions share/modules/nixos-shell-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,47 @@ in {
xterm # for resize command
];

extraSetup = lib.optionalString cfg.terminfo.fixFSCaseConflicts ''
nixosShell::symlinkToDir() (
# this function runs in a subshell to make shopt local to this function
shopt -s nullglob

local target="$1"

if ! [[ -L "$target" && -d "$target" ]]; then
return
fi

local linkTo="$(readlink "$target")"
rm "$target"
mkdir "$target"

local files=( "$linkTo/"{.,}* )
if (( ''${#files[@]} > 0 )); then
cp -s "''${files[@]}" "$target/"
fi
)

nixosShell::fixTerminfoFSCaseConflicts() {
nixosShell::symlinkToDir "$out"
nixosShell::symlinkToDir "$out/share"
nixosShell::symlinkToDir "$out/share/terminfo"
pushd "$out/share/terminfo"

local c
for c in {a..z}; do
if [[ -d "$c" && -d "''${c@U}" && ! "$c" -ef ''${c@U} ]]; then
nixosShell::symlinkToDir "''${c@U}"
cp "$c/"* "''${c@U}/"
fi
done

popd
}

nixosShell::fixTerminfoFSCaseConflicts
'';

loginShellInit =
let
pwd = builtins.getEnv "PWD";
Expand Down
12 changes: 12 additions & 0 deletions share/modules/nixos-shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{ lib, pkgs, modulesPath, config, options, extendModules, ... }:

let
isDarwin = options.virtualisation.host.pkgs.isDefined && config.virtualisation.host.pkgs.stdenv.hostPlatform.isDarwin;
in
{
imports = [
"${toString modulesPath}/virtualisation/qemu-vm.nix"
Expand Down Expand Up @@ -65,6 +68,15 @@
default = {};
};
};

terminfo.fixFSCaseConflicts = mkOption {
type = types.bool;
default = isDarwin;
description = ''
Whether to apply workaround for broken terminfo lookup on hosts with case insensitive file
systems.
'';
};
};

config = let
Expand Down
Loading