services/enthalpy: implement handcrafted script to switch netns

This commit is contained in:
Lu Wang 2024-12-03 21:45:59 +08:00
parent fbd4f36480
commit 74bc41f8cd
Signed by: rebmit
SSH key fingerprint: SHA256:3px8QV1zEerIrEWHaqtH5rR9kjetyRST5EipOPrd+bU

View file

@ -118,5 +118,17 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
}) })
(mkIf (cfg.users != { }) {
environment.systemPackages = with pkgs; [
(pkgs.writeShellApplication {
name = "netns-run-default";
runtimeInputs = with pkgs; [ util-linux ];
text = ''
pkexec nsenter -t $$ -e --mount=/proc/1/ns/mnt --net=/proc/1/ns/net -S "$(id -u)" -G "$(id -g)" --wdns="$PWD" "$@"
'';
})
];
})
]); ]);
} }