diff options
author | Yves Fischer <yvesf+git@xapek.org> | 2021-02-24 11:04:40 +0100 |
---|---|---|
committer | Yves Fischer <yvesf+git@xapek.org> | 2021-02-24 11:04:40 +0100 |
commit | ec601443cfb26a6540f9459a5b741ecfd3c96f11 (patch) | |
tree | fa337ab76a6f09fe19d220d81343a350a7bb69a5 | |
parent | 6c3865eae8dd5e3999a66fdd2ddb70a893e22e7d (diff) | |
download | batteriewarner-ec601443cfb26a6540f9459a5b741ecfd3c96f11.tar.gz batteriewarner-ec601443cfb26a6540f9459a5b741ecfd3c96f11.zip |
fix nix packaging
-rw-r--r-- | default.nix | 21 | ||||
-rw-r--r-- | module.nix | 52 |
2 files changed, 36 insertions, 37 deletions
diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..6d329d8 --- /dev/null +++ b/default.nix @@ -0,0 +1,21 @@ +{ pkgs ? (import <nixpkgs> {}) }: +let + rustPlatform = pkgs.rustPlatform; + makeWrapper = pkgs.makeWrapper; +in + rustPlatform.buildRustPackage rec { + name = "batteriewarner-${version}"; + version = "2017-09-15"; + src = ./.; + + cargoSha256 = "sha256:1rf1sckjpjwdvllx3aapw646wl522j9cn7zx4bah805d6ak9plls"; + + buildInputs = [ makeWrapper ]; + + meta = { + description = "Display low battery status using the power led of Thinkpads X-series"; + homepage = https://github.com/yvesf/batteriewarner; + platforms = pkgs.lib.platforms.all; + }; + } + @@ -1,43 +1,21 @@ { config, lib, pkgs, ... }: let - rustPlatform = pkgs.rustPlatform; - makeWrapper = pkgs.makeWrapper; - batteriewarner = rustPlatform.buildRustPackage rec { - name = "batteriewarner-${version}"; - version = "2017-09-15"; - src = ./.; - - doCheck = false; - - cargoSha256 = "sha256:0jacm96l1gw9nxwavqi1x4669cg6lzy9hr18zjpwlcyb3qkw9z7f"; - - buildInputs = [ makeWrapper ]; - - RUST_SRC_PATH = rustPlatform.rustcSrc; - - installPhase = '' - mkdir -p $out/bin - cp -p target/release/batteriewarner $out/bin/ - wrapProgram $out/bin/batteriewarner --set RUST_SRC_PATH "$RUST_SRC_PATH" - ''; - - meta = with lib; { - description = "Display low battery status using the power led of Thinkpads X-series"; - homepage = https://github.com/yvesf/batteriewarner; - platforms = platforms.all; - }; - }; + package = pkgs.callPackage ./. {}; + cfg = config.programs.batteriewarner; in -{ - config = { - systemd.services.batteriewarner = { - enable = true; - description = "Batteriewarner"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - ExecStart = "${batteriewarner}/bin/batteriewarner"; - }; + { + options.programs.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"; }; + }; }; -} + } |