Skip to content

Commit 2405942

Browse files
karaolidisljxfstorm
authored andcommitted
feat: wl-clipboard-wsl
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com> Co-authored-by: ljxfstorm <ljxf.storm@live.cn> Signed-off-by: Nick Karaolidis <Nick.Karaolidis@sas.com>
1 parent be89460 commit 2405942

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
utils = pkgs.callPackage ./utils { };
9090
staticUtils = pkgs.pkgsStatic.callPackage ./utils { };
9191
docs = pkgs.callPackage ./docs { };
92+
wl-clipboard-wsl = pkgs.callPackage ./packages/wl-clipboard-wsl { };
9293
});
9394

9495
devShells = forAllSystems (pkgs: {

modules/clipboard.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{ config
2+
, lib
3+
, pkgs
4+
, ...
5+
}:
6+
let
7+
cfg = config.wsl.clipboard;
8+
in
9+
{
10+
options.wsl.clipboard = {
11+
enable = lib.mkEnableOption "wl-copy/wl-paste integration via Windows clipboard";
12+
13+
package = lib.mkOption {
14+
type = lib.types.package;
15+
default = pkgs.callPackage ../packages/wl-clipboard-wsl { };
16+
description = "Package providing wl-copy and wl-paste wrappers for WSL clipboard interop.";
17+
};
18+
};
19+
20+
config = lib.mkIf (config.wsl.enable && cfg.enable) {
21+
environment.systemPackages = [ cfg.package ];
22+
};
23+
}

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{ lib, ... }: {
22
imports = [
33
./build-tarball.nix
4+
./clipboard.nix
45
./docker-desktop.nix
56
./interop.nix
67
./recovery.nix
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ pkgs, ... }:
2+
let
3+
wl-copy = pkgs.writeShellScriptBin "wl-copy" ''
4+
printf '%s' "$(cat)" | ${pkgs.dos2unix}/bin/unix2dos | /mnt/c/windows/system32/clip.exe
5+
'';
6+
7+
wl-paste = pkgs.writeShellScriptBin "wl-paste" ''
8+
/mnt/c/windows/system32/windowspowershell/v1.0/powershell.exe -command Get-Clipboard | ${pkgs.dos2unix}/bin/dos2unix
9+
'';
10+
in
11+
pkgs.symlinkJoin {
12+
name = "wl-clipboard-wsl";
13+
paths = [
14+
wl-copy
15+
wl-paste
16+
];
17+
}

0 commit comments

Comments
 (0)