Skip to content

Commit 993b462

Browse files
authored
Merge pull request #74 from es-sai-fi/main
2 parents d70273b + e7b541e commit 993b462

6 files changed

Lines changed: 246 additions & 0 deletions

File tree

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,131 @@ cd gitv
5858
cargo install --path .
5959
```
6060

61+
#### NixOS
62+
63+
<details>
64+
<summary>Flake</summary>
65+
66+
First add the repository to your inputs.
67+
68+
Point to main branch:
69+
70+
```nix
71+
inputs = {
72+
...
73+
gitv.url = "github:JayanAXHF/gitv";
74+
...
75+
};
76+
```
77+
78+
Point to a rev in main branch:
79+
80+
```nix
81+
inputs = {
82+
...
83+
gitv.url = "github:JayanAXHF/gitv/d70273b05c5e80b05446e4aa0847758e54435d62";
84+
...
85+
};
86+
```
87+
88+
Point to a tag:
89+
90+
```nix
91+
inputs = {
92+
...
93+
gitv.url = "github:JayanAXHF/gitv/refs/tags/gitv-tui-v0.3.2";
94+
...
95+
};
96+
```
97+
98+
Then your outputs should look something like this:
99+
100+
```nix
101+
outputs = {...} @ inputs: {
102+
# Don't forget to add nixpkgs to your inputs
103+
nixosConfigurations."nixos" = inputs.nixpkgs.lib.nixosSystem {
104+
...
105+
specialArgs = {inherit inputs;};
106+
modules = [
107+
./configuration.nix
108+
...
109+
];
110+
};
111+
};
112+
```
113+
114+
And finally, somewhere in your `configuration.nix`:
115+
116+
```nix
117+
{inputs, pkgs, ...}: {
118+
...
119+
environment.systemPackages = [
120+
inputs.gitv.packages.${pkgs.stdenv.hostPlatform.system}.default
121+
];
122+
...
123+
}
124+
```
125+
</details>
126+
127+
<details>
128+
<summary>Non-Flake</summary>
129+
130+
##### Pinning Tool
131+
132+
First add the pin using your pinning tool.
133+
134+
We are going to show examples using npins.
135+
136+
Point to a branch:
137+
138+
```bash
139+
npins add github JayanAXHF gitv -b main
140+
```
141+
142+
Point to a rev in main branch:
143+
144+
```bash
145+
npins add github JayanAXHF gitv -b main --at d70273b05c5e80b05446e4aa0847758e54435d62
146+
```
147+
148+
Point to a tag:
149+
150+
```bash
151+
npins add github JayanAXHF gitv --at gitv-tui-v0.3.2
152+
```
153+
154+
Or point to latest release:
155+
156+
```bash
157+
npins add github JayanAXHF gitv
158+
```
159+
160+
Then add the package to your `systemPackages`:
161+
162+
```nix
163+
let
164+
sources = import ./npins;
165+
in {
166+
environment.systemPackages = [
167+
(import sources.gitv)
168+
];
169+
}
170+
```
171+
172+
##### No Pinning Tool
173+
174+
```nix
175+
let
176+
rev = "d70273b05c5e80b05446e4aa0847758e54435d62";
177+
gitv = import (fetchTarball "https://github.com/JayanAXHF/gitv/archive/${rev}.tar.gz") {};
178+
in {
179+
environment.systemPackages = [
180+
gitv
181+
];
182+
}
183+
```
184+
</details>
185+
61186
### Usage
62187

63188
```
@@ -120,6 +245,9 @@ Contributions to `gitv` are welcome! If you have an idea for a new feature or ha
120245
> [!TIP]
121246
> 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`.
122247
248+
[!TIP]
249+
> 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`.
250+
123251
### License
124252

125253
`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.

default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{pkgs ? import <nixpkgs> {}}:
2+
pkgs.callPackage ./package.nix {}

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
4+
};
5+
6+
outputs = {nixpkgs, ...}: let
7+
supportedSystems = [
8+
"x86_64-linux"
9+
"aarch64-linux"
10+
"x86_64-darwin"
11+
"aarch64-darwin"
12+
];
13+
14+
forAllSystems = function:
15+
nixpkgs.lib.genAttrs
16+
supportedSystems
17+
(system: function nixpkgs.legacyPackages.${system});
18+
in {
19+
packages = forAllSystems (
20+
pkgs: let
21+
default = pkgs.callPackage ./package.nix {};
22+
in {
23+
inherit default;
24+
25+
debug = default.overrideAttrs (finalAttrs: _: {
26+
cargoBuildType = "debug";
27+
cargoCheckType = finalAttrs.cargoBuildType;
28+
});
29+
}
30+
);
31+
32+
devShells = forAllSystems (
33+
pkgs: {
34+
default = import ./shell.nix {inherit pkgs;};
35+
}
36+
);
37+
};
38+
}

package.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
lib,
3+
rustPlatform,
4+
}:
5+
rustPlatform.buildRustPackage (finalAttrs: {
6+
name = "gitv";
7+
8+
src = ./.;
9+
cargoLock = {
10+
lockFile = ./Cargo.lock;
11+
allowBuiltinFetchGit = true;
12+
};
13+
14+
meta = with lib; {
15+
description = "Terminal-based viewer for GitHub issues";
16+
homepage = "https://github.com/JayanAXHF/gitv";
17+
license = with lib.licenses; [mit unlicense];
18+
};
19+
})

shell.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{pkgs ? import <nixpkgs> {}}:
2+
with pkgs;
3+
mkShell {
4+
packages = [
5+
nil
6+
alejandra
7+
8+
rustc
9+
cargo
10+
clippy
11+
rustfmt
12+
rust-analyzer
13+
14+
typos
15+
];
16+
17+
env = {
18+
RUST_BACKTRACE = "full";
19+
};
20+
21+
shellHook = ''
22+
echo "Setting up pre-push hook..."
23+
24+
HOOK=".git/hooks/pre-push"
25+
26+
if [ ! -f "$HOOK" ]; then
27+
cp ./etc/pre-push.sh "$HOOK"
28+
chmod 755 "$HOOK"
29+
echo "Pre-push hook installed."
30+
fi
31+
'';
32+
}

0 commit comments

Comments
 (0)