2022-09-24 03:24:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
environment.binbash.enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Include a /bin/bash in the system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
environment.binbash.bash = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.bashInteractive;
|
|
|
|
defaultText = literalExpression "pkgs.bashInteractive";
|
|
|
|
example = literalExpression "pkgs.bash";
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The bash implementation that will be present in
|
|
|
|
`/bin/bash` after enabling this option.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2022-09-27 16:17:40 +00:00
|
|
|
system.activationScripts.binbash = mkMerge [
|
|
|
|
(mkIf config.environment.binbash.enable ''
|
2022-09-24 03:24:58 +00:00
|
|
|
mkdir -m 0755 -p /bin
|
|
|
|
ln -sfn ${config.environment.binbash.bash}/bin/bash /bin/.bash.tmp
|
2022-09-27 16:17:40 +00:00
|
|
|
mv /bin/.bash.tmp /bin/bash # atomically replace
|
|
|
|
'')
|
|
|
|
(mkIf (! config.environment.binbash.enable) ''
|
2022-09-24 03:24:58 +00:00
|
|
|
rm -f /bin/bash
|
2022-09-27 16:17:40 +00:00
|
|
|
'')
|
|
|
|
];
|
2022-09-24 03:24:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|