File tree 3 files changed +56
-1
lines changed
3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 19
19
20
20
# Enable integration with Docker Desktop (needs to be installed)
21
21
# docker.enable = true;
22
+
23
+ # Enable authenticating sudo prompts with Windows Hello
24
+ # windowsHello.enable = true;
22
25
} ;
23
26
24
27
# Enable nix flakes
Original file line number Diff line number Diff line change 17
17
nixosModules . wsl = {
18
18
imports = [
19
19
./modules/build-tarball.nix
20
- ./modules/wsl-distro.nix
21
20
./modules/docker-desktop.nix
22
21
./modules/installer.nix
22
+ ./modules/windows-hello.nix
23
+ ./modules/wsl-distro.nix
23
24
] ;
24
25
} ;
25
26
Original file line number Diff line number Diff line change
1
+ { lib , pkgs , config , ... } :
2
+
3
+ with builtins ; with lib ;
4
+ {
5
+
6
+ options . wsl . windowsHello = {
7
+ enable = mkEnableOption "Authentication using Windows Hello" ;
8
+ } ;
9
+
10
+ config =
11
+ let
12
+ cfg = config . wsl . windowsHello ;
13
+ in
14
+ mkIf ( config . wsl . enable && cfg . enable ) {
15
+
16
+ security . sudo . wheelNeedsPassword = true ;
17
+ security . sudo . extraConfig = ''
18
+ Defaults rootpw
19
+ '' ;
20
+
21
+ # Hijack the pam_usb module, because NixOS does not allow for adding custom PAM modules at the moment
22
+ security . pam . usb . enable = true ;
23
+ nixpkgs . overlays = [
24
+ ( self : super : {
25
+ pam_usb =
26
+ let
27
+ authenticator = pkgs . stdenv . mkDerivation {
28
+ name = "WindowsHelloAuthenticator.exe" ;
29
+ src = pkgs . fetchurl {
30
+ url = "https://github.com/nzbr/PAM-WindowsHello/releases/download/v1/WindowsHelloAuthenticator.exe" ;
31
+ sha256 = "4856a1fefa5c869b78890f9313a560d310e9c11f2a2a212c2868cf292792ff7f" ;
32
+ } ;
33
+ dontUnpack = true ;
34
+ buildCommand = ''
35
+ install -m 0755 $src $out
36
+ '' ;
37
+ } ;
38
+ wrapper = pkgs . writeShellScript "wrapper" ''
39
+ export PATH=${ pkgs . coreutils } /bin # The PAM environment does not include the default PATH
40
+ export WSL_INTEROP="/run/WSL/$(ls -tr /run/WSL | tail -n1)" # Find the correct WSL_INTEROP socket to be able to start the EXE
41
+ env > /tmp/env
42
+ exec ${ authenticator } [$PAM_SERVICE] $PAM_RUSER wants to authenticate as $PAM_USER
43
+ '' ;
44
+ in
45
+ "${ pkgs . pam } /lib/security/pam_exec.so ${ wrapper } \n # " ;
46
+ } )
47
+ ] ;
48
+
49
+ } ;
50
+
51
+ }
You can’t perform that action at this time.
0 commit comments