forked from Toqozz/wired-notify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
127 lines (115 loc) · 3.76 KB
/
Copy pathflake.nix
File metadata and controls
127 lines (115 loc) · 3.76 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description = "Lightweight notification daemon with highly customizable layout blocks, written in Rust.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
alejandra = {
url = "github:kamadorueda/alejandra";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
utils,
alejandra,
...
}: let
inherit (builtins) fromTOML readFile substring mapAttrs;
supportedSystems = [
"aarch64-linux"
"i686-linux"
"x86_64-linux"
];
eachSupportedSystems = utils.lib.eachSystem supportedSystems;
cargoToml = fromTOML (readFile ./Cargo.toml);
version = "${cargoToml.package.version}_${substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}";
mkWired = {
lib,
rustPlatform,
dbus,
dlib,
cairo,
pango,
pkg-config,
xorg,
...
}:
rustPlatform.buildRustPackage {
name = "wired-${version}";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
# Requires dbus cairo and pango
# pkgconfig, glib and xorg are required for x11-crate
nativeBuildInputs = [pkg-config];
buildInputs = [
dbus
dlib
cairo
pango
xorg.libX11
xorg.libXi
xorg.libXrandr
xorg.libXcursor
xorg.libXScrnSaver
];
# install extra files (i.e. the systemd service)
postInstall = ''
# /usr/bin/wired doesn't exist, here, because the binary will be somewhere in /nix/store,
# so this fixes the bin path in the systemd service and writes the updated file to the output dir.
mkdir -p $out/usr/lib/systemd/system
substitute ./wired.service $out/usr/lib/systemd/system/wired.service --replace /usr/bin/wired $out/bin/wired
# install example/default config files to etc/wired -- Arch packages seem to use etc/{pkg} for this,
# so there's precedent
install -Dm444 -t $out/etc/wired wired.ron wired_multilayout.ron
'';
meta = {
homepage = "https://github.com/Toqozz/wired-notify";
downloadPage = "https://github.com/Toqozz/wired-notify/releases";
license = lib.licenses.mit;
};
};
in ({
# `nix fmt` (added in Nix 2.8)
# (generating this outside of `eachDefaultSystem` because alejandra's supported systems may not match ours)
formatter = mapAttrs (system: pkgs: pkgs.default) alejandra.packages;
# consumed by github:nix-community/home-manager
homeManagerModules.default = import ./home-manager.nix;
overlays = {
default = final: prev: {
wired = prev.callPackage mkWired {};
};
};
}
// (
eachSupportedSystems (system: let
pkgs = import nixpkgs {inherit system;};
wired = pkgs.callPackage mkWired {};
in {
# `nix build`
packages = {
inherit wired;
default = wired;
};
# `defaultPackage` deprecated in Nix 2.7
defaultPackage = self.packages.${system}.default;
# `nix run`
apps.wired = {
type = "app";
program = "${wired}/bin/wired";
};
apps.default = self.apps.${system}.wired;
# `defaultApp` deprecated in Nix 2.7
defaultApp = self.apps.${system}.default;
# `nix develop`
devShells.default = pkgs.mkShell {
nativeBuildInputs =
wired.nativeBuildInputs
++ (with pkgs; [rustc cargo gcc clippy rustfmt]);
inherit (wired) buildInputs;
};
# `devShell` deprecated in Nix 2.7
devShell = self.devShells.${system}.default;
})
));
}