-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.nix
155 lines (134 loc) · 4.06 KB
/
configuration.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# NixOS-WSL config: system packages and settings
{ config, lib, pkgs, inputs, ... }:
{
nixpkgs.config.allowUnfree = true;
wsl = {
enable = true;
defaultUser = "nixos";
useWindowsDriver = true;
wslConf.boot.command = "${pkgs.zsh}/bin/zsh";
};
programs.zsh = {
enable = true;
};
users.defaultUserShell = pkgs.zsh;
programs.ssh.startAgent = false;
environment.variables = {
LD_LIBRARY_PATH = "/usr/lib/wsl/lib:$LD_LIBRARY_PATH";
SSH_AUTH_SOCK = "/mnt/wsl/ssh-agent.sock";
};
# Keep only system-wide packages here
environment.systemPackages = with pkgs; [
git
curl
wget
nvtopPackages.full
socat
zsh
starship
nvd
wslu
coreutils
];
services = {
openssh.enable = true;
};
programs.nix-ld = {
enable = true;
package = pkgs.nix-ld-rs;
};
nix = {
settings = {
experimental-features = ["nix-command" "flakes" "repl-flake"];
auto-optimise-store = true;
trusted-users = ["root" "nixos"];
max-jobs = "auto";
cores = 0;
keep-outputs = true;
keep-derivations = true;
fallback = true;
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://cuda-maintainers.cachix.org"
"https://devenv.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
];
sandbox = true;
use-xdg-base-directories = true;
download-attempts = 3;
connect-timeout = 5;
min-free = 128000000;
max-free = 1000000000;
};
registry = {
nixpkgs.flake = inputs.nixpkgs;
nixpkgs-unstable.flake = inputs.nixpkgs-unstable;
default.flake = inputs.nixpkgs;
};
};
system.stateVersion = "24.05";
systemd.user.services.ssh-agent-proxy = {
description = "Windows SSH agent proxy";
path = [ pkgs.wslu pkgs.coreutils pkgs.bash ];
serviceConfig = {
ExecStartPre = [
"${pkgs.coreutils}/bin/mkdir -p /mnt/wsl"
"${pkgs.coreutils}/bin/rm -f /mnt/wsl/ssh-agent.sock"
];
ExecStart = "${pkgs.writeShellScript "ssh-agent-proxy" ''
set -x # Enable debug output
# Get Windows username using wslvar
WIN_USER="$("${pkgs.wslu}/bin/wslvar" USERNAME 2>/dev/null || echo $USER)"
# Check common npiperelay locations
NPIPE_PATHS=(
"/mnt/c/Users/$WIN_USER/AppData/Local/Microsoft/WinGet/Links/npiperelay.exe"
"/mnt/c/ProgramData/chocolatey/bin/npiperelay.exe"
)
NPIPE_PATH=""
for path in "''${NPIPE_PATHS[@]}"; do
echo "Checking npiperelay at: $path"
if [ -f "$path" ]; then
NPIPE_PATH="$path"
break
fi
done
if [ -z "$NPIPE_PATH" ]; then
echo "npiperelay.exe not found in expected locations!"
exit 1
fi
echo "Using npiperelay from: $NPIPE_PATH"
exec ${pkgs.socat}/bin/socat -d UNIX-LISTEN:/mnt/wsl/ssh-agent.sock,fork,mode=600 \
EXEC:"$NPIPE_PATH -ei -s //./pipe/openssh-ssh-agent",nofork
''}";
Type = "simple";
Restart = "always";
RestartSec = "5";
StandardOutput = "journal";
StandardError = "journal";
};
wantedBy = [ "default.target" ];
};
systemd.user.services.ssh-agent-proxy.serviceConfig.RuntimeDirectory = "ssh-agent";
# Disable the default command-not-found
programs.command-not-found.enable = false;
programs.nh = {
enable = true;
clean = {
enable = true;
extraArgs = "--keep-since 7d --keep 10";
};
flake = "/home/nixos/nixos-config";
};
# Set default shell for your user
users.users.nixos = {
shell = pkgs.zsh;
isNormalUser = true;
# Keep any other existing user settings
};
}