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
128 changes: 128 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,131 @@ cd gitv
cargo install --path .
```

#### NixOS

<details>
<summary>Flake</summary>

First add the repository to your inputs.

Point to main branch:

```nix
inputs = {
...
gitv.url = "github:JayanAXHF/gitv";
...
};
```

Point to a rev in main branch:

```nix
inputs = {
...
gitv.url = "github:JayanAXHF/gitv/d70273b05c5e80b05446e4aa0847758e54435d62";
...
};
```

Point to a tag:

```nix
inputs = {
...
gitv.url = "github:JayanAXHF/gitv/refs/tags/gitv-tui-v0.3.2";
...
};
```

Then your outputs should look something like this:

```nix
outputs = {...} @ inputs: {
# Don't forget to add nixpkgs to your inputs
nixosConfigurations."nixos" = inputs.nixpkgs.lib.nixosSystem {
...
specialArgs = {inherit inputs;};
modules = [
./configuration.nix
...
];
};
};
```

And finally, somewhere in your `configuration.nix`:

```nix
{inputs, pkgs, ...}: {
...
environment.systemPackages = [
inputs.gitv.packages.${pkgs.stdenv.hostPlatform.system}.default
];
...
}
```
</details>

<details>
<summary>Non-Flake</summary>

##### Pinning Tool

First add the pin using your pinning tool.

We are going to show examples using npins.

Point to a branch:

```bash
npins add github JayanAXHF gitv -b main
```

Point to a rev in main branch:

```bash
npins add github JayanAXHF gitv -b main --at d70273b05c5e80b05446e4aa0847758e54435d62
```

Point to a tag:

```bash
npins add github JayanAXHF gitv --at gitv-tui-v0.3.2
```

Or point to latest release:

```bash
npins add github JayanAXHF gitv
```

Then add the package to your `systemPackages`:

```nix
let
sources = import ./npins;
in {
environment.systemPackages = [
(import sources.gitv)
];
}
```

##### No Pinning Tool

```nix
let
rev = "d70273b05c5e80b05446e4aa0847758e54435d62";
gitv = import (fetchTarball "https://github.com/JayanAXHF/gitv/archive/${rev}.tar.gz") {};
in {
environment.systemPackages = [
gitv
];
}
```
</details>

### Usage

```
Expand Down Expand Up @@ -120,6 +245,9 @@ Contributions to `gitv` are welcome! If you have an idea for a new feature or ha
> [!TIP]
> Run the `init.py` initialization script to set up your development environment. It installs a pre-push hook that runs `typos` and `clippy` to help maintain code quality and consistency. Ensure that you have the `typos-cli` installed and available in your PATH for the pre-push hook to work correctly. You can install it using `cargo install typos-cli`.

[!TIP]
> If you're using nix then you can use the provided devshell to get your development environment up and running, it also includes the pre-push hook provided. You can do so by executing `direnv allow` or `nix develop`.

### License

`gitv` is dual-licensed under the MIT License and the Unlicense, at your option. See the [MIT](./LICENSE-MIT) and [Unlicense](./UNLICENSE) for more information.
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.callPackage ./package.nix {}
27 changes: 27 additions & 0 deletions flake.lock

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

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = {nixpkgs, ...}: let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

forAllSystems = function:
nixpkgs.lib.genAttrs
supportedSystems
(system: function nixpkgs.legacyPackages.${system});
in {
packages = forAllSystems (
pkgs: let
default = pkgs.callPackage ./package.nix {};
in {
inherit default;

debug = default.overrideAttrs (finalAttrs: _: {
cargoBuildType = "debug";
cargoCheckType = finalAttrs.cargoBuildType;
});
}
);

devShells = forAllSystems (
pkgs: {
default = import ./shell.nix {inherit pkgs;};
}
);
};
}
19 changes: 19 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
lib,
rustPlatform,
}:
rustPlatform.buildRustPackage (finalAttrs: {
name = "gitv";

src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};

meta = with lib; {
description = "Terminal-based viewer for GitHub issues";
homepage = "https://github.com/JayanAXHF/gitv";
license = with lib.licenses; [mit unlicense];
};
})
32 changes: 32 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell {
packages = [
nil
alejandra

rustc
cargo
clippy
rustfmt
rust-analyzer

typos
];

env = {
RUST_BACKTRACE = "full";
};

shellHook = ''
echo "Setting up pre-push hook..."

HOOK=".git/hooks/pre-push"

if [ ! -f "$HOOK" ]; then
cp ./etc/pre-push.sh "$HOOK"
chmod 755 "$HOOK"
echo "Pre-push hook installed."
fi
'';
}