diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..fcf1885 --- /dev/null +++ b/default.nix @@ -0,0 +1,23 @@ +{ + lib, + rustPlatform, + ... +}: let + pname = "batmon"; + version = "unstable-2024-01-08"; +in + rustPlatform.buildRustPackage { + inherit pname version; + + src = lib.cleanSource ./.; + cargoHash = "sha256-d9wWr17BnlRwa3CLcfDeby60a2BPwpBy1xjY6oTgyG0="; + + meta = { + description = "Nananananananana batmon"; + homepage = "https://github.com/NotAShelf/batmon.git"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [NotAShelf]; + mainProgram = "batmon"; + platforms = lib.platforms.linux; + }; + } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7c737b0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1704796538, + "narHash": "sha256-uRMWOijfPGHzLXMqiYGoAitkq1beLfg2JAmGLdTjmvQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "792a7ddec9e0fe05aed934160eb75f1a821eb69b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..21b4b61 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + description = "Batmon - battery monitor service"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + pkgsForEach = nixpkgs.legacyPackages; + in { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./default.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./shell.nix {}; + }); + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..8150363 --- /dev/null +++ b/shell.nix @@ -0,0 +1,20 @@ +{ + callPackage, + rust-analyzer, + rustfmt, + clippy, + cargo, +}: let + mainPkg = callPackage ./default.nix {}; +in + mainPkg.overrideAttrs (oa: { + nativeBuildInputs = + [ + # Additional rust tooling + rust-analyzer + rustfmt + clippy + cargo + ] + ++ (oa.nativeBuildInputs or []); + })