-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
110 lines (95 loc) · 2.73 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
description = "Minimal Apple Music CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = {
self,
nixpkgs,
...
}: let
version = builtins.substring 0 8 self.lastModifiedDate;
inherit (nixpkgs) lib;
systems = ["x86_64-darwin" "aarch64-darwin"];
forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s});
in {
checks = forAllSystems (pkgs: let
formatter = self.formatter.${pkgs.system};
in {
fmt =
pkgs.runCommand "check-fmt" {}
''
${pkgs.lib.getExe formatter} --check ${self}
touch $out
'';
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
rust-analyzer
rustc
cargo
rustfmt
];
RUST_BACKTRACE = 1;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
});
packages = forAllSystems (
pkgs: let
scope = lib.makeScope pkgs.newScope;
fn = final: {p = self.overlays.default final pkgs;};
inherit (scope fn) p;
in
p // {default = p.am;}
);
formatter = forAllSystems (p: p.alejandra);
overlays.default = _: prev: {
am = prev.callPackage ./default.nix {
inherit self version;
inherit (prev.darwin.apple_sdk_11_0.frameworks) CoreFoundation Security SystemConfiguration;
inherit (prev.darwin) IOKit;
};
};
homeManagerModules.default = {
lib,
config,
pkgs,
...
}: let
cfg = config.services.am-discord-rich-presence;
inherit (lib) mkEnableOption mkIf mkOption mkPackageOption types;
in {
options.services.am-discord-rich-presence = {
enable = mkEnableOption "am-discord-rich-presence";
package = mkPackageOption pkgs "am" {};
logFile = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Path to where am's Discord presence will store its log file
'';
example = ''''${config.xdg.cacheHome}/am-discord-rich-presence.log'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform
"launchd.agents.am-discord-rich-presence"
pkgs
lib.platforms.darwin)
];
launchd.agents.am-discord-rich-presence = {
enable = true;
config = {
ProgramArguments = ["${lib.getExe cfg.package}" "discord"];
KeepAlive = true;
RunAtLoad = true;
StandardOutPath = cfg.logFile;
StandardErrorPath = cfg.logFile;
};
};
};
};
};
}