Skip to content

Commit

Permalink
fix bashWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Sep 12, 2023
1 parent da34902 commit 544d922
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 0 additions & 2 deletions modules/systemd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ with lib; {
in
mkIf (cfg.enable) {

wsl.binShPkg = if cfg.nativeSystemd then bashWrapper else pkgs.bashInteractive;

# systemd-oomd requires cgroup pressure info which WSL doesn't have
systemd.oomd.enable = false;

Expand Down
15 changes: 12 additions & 3 deletions modules/systemd/native/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ with lib; {
let
cfg = config.wsl;
nativeUtils = pkgs.callPackage ../../../utils { };

bashWrapper = pkgs.writeShellScriptBin "sh" ''
export PATH="$PATH:${lib.makeBinPath [ pkgs.systemd pkgs.gnugrep ]}"
exec ${pkgs.bashInteractive}/bin/sh "$@"
'';
in
mkIf (cfg.enable && cfg.nativeSystemd) {
wsl.wslConf = {
user.default = config.users.users.${cfg.defaultUser}.name;
boot.systemd = true;

wsl = {
binShPkg = bashWrapper;
wslConf = {
user.default = config.users.users.${cfg.defaultUser}.name;
boot.systemd = true;
};
};

system.activationScripts = {
Expand Down
6 changes: 5 additions & 1 deletion modules/systemd/syschdemd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ with lib; {
in
mkIf (cfg.enable && !cfg.nativeSystemd) {

wsl = {
binShPkg = pkgs.bashInteractive;
wslConf.user.default = "root";
};

users.users.root.shell = "${syschdemd}/bin/syschdemd";
security.sudo.extraConfig = ''
Defaults env_keep+=INSIDE_NAMESPACE
'';
wsl.wslConf.user.default = "root";

# Start a systemd user session when starting a command through runuser
security.pam.services.runuser.startSession = true;
Expand Down
5 changes: 0 additions & 5 deletions modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
with builtins; with lib;

let
bashWrapper = pkgs.writeShellScriptBin "sh" ''
export PATH="$PATH:${lib.makeBinPath [ pkgs.systemd pkgs.gnugrep ]}"
exec ${pkgs.bashInteractive}/bin/sh "$@"
'';

cfg = config.wsl;
in
{
Expand Down

0 comments on commit 544d922

Please sign in to comment.