Skip to content

Commit

Permalink
Merge pull request #37 from QuarterHeaven/master
Browse files Browse the repository at this point in the history
add nix flake support
  • Loading branch information
dnut authored Sep 23, 2024
2 parents 2c286a1 + c1e100c commit a79e6ad
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled files and executables
/target/
/result

# distributable packages
/dist/
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Example use cases:

- **Improve Wayland compatibility**: You have already enabled support for wayland in your system, but your computer does not synchronize the clipboard between X11 and wayland windows. clipboard-sync can solve this problem. [more details](https://github.com/dnut/clipboard-sync/issues/9#issuecomment-1502368133)
- **VNC**: You run a VNC server and would like all host and client logins from the same user to share the same clipboard.
- **Multiple displays**: You run two or more desktop environments or window managers in separate ttys, switching between desktops using ctrl-alt-F*.
- **Multiple displays**: You run two or more desktop environments or window managers in separate ttys, switching between desktops using ctrl-alt-F*.
- **Nested Wayland**: You run a wayland compositor within a window. examples:
- you primarily use kde, but run sway in a window to consolidate all your messenger apps into a single tiled/tabbed window.
- you use gnome and develop extensions for gnome, so you run a nested gnome environment for testing.
Expand Down Expand Up @@ -77,6 +77,16 @@ In addition to installing from the official repository, you can also build and i
make deb && sudo apt install ./dist/deb/clipboard-sync_*.deb
```

### NixOS
Add this repo to your flake inputs:
```nix
clipboard-sync.url = "github:dnut/clipboard-sync";
```

Put `clipboard-sync.nixosModules.default` into flake modules.

To enable the systemd service, add `services.clipboard-sync.enable = true;` into the `configuration.nix`.

# Usage
The typical set-and-forget approach is to enable to service:
```bash
Expand Down
11 changes: 11 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
pkgs ? import <nixpkgs> { },
}:
pkgs.rustPlatform.buildRustPackage rec {
buildInputs = with pkgs; [ xorg.libxcb ];

pname = "clipboard-sync";
version = "0.2.0";
cargoLock.lockFile = ./Cargo.lock;
src = ./.;
}
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
description = "Synchronizes the clipboard across multiple X11 and wayland instances running on the same machine";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = nixpkgs.legacyPackages;
in
{
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
packages = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./. { };
});

nixosModules.default =
# For illustration, probably want to break this definition out to a separate file
{
config,
pkgs,
lib,
...
}:
{
options = {
services.clipboard-sync.enable = lib.mkEnableOption "clipboard-sync";
};

config = lib.mkIf config.services.clipboard-sync.enable {
systemd.user.services.clipboard-sync = {
description = "Synchronize clipboards across all displays";
documentation = [ "https://github.com/dnut/clipboard-sync/" ];
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
requisite = [ "graphical-session.target" ];
serviceConfig.ExecStart = "/usr/bin/env ${
self.packages.${pkgs.system}.default
}/bin/clipboard-sync --hide-timestamp --log-level debug";
serviceConfig.Restart = "on-failure";
};
};
};
};
}

0 comments on commit a79e6ad

Please sign in to comment.