diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index b9f700a9..f092463e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ TODO.md Lazydocker.code-workspace .vscode .idea + +# Ignore build outputs from performing a nix-build or `nix build` command +result +result-* + +# Ignore automatically generated direnv output +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..6083ebd6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1755078291, + "narHash": "sha256-Hu/gTDoi4uy6TAKISPHQusSMy8U6xUbLSDjKBYdhDIY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3385ca0cd7e14c1a1eb80401fe011705ff012323", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..6485e4ed --- /dev/null +++ b/flake.nix @@ -0,0 +1,138 @@ +{ + description = "The lazier way to manage everything docker"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + gitCommit = self.rev or self.dirtyRev or "dev"; + version = "0.24.1"; + + in + flake-utils.lib.eachSystem supportedSystems ( + system: + let + pkgs = import nixpkgs { inherit system; }; + + lazydocker = pkgs.buildGoModule rec { + pname = "lazydocker"; + inherit version; + + src = ./.; + + vendorHash = null; + + # Disable integration tests that require specific environment + doCheck = false; + + nativeBuildInputs = with pkgs; [ git ]; + + buildInputs = with pkgs; [ git ]; + + ldflags = [ + "-s" + "-w" + "-X main.commit=${gitCommit}" + "-X main.version=${version}" + "-X main.buildSource=nix" + ]; + + meta = with pkgs.lib; { + description = "The lazier way to manage everything docker"; + homepage = "https://github.com/jesseduffield/lazydocker"; + license = licenses.mit; + maintainers = [ "jesseduffield" ]; + platforms = platforms.unix; + mainProgram = "lazydocker"; + }; + }; + + in + { + packages = { + default = lazydocker; + inherit lazydocker; + }; + + apps = { + default = flake-utils.lib.mkApp { + drv = lazydocker; + name = "lazydocker"; + }; + lazydocker = flake-utils.lib.mkApp { + drv = lazydocker; + name = "lazydocker"; + }; + }; + + devShells.default = pkgs.mkShell { + name = "lazydocker-dev"; + + buildInputs = with pkgs; [ + # Go toolchain + go_1_24 + gotools + golangci-lint + + # Development tools + git + gnumake + ]; + + shellHook = '' + echo "Lazydocker development environment" + echo "Go version: $(go version)" + echo "Git version: $(git --version)" + echo "" + ''; + + # Environment variables for development + CGO_ENABLED = "0"; + }; + + # Formatting check + formatter = pkgs.nixpkgs-fmt; + + # Development checks + checks = { + # Ensure the package builds + build = lazydocker; + + # Format check + format = + pkgs.runCommand "check-format" + { + buildInputs = [ pkgs.nixpkgs-fmt ]; + } + '' + nixpkgs-fmt --check ${./.} + touch $out + ''; + }; + } + ) + // { + # Global overlay for other flakes to use + overlays.default = final: prev: { + lazydocker = self.packages.${final.system}.lazydocker; + }; + + # CI/CD support + hydraJobs = self.packages; + }; +}