summaryrefslogtreecommitdiff
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
parentefc84d128aa88a49516abf3e593ea41753f57729 (diff)
downloadbatteriewarner-b96f94887953deeb6e5888bdb7114315016147e7.tar.gz
batteriewarner-b96f94887953deeb6e5888bdb7114315016147e7.zip
simplify nix build configHEADmaster
-rw-r--r--default.nix21
-rw-r--r--flake.lock21
-rw-r--r--flake.nix37
-rw-r--r--module.nix21
4 files changed, 33 insertions, 67 deletions
diff --git a/default.nix b/default.nix
deleted file mode 100644
index a1c5718..0000000
--- a/default.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-{ 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;
- };
-}
-
diff --git a/flake.lock b/flake.lock
index 8ed578a..5999137 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,25 +1,6 @@
{
"nodes": {
- "nixpkgs": {
- "locked": {
- "lastModified": 1618358082,
- "narHash": "sha256-4vyEiTcCk7hRigwcRqDAF86YQbUzALUNxyH8SLG4oeo=",
- "owner": "NixOS",
- "repo": "nixpkgs",
- "rev": "dec334fa196a4aeedb1b60d8f7d61aa00d327499",
- "type": "github"
- },
- "original": {
- "id": "nixpkgs",
- "ref": "nixos-20.09",
- "type": "indirect"
- }
- },
- "root": {
- "inputs": {
- "nixpkgs": "nixpkgs"
- }
- }
+ "root": {}
},
"root": "root",
"version": 7
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";
+ };
+ };
+ };
};
}
diff --git a/module.nix b/module.nix
deleted file mode 100644
index c08a64a..0000000
--- a/module.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
- package = pkgs.callPackage ./. { };
- cfg = config.programs.batteriewarner;
-in
-{
- 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";
- };
- };
- };
-}
-