Provide NixOS module
This commit is contained in:
parent
5bd65faa55
commit
d007d1f2f7
27
README.md
27
README.md
|
@ -43,19 +43,16 @@ This repository also contains a Nix flake. It can be used in a NixOS configurati
|
||||||
```nix
|
```nix
|
||||||
url-eater.url = "github:AgathaSorceress/url-eater";
|
url-eater.url = "github:AgathaSorceress/url-eater";
|
||||||
```
|
```
|
||||||
2. Add package
|
2. Import NixOS module
|
||||||
```nix
|
```nix
|
||||||
nixpkgs.overlays = [
|
imports = [ url-eater.nixosModule ];
|
||||||
(final: prev: {
|
|
||||||
url-eater = url-eater.defaultPackage.${final.system};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
```
|
```
|
||||||
3. Add a module that defines a systemd service:
|
3. Configure the module:
|
||||||
```nix
|
```nix
|
||||||
{ pkgs, ... }:
|
{ ... }: {
|
||||||
let
|
services.url-eater = {
|
||||||
filters = pkgs.writeText "filters.kdl" ''
|
enable = true;
|
||||||
|
filters = ''
|
||||||
category "Spotify" {
|
category "Spotify" {
|
||||||
params "context@open.spotify.com" "si@open.spotify.com"
|
params "context@open.spotify.com" "si@open.spotify.com"
|
||||||
}
|
}
|
||||||
|
@ -63,16 +60,6 @@ let
|
||||||
params "cxt@*.twitter.com" "ref_*@*.twitter.com" "s@*.twitter.com" "t@*.twitter.com" "twclid"
|
params "cxt@*.twitter.com" "ref_*@*.twitter.com" "s@*.twitter.com" "t@*.twitter.com" "twclid"
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in {
|
|
||||||
systemd.user.services."url-eater" = {
|
|
||||||
description = "Clipboard URL cleanup service";
|
|
||||||
|
|
||||||
after = [ "graphical-session-pre.target" ];
|
|
||||||
wantedBy = [ "graphical-session.target" ];
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
exec ${pkgs.url-eater}/bin/url-eater ${filters}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
41
flake.nix
41
flake.nix
|
@ -24,5 +24,44 @@
|
||||||
];
|
];
|
||||||
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
||||||
};
|
};
|
||||||
});
|
}) // {
|
||||||
|
nixosModule = { 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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
systemd.user.services."url-eater" = let
|
||||||
|
filters = pkgs.writeText "filters.kdl" cfg.filters;
|
||||||
|
pkg = self.defaultPackage.${pkgs.system};
|
||||||
|
in {
|
||||||
|
description = "Clipboard URL cleanup service";
|
||||||
|
|
||||||
|
after = [ "graphical-session-pre.target" ];
|
||||||
|
wantedBy = [ "graphical-session.target" ];
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
exec ${pkg}/bin/url-eater ${filters}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue