diff --git a/README.md b/README.md index 5f29f9f..ac9c5d4 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ please see [CONTRIBUTING](CONTRIBUTING.md) . ---- ## Availability ## +You can download, build, and run *RatSlap* in one command using the nix package manager. + +``` +nix run github:zebreus/ratslap +``` + +You can also use `nix develop .` to get a shell with all required dependencies. + ### { BACKWARDS COMPATIBILITY WARNING FOR PRE-0.4.0 { ### The default branch has changed from `master` to `main`. If you are building from @@ -109,8 +117,6 @@ with the primary (public) repository being [GitHub](https://github.com/krayon/ratslap) . - - ---- ## What's New? ## diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7ad2214 --- /dev/null +++ b/default.nix @@ -0,0 +1,44 @@ +{ pkgs ? import { } +}: + +with pkgs; +stdenv.mkDerivation +rec { + pname = "ratslap"; + version = "0.4.1"; + + src = ./.; + + nativeBuildInputs = [ + pkg-config + installShellFiles + git + ]; + + buildInputs = [ + libusb + ]; + + buildPhase = '' + make \ + -W gitup \ + VDIRTY="" \ + BUILD_DATE="`git show -s --date=format:'%Y-%m-%d %H:%M:%S%z' --format=%cd`" \ + BUILD_MONTH="`git show -s --date=format:'%B' --format=%cd`" \ + BUILD_YEAR="`git show -s --date=format:'%Y' --format=%cd`" \ + manpage.1 \ + ${pname} + + # MAJVER="${version}" \ + # APPBRANCH="main" \ + # BINNAME="${pname}" \ + ''; + + installPhase = '' + mkdir -p $out/bin + cp ratslap $out/bin + + mv manpage.1 ${pname}.1 + installManPage ${pname}.1 + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8266de9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1659446231, + "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6424e08 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + description = "Configure G300 and G300s Logitech mice"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-21.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + rec { + name = "ratslap"; + packages.default = (with nixpkgs.legacyPackages.${system}; + stdenv.mkDerivation { + name = name; + src = ./.; + + nativeBuildInputs = [ + pkg-config + installShellFiles + git + which + ctags + python310Packages.markdown + ]; + + buildInputs = [ + libusb + ]; + + buildPhase = '' + REV="${self."rev" or "dirty-worktree"}" + APPVER="${builtins.substring 0 8 (self."shortRev" or "dirty")}-flake" + TIME="@${toString self.lastModified}" + + make \ + -W gitup \ + VDIRTY="" \ + APPBRANCH="" \ + MAJVER="" \ + APPVER="$APPVER" \ + BUILD_COMMIT="$REV" \ + BINNAME="${name}" \ + BUILD_DATE="`date --date=$TIME +'%Y-%m-%d %H:%M:%S%z'`" \ + BUILD_MONTH="`date --date=$TIME +'%B'`" \ + BUILD_YEAR="`date --date=$TIME +'%Y'`" \ + manpage.1 \ + ${name} + ''; + + installPhase = '' + mkdir -p $out/bin + cp ${name} $out/bin + + mv manpage.1 ${name}.1 + installManPage ${name}.1 + ''; + }); + + apps.default = flake-utils.lib.mkApp { + drv = packages.default; + exePath = "/bin/${name}"; + }; + } + ); +}