Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nix flake #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -109,8 +117,6 @@ with the primary (public) repository being
[GitHub](https://github.com/krayon/ratslap)
.



----
## What's New? ##

Expand Down
44 changes: 44 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ pkgs ? import <nixpkgs> { }
}:

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
'';
}
42 changes: 42 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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}";
};
}
);
}