Skip to content
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Verify Nix lockfile is up to date
run: |
bun run nix:update-lock
if ! git diff --exit-code nix/bun.lock.nix; then
echo "::error::Nix lockfile is out of date. Please run 'bun run nix:update-lock' and commit the changes to nix/bun.lock.nix."
exit 1
fi
- name: Format check
run: bun run format:check

Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Verify Nix lockfile is up to date
run: |
bun run nix:update-lock
if ! git diff --exit-code nix/bun.lock.nix; then
echo "::error::Nix lockfile is out of date. Please run 'bun run nix:update-lock' and commit the changes to nix/bun.lock.nix."
exit 1
fi
- name: Format check
run: bun run format:check

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
.eslintcache
.cache
*.tsbuildinfo
.direnv/

# IntelliJ based IDEs
.idea
Expand All @@ -42,3 +43,4 @@ tmp
.pi/
autoresearch.jsonl
autoresearch.ideas.md
result
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Requirements:
- Node.js 18+
- Git

> Nix users can use `nix develop` or [direnv](https://direnv.net/) to enter a development shell.
Install dependencies:

```bash
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Requirements:
- macOS or Linux
- Git recommended for most workflows

> Nix users can use the `default` package exported in `flake.nix` instead. See [nix/README.md](./nix/README.md) for details.
## Quick start

```bash
Expand Down
26 changes: 13 additions & 13 deletions bun.lock

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

136 changes: 136 additions & 0 deletions flake.lock

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

63 changes: 63 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
description = "Dev Flake for Modem-dev's Hunk";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
bun2nix.url = "github:nix-community/bun2nix";
bun2nix.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
outputs = {
self,
nixpkgs,
bun2nix,
...
}: let
lib = nixpkgs.lib;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs supportedSystems;
in {
packages = forAllSystems (
system: let
pkgs = import nixpkgs {
inherit system;
};
in {
default = pkgs.callPackage ./nix/package.nix {
bun2nix = bun2nix.packages.${system}.default;
};
}
);

devShells = forAllSystems (
system: let
pkgs = import nixpkgs {
inherit system;
};
in {
default = pkgs.callPackage ./nix/devShell.nix {
bun2nix = bun2nix.packages.${system}.default;
};
}
);

homeManagerModules = {
hunk = import ./nix/home-manager.nix;
default = {pkgs, ...}: {
imports = [self.homeManagerModules.hunk];
programs.hunk.package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default;
};
};
};
}
55 changes: 55 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Installing using Nix

Nix users can install Hunk from source instead of using npm.

1. Add Hunk to your nix flake inputs like such:

```nix
{
inputs = {
hunk = {
url = "github:modem-dev/hunk";
inputs.nixpkgs.follows = "nixpkgs";
};
}
}
```

2. Use in NixOS `environment.systemPackages` or `home.packages`:

```nix
{
packages = [
inputs.hunk.packages.${pkgs.stdenv.hostPlatform.system}.default
]
}
```

## Home Manager

Hunk provides a Home Manager module to manage both the package and its configuration.

1. Add the module to your Home Manager configuration:

```nix
{
imports = [
inputs.hunk.homeManagerModules.default
];

programs.hunk = {
enable = true;
enableGitIntegration = true; # Optional: set hunk as default git pager
settings = {
theme = "graphite";
mode = "split";
line_numbers = true;
};
};
}
```

## Building using Nix

Simply run `nix build .#packages.{YOUR_SYSTEM}.default` where YOUR_SYSTEM is one of `x86_64-linux`, `x86_64-darwin`, `aarch64-linux` or `aarch64-darwin`. The resulting
Hunk binary will be `./result/bin/hunk`.
Loading