2023-04-02 17:20:29 +00:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
naersk.url = "github:nix-community/naersk/master";
|
2024-03-15 17:25:08 +00:00
|
|
|
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
2023-04-02 17:20:29 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2024-11-28 22:48:00 +00:00
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
utils,
|
|
|
|
naersk,
|
|
|
|
}:
|
|
|
|
utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
2023-04-02 17:20:29 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
naersk-lib = pkgs.callPackage naersk { };
|
2024-11-28 22:48:00 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages.default = naersk-lib.buildPackage {
|
|
|
|
src = ./.;
|
|
|
|
buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit ];
|
|
|
|
};
|
|
|
|
devShells.default =
|
|
|
|
with pkgs;
|
2023-04-02 17:20:29 +00:00
|
|
|
mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
rustfmt
|
|
|
|
pre-commit
|
|
|
|
rustPackages.clippy
|
|
|
|
rust-analyzer
|
|
|
|
];
|
|
|
|
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
|
|
|
};
|
2024-11-28 22:48:00 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
// {
|
|
|
|
nixosModules.default =
|
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.url-eater;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.url-eater = {
|
|
|
|
enable = mkEnableOption "Enables the URL Eater service";
|
|
|
|
filters = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = ''
|
|
|
|
category "Spotify" {
|
|
|
|
params "context@open.spotify.com" "si@open.spotify.com"
|
|
|
|
}
|
|
|
|
category "Twitter" {
|
|
|
|
params "cxt@*.twitter.com" "ref_*@*.twitter.com" "s@*.twitter.com" "t@*.twitter.com" "twclid"
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = mdDoc ''
|
|
|
|
A list of filters to use, in the KDL file format.
|
|
|
|
'';
|
2023-04-15 10:29:10 +00:00
|
|
|
};
|
2024-11-28 22:48:00 +00:00
|
|
|
};
|
2023-04-15 10:29:10 +00:00
|
|
|
|
2024-11-28 22:48:00 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.user.services."url-eater" =
|
|
|
|
let
|
2023-04-15 10:29:10 +00:00
|
|
|
filters = pkgs.writeText "filters.kdl" cfg.filters;
|
2024-01-10 11:51:08 +00:00
|
|
|
pkg = self.packages.${pkgs.system}.default;
|
2024-11-28 22:48:00 +00:00
|
|
|
in
|
|
|
|
{
|
2023-04-15 10:29:10 +00:00
|
|
|
description = "Clipboard URL cleanup service";
|
|
|
|
|
|
|
|
after = [ "graphical-session-pre.target" ];
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
exec ${pkg}/bin/url-eater ${filters}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2024-11-28 22:48:00 +00:00
|
|
|
};
|
|
|
|
};
|
2023-04-02 17:20:29 +00:00
|
|
|
}
|