Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
107 lines (93 loc) · 3.58 KB
/
Copy pathflake.nix
File metadata and controls
107 lines (93 loc) · 3.58 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
{
description = "Hardware kill-switch daemon for Linux and FreeBSD that powers off on hardware changes (USB, Thunderbolt, SD, PCI, power, network, lid, display)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachSystem
[
"x86_64-linux"
"aarch64-linux"
]
(
system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "plugkill";
version = (builtins.fromTOML (builtins.readFile ./crates/plugkill/Cargo.toml)).package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
# Integration tests require /sys/bus/usb/devices which is unavailable in the Nix sandbox
checkFlags = [
"--skip=test_list_devices_no_root"
"--skip=test_generate_whitelist_no_root"
];
# The polkit actions for require_auth. Inert unless the daemon is
# started with it, and polkit only reads them once the package is on
# the system path.
postInstall = ''
install -Dm444 assets/net.acidnetworks.plugkill.policy \
-t $out/share/polkit-1/actions
'';
meta = {
description = "Hardware kill-switch daemon that shuts down the system when device changes are detected";
license = pkgs.lib.licenses.gpl3Plus;
platforms = [
"x86_64-linux"
"aarch64-linux"
];
mainProgram = "plugkill";
};
};
packages.gui = pkgs.rustPlatform.buildRustPackage {
pname = "plugkill-gui";
version = (builtins.fromTOML (builtins.readFile ./crates/plugkill-gui/Cargo.toml)).package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = [ "--package" "plugkill-gui" ];
cargoTestFlags = [ "--package" "plugkill-gui" ];
nativeBuildInputs = with pkgs; [ pkg-config wrapGAppsHook4 ];
buildInputs = with pkgs; [ gtk4 gtk4-layer-shell ];
# The desktop entry is named for the GTK application id, so the
# compositor matches the dashboard window to it and the launcher
# shows the right name and icon. The tray's own icons are embedded
# in the binary and written out at startup; this one is the app
# icon that the entry points at.
postInstall = ''
install -Dm444 assets/io.github.aciddemon.plugkill.desktop \
-t $out/share/applications
install -Dm444 assets/plugkill-icon.svg \
$out/share/icons/hicolor/scalable/apps/io.github.aciddemon.plugkill.svg
'';
meta = {
description = "Tray icon and dashboard for the plugkill daemon";
license = pkgs.lib.licenses.gpl3Plus;
platforms = [ "x86_64-linux" "aarch64-linux" ];
mainProgram = "plugkill-gui";
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [
cargo
rustc
rust-analyzer
clippy
rustfmt
gtk4
gtk4-layer-shell
];
};
}
)
// {
nixosModules.default = import ./nix/module.nix self;
nixosModules.relay = import ./nix/relay-module.nix self;
};
}