Skip to content
Merged
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
16 changes: 16 additions & 0 deletions .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "CI Nix"
on:
pull_request:
push:

jobs:
check:
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- run: nix develop -c rustc --version
- run: nix build
- run: nix run . -- --help
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ dist/

# Hatch
_version.py

# Nix
result
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,24 @@ cargo build
./target/debug/qmk_hid
```

### With Nix Flakes

Pre-requisites: Nix with flakes and nix command enabled.

```sh
# Build
nix build

# Build and run command
nix run

# Build and enter shell with command
nix shell

# Enter shell with cargo and dependencies
nix develop
```

## Running on Linux

To avoid needing root privileges to access the keyboard please follow the
Expand Down
143 changes: 143 additions & 0 deletions flake.lock

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

45 changes: 45 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, flake-utils, naersk, nixpkgs, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};

toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};

in {
# For `nix build` & `nix run`:
packages.default = naersk'.buildPackage {
src = ./.;
doCheck = false;
buildInputs = [ pkgs.systemd ];
nativeBuildInputs = [ pkgs.pkg-config ];
};

# For `nix develop` (optional, can be skipped):
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.systemd ];
nativeBuildInputs = [ toolchain pkgs.pkg-config ];
};
}
);
}
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default
Loading