-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
151 lines (138 loc) · 4.18 KB
/
flake.nix
File metadata and controls
151 lines (138 loc) · 4.18 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
{
description = "Sound Blaster X G7 Control for Linux - A native GUI application to control the Creative Sound Blaster X G6";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; # unstable Nixpkgs
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self, ... }@inputs:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
f {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.self.overlays.default
];
};
}
);
in
{
overlays.default = final: prev: {
rustToolchain =
with inputs.fenix.packages.${prev.stdenv.hostPlatform.system};
combine (
with complete;
[
clippy
rustc
cargo
rustfmt
rust-src
]
);
blaster-x-g6-control = prev.callPackage ./nix/package.nix {
rustPlatform = prev.makeRustPlatform {
cargo = final.rustToolchain;
rustc = final.rustToolchain;
};
};
};
packages = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.blaster-x-g6-control;
blaster-x-g6-control = pkgs.blaster-x-g6-control;
# Debian package output
deb = pkgs.callPackage ./nix/deb.nix {
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.rustToolchain;
rustc = pkgs.rustToolchain;
};
};
}
);
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
udev
rustToolchain
openssl
pkg-config
libusb1
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
bacon
evcxr
# wayland support
wayland
libxkbcommon
libGL
libglvnd
# python
(pkgs.python312.withPackages (
python-pkgs: with python-pkgs; [
pyusb
libusb1
hidapi
]
))
];
env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath [ pkgs.udev pkgs.wayland pkgs.libxkbcommon pkgs.libGL pkgs.libglvnd pkgs.openssl pkgs.libusb1]}";
};
};
}
);
# NixOS module for easy installation
nixosModules.default = { config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.soundblaster-g6;
in
{
options.hardware.soundblaster-g6 = {
enable = mkEnableOption "Sound Blaster X G6 support";
commandName = mkOption {
type = types.str;
default = "linuxblaster";
description = "The command name to make available in the system path.";
};
};
config = mkIf cfg.enable {
# Install the control application
environment.systemPackages = [
self.packages.${pkgs.system}.blaster-x-g6-control
(pkgs.runCommand "linuxblaster-symlink" {} ''
mkdir -p $out/bin
ln -s ${self.packages.${pkgs.system}.blaster-x-g6-control}/bin/blaster_x_g6_control $out/bin/${cfg.commandName}
'')
];
# Add udev rules for device access
services.udev.extraRules = ''
# Creative Sound Blaster X G6
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="041e", ATTRS{idProduct}=="3256", MODE="0666"
'';
};
};
};
}