mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-10-08 22:52:12 +02:00
feat(nix): add comprehensive nix flake
Co-authored-by: Eveeifyeve
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -28,3 +28,9 @@ __debug_bin*
|
|||||||
demo/output/*
|
demo/output/*
|
||||||
|
|
||||||
coverage.out
|
coverage.out
|
||||||
|
|
||||||
|
# Nix
|
||||||
|
result
|
||||||
|
result-*
|
||||||
|
.direnv
|
||||||
|
.envrc
|
||||||
|
@@ -60,6 +60,31 @@ To run lazygit from within the integrated terminal just go `go run main.go`
|
|||||||
|
|
||||||
This allows you to contribute to Lazygit without needing to install anything on your local machine. The Codespace has all the necessary tools and extensions pre-installed.
|
This allows you to contribute to Lazygit without needing to install anything on your local machine. The Codespace has all the necessary tools and extensions pre-installed.
|
||||||
|
|
||||||
|
## Using Nix for development
|
||||||
|
|
||||||
|
If you use Nix, you can leverage the included flake to set up a complete development environment with all necessary dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
This will drop you into a development shell that includes:
|
||||||
|
* Latest Go toolchain
|
||||||
|
* golangci-lint for code linting
|
||||||
|
* git and make
|
||||||
|
|
||||||
|
You can also build and run lazygit using nix:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Build lazygit
|
||||||
|
nix build
|
||||||
|
|
||||||
|
# Run lazygit directly
|
||||||
|
nix run
|
||||||
|
```
|
||||||
|
|
||||||
|
The nix flake supports multiple architectures (x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin) and provides a consistent development environment across different systems.
|
||||||
|
|
||||||
## Code of conduct
|
## Code of conduct
|
||||||
|
|
||||||
Please note by participating in this project, you agree to abide by the [code of conduct].
|
Please note by participating in this project, you agree to abide by the [code of conduct].
|
||||||
|
55
README.md
55
README.md
@@ -388,19 +388,64 @@ sudo zypper ar https://download.opensuse.org/repositories/devel:/languages:/go/$
|
|||||||
sudo zypper ref && sudo zypper in lazygit
|
sudo zypper ref && sudo zypper in lazygit
|
||||||
```
|
```
|
||||||
|
|
||||||
### NixOs
|
### NixOS
|
||||||
|
|
||||||
On NixOs lazygit is packaged with nix and distributed via nixpkgs.
|
#### Using lazygit from nixpkgs
|
||||||
You can try the lazygit without installing it with:
|
|
||||||
|
On NixOS, lazygit is packaged with nix and distributed via nixpkgs.
|
||||||
|
You can try lazygit without installing it with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix-shell -p lazygit
|
nix-shell -p lazygit
|
||||||
# or with flakes enabled
|
# or with flakes enabled
|
||||||
nix run nixpkgs#lazygit
|
nix run nixpkgs#lazygit
|
||||||
```
|
```
|
||||||
|
Or you can add lazygit to your `configuration.nix` using the `environment.systemPackages` option.
|
||||||
|
More details can be found via NixOS search [page](https://search.nixos.org/).
|
||||||
|
|
||||||
Or you can add lazygit to you `configuration.nix` using the `environment.systemPackages` option.
|
#### Using the official lazygit flake
|
||||||
More details can be found via NixOs search [page](https://search.nixos.org/).
|
|
||||||
|
This repository includes a nix flake that provides the latest development version and additional development tools:
|
||||||
|
|
||||||
|
**Run lazygit directly from the repository:**
|
||||||
|
```sh
|
||||||
|
nix run github:jesseduffield/lazygit
|
||||||
|
# or from a local clone
|
||||||
|
nix run .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Build lazygit from source:**
|
||||||
|
```sh
|
||||||
|
nix build github:jesseduffield/lazygit
|
||||||
|
# or from a local clone
|
||||||
|
nix build .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Development environment:**
|
||||||
|
For contributors, the flake provides a development shell with Go toolchain, development tools, and dependencies:
|
||||||
|
```sh
|
||||||
|
nix develop github:jesseduffield/lazygit
|
||||||
|
# or from a local clone
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
The development shell includes:
|
||||||
|
- Go toolchain
|
||||||
|
- git and make
|
||||||
|
- Proper environment variables for development
|
||||||
|
|
||||||
|
**Using in other flakes:**
|
||||||
|
The flake also provides an overlay for easy integration into other flake-based projects:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs.lazygit.url = "github:jesseduffield/lazygit";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, lazygit }: {
|
||||||
|
# Use the overlay
|
||||||
|
nixpkgs.overlays = [ lazygit.overlays.default ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Flox
|
### Flox
|
||||||
|
|
||||||
|
12
default.nix
Normal file
12
default.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
(import (
|
||||||
|
let
|
||||||
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
|
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||||
|
in
|
||||||
|
fetchTarball {
|
||||||
|
url =
|
||||||
|
lock.nodes.${nodeName}.locked.url
|
||||||
|
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
|
||||||
|
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||||
|
}
|
||||||
|
) { src = ./.; }).defaultNix
|
127
flake.lock
generated
Normal file
127
flake.lock
generated
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-compat": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733328505,
|
||||||
|
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||||
|
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||||
|
"revCount": 69,
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1754487366,
|
||||||
|
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1756217674,
|
||||||
|
"narHash": "sha256-TH1SfSP523QI7kcPiNtMAEuwZR3Jdz0MCDXPs7TS8uo=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "4e7667a90c167f7a81d906e5a75cba4ad8bee620",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-25.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1753579242,
|
||||||
|
"narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1754340878,
|
||||||
|
"narHash": "sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "cab778239e705082fe97bb4990e0d24c50924c04",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"systems": "systems",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1755934250,
|
||||||
|
"narHash": "sha256-CsDojnMgYsfshQw3t4zjRUkmMmUdZGthl16bXVWgRYU=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "74e1a52d5bd9430312f8d1b8b0354c92c17453e5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
125
flake.nix
Normal file
125
flake.nix
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
{
|
||||||
|
description = "A simple terminal UI for git commands";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
|
systems.url = "github:nix-systems/default";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||||
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
inputs@{ flake-parts, systems, ... }:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = import systems;
|
||||||
|
imports = [
|
||||||
|
inputs.treefmt-nix.flakeModule
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
goMod = builtins.readFile ./go.mod;
|
||||||
|
versionMatch = builtins.match ".*go[[:space:]]([0-9]+\\.[0-9]+)(\\.[0-9]+)?.*" goMod;
|
||||||
|
|
||||||
|
goVersion =
|
||||||
|
if versionMatch != null then
|
||||||
|
builtins.head versionMatch
|
||||||
|
else
|
||||||
|
throw "Could not extract Go version from go.mod";
|
||||||
|
|
||||||
|
goOverlay = final: prev: {
|
||||||
|
go = prev."go_${builtins.replaceStrings [ "." ] [ "_" ] goVersion}";
|
||||||
|
};
|
||||||
|
|
||||||
|
lazygit = pkgs.buildGoModule rec {
|
||||||
|
pname = "lazygit";
|
||||||
|
version = "dev";
|
||||||
|
|
||||||
|
gitCommit = inputs.self.rev or inputs.self.dirtyRev or "dev";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
vendorHash = null;
|
||||||
|
|
||||||
|
# Disable integration tests that require specific environment
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
git
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
buildInputs = [ pkgs.git ];
|
||||||
|
|
||||||
|
ldflags = [
|
||||||
|
"-s"
|
||||||
|
"-w"
|
||||||
|
"-X main.commit=${gitCommit}"
|
||||||
|
"-X main.version=${version}"
|
||||||
|
"-X main.buildSource=nix"
|
||||||
|
];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
wrapProgram $out/bin/lazygit \
|
||||||
|
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.git ]}
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "A simple terminal UI for git commands";
|
||||||
|
homepage = "https://github.com/jesseduffield/lazygit";
|
||||||
|
license = pkgs.lib.licenses.mit;
|
||||||
|
maintainers = [ "jesseduffield" ];
|
||||||
|
platforms = pkgs.lib.platforms.unix;
|
||||||
|
mainProgram = "lazygit";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
_module.args.pkgs = import inputs.nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ goOverlay ];
|
||||||
|
config = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = {
|
||||||
|
default = lazygit;
|
||||||
|
inherit lazygit;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
name = "lazygit-dev";
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# Go toolchain
|
||||||
|
go
|
||||||
|
gotools
|
||||||
|
|
||||||
|
# Development tools
|
||||||
|
git
|
||||||
|
gnumake
|
||||||
|
];
|
||||||
|
|
||||||
|
# Environment variables for development
|
||||||
|
CGO_ENABLED = "0";
|
||||||
|
};
|
||||||
|
|
||||||
|
treefmt = {
|
||||||
|
programs.nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler;
|
||||||
|
programs.nixfmt.package = pkgs.nixfmt-rfc-style;
|
||||||
|
programs.gofmt.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
checks.build = lazygit;
|
||||||
|
};
|
||||||
|
|
||||||
|
flake = {
|
||||||
|
overlays.default = final: prev: {
|
||||||
|
lazygit = inputs.self.packages.${final.system}.lazygit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
12
shell.nix
Normal file
12
shell.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
(import (
|
||||||
|
let
|
||||||
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
|
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||||
|
in
|
||||||
|
fetchTarball {
|
||||||
|
url =
|
||||||
|
lock.nodes.${nodeName}.locked.url
|
||||||
|
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
|
||||||
|
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||||
|
}
|
||||||
|
) { src = ./.; }).shellNix
|
Reference in New Issue
Block a user