summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorYves Fischer <yvesf+git@xapek.org>2022-08-25 23:35:20 +0200
committerYves Fischer <yvesf+git@xapek.org>2022-08-29 18:24:17 +0200
commitb96f94887953deeb6e5888bdb7114315016147e7 (patch)
treecbb8d2b347ccff4c7be33e08498442e3b85cbce5 /flake.nix
parentefc84d128aa88a49516abf3e593ea41753f57729 (diff)
downloadbatteriewarner-master.tar.gz
batteriewarner-master.zip
simplify nix build configHEADmaster
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix37
1 files changed, 32 insertions, 5 deletions
diff --git a/flake.nix b/flake.nix
index 87e4b9c..c187dd9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,10 +1,37 @@
{
- inputs.nixpkgs.url = "nixpkgs/nixos-20.09";
- outputs = { self, nixpkgs }:
- with import nixpkgs { system = "x86_64-linux"; };
+ outputs = { ... }:
+ let
+ batteriewarner = { lib, rustPlatform, makeWrapper }:
+ rustPlatform.buildRustPackage rec {
+ name = "batteriewarner-${version}";
+ version = "2022-08-25";
+ src = ./.;
+ cargoLock.lockFile = ./Cargo.lock;
+ buildInputs = [ makeWrapper ];
+ meta = {
+ description = "Display low battery status using the power led of Thinkpads X-series";
+ homepage = https://github.com/yvesf/batteriewarner;
+ platforms = lib.platforms.all;
+ };
+ };
+ in
{
- defaultPackage.x86_64-linux = callPackage ./. { };
- nixosModule = { config }: { imports = [ ./module.nix ]; };
+ nixosModule = { config, lib, pkgs, ... }:
+ let
+ package = pkgs.callPackage batteriewarner { };
+ cfg = config.services.batteriewarner;
+ in
+ {
+ options.services.batteriewarner.enable = lib.mkEnableOption "Batteriewarner";
+ config = lib.mkIf cfg.enable {
+ systemd.services.batteriewarner = {
+ enable = true;
+ description = "Batteriewarner";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig.ExecStart = "${package}/bin/batteriewarner";
+ };
+ };
+ };
};
}