Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

flake: add new build dependencies #75

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 54 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,65 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs = inputs @ {
self,
nixpkgs,
flake-utils,
}:
outputs =
inputs@{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
system:
let
pkgs = nixpkgs.legacyPackages.${system};
name = "razer-laptop-control";
in {
in
{
formatter = pkgs.nixfmt-rfc-style;

packages.default = pkgs.rustPlatform.buildRustPackage {
pname = name;
version = "0.2.0";

nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [dbus.dev hidapi systemd];
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [
dbus.dev
hidapi
systemd
glib
pango
gtk3
];

src = ./razer_control_gui;

postConfigure = ''
substituteInPlace src/device.rs --replace '/usr/share/razercontrol/laptops.json' '${./razer_control_gui/data/devices/laptops.json}'
'';

postBuild =
let
app = "razer-settings";
path = "$out/share/applications/${app}.desktop";
in
''
# Install .desktop file
mkdir -p $out/share/applications
cat > ${path} <<EOF
[Desktop Entry]
Name=Razer Settings
Exec=$out/bin/${app}
Type=Application
Categories=Utility;
EOF
chmod +x ${path}
'';

postInstall = ''
mkdir -p $out/lib/udev/rules.d
mkdir -p $out/libexec
mv $out/bin/daemon $out/libexec
cp ${./razer_control_gui/data/udev/99-hidraw-permissions.rules} $out/lib/udev/rules.d/99-hidraw-permissions.rules

'';

cargoLock = {
Expand All @@ -43,15 +74,18 @@
}
)
// {
nixosModules.default = {
config,
lib,
pkgs,
...
}:
with lib; let
nixosModules.default =
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.razer-laptop-control;
in {
in
{
options.services.razer-laptop-control = {
enable = mkEnableOption "Enables razer-laptop-control";
package = mkOption {
Expand All @@ -62,8 +96,8 @@

config = mkIf cfg.enable {
services.upower.enable = true;
environment.systemPackages = [cfg.package];
services.udev.packages = [cfg.package];
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];

systemd.user.services."razerdaemon" = {
description = "Razer laptop control daemon";
Expand All @@ -72,7 +106,7 @@
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p %h/.local/share/razercontrol";
ExecStart = "${cfg.package}/libexec/daemon";
};
wantedBy = ["default.target"];
wantedBy = [ "default.target" ];
};
};
};
Expand Down