-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
72 lines (72 loc) · 2.44 KB
/
flake.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
{
description = "WebNowPlaying-CLI";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
libwnp.url = "github:keifufu/WebNowPlaying-Library";
};
outputs = inputs@{ self, flake-parts, libwnp, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem = { pkgs, system, lib, ...}: let
libwnppkg = libwnp.packages.${system}.default;
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "wnpcli";
version = builtins.readFile ./VERSION;
src = ./.;
nativeBuildInputs = [ pkgs.cmake ]
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.pkg-config ];
buildInputs = [ libwnppkg ]
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.glib ];
meta.mainProgram = "wnpcli";
};
devShells.default = pkgs.mkShell {
shellHook = "exec $SHELL";
buildInputs = with pkgs; [ clang cmake glib pkg-config dpkg rpm ] ++ [ libwnppkg ];
};
};
flake = {
homeManagerModules.wnpcli = { config, pkgs, lib, ... }: let
inherit (pkgs.stdenv.hostPlatform) system;
in {
options.programs.wnpcli = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Install wnpcli package";
};
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${system}.default;
description = "wnpcli package to install";
};
service.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable wnpcli service";
};
};
config = lib.mkIf config.programs.wnpcli.enable {
home.packages = [ config.programs.wnpcli.package ];
systemd.user.services.wnpcli = lib.mkIf config.programs.wnpcli.service.enable {
Unit = {
Description = "wnpcli service";
After = [ "default.target" ];
};
Service = {
Type = "simple";
ExecStart = "${config.programs.wnpcli.package}/bin/wnpcli start-daemon --no-detach";
Restart = "always";
};
Install.WantedBy = [ "default.target" ];
};
};
};
};
};
}