diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..c48b1fb8 --- /dev/null +++ b/default.nix @@ -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 diff --git a/flake.lock b/flake.lock index 6083ebd6..c1f974cb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,43 +1,91 @@ { "nodes": { - "flake-utils": { + "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": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "lastModified": 1765495779, + "narHash": "sha256-MhA7wmo/7uogLxiewwRRmIax70g6q1U/YemqTGoFHlM=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "5635c32d666a59ec9a55cab87e898889869f7b71", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1755078291, - "narHash": "sha256-Hu/gTDoi4uy6TAKISPHQusSMy8U6xUbLSDjKBYdhDIY=", + "lastModified": 1765472234, + "narHash": "sha256-9VvC20PJPsleGMewwcWYKGzDIyjckEz8uWmT0vCDYK0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3385ca0cd7e14c1a1eb80401fe011705ff012323", + "rev": "2fbfb1d73d239d2402a8fe03963e37aab15abe8b", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.05", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" } }, "systems": { @@ -54,6 +102,24 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1762938485, + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 6485e4ed..eb297347 100644 --- a/flake.nix +++ b/flake.nix @@ -2,137 +2,98 @@ description = "The lazier way to manage everything docker"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; - flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + 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@{ self, - nixpkgs, - flake-utils, + flake-parts, + systems, + ... }: - let - supportedSystems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" + flake-parts.lib.mkFlake { inherit inputs; } { + systems = import systems; + imports = [ + inputs.treefmt-nix.flakeModule ]; - gitCommit = self.rev or self.dirtyRev or "dev"; - version = "0.24.1"; + perSystem = + { + self', + pkgs, + system, + ... + }: + let + lazydocker = pkgs.buildGoModule rec { + pname = "lazydocker"; + version = "dev"; - in - flake-utils.lib.eachSystem supportedSystems ( - system: - let - pkgs = import nixpkgs { inherit system; }; + gitCommit = inputs.self.rev or inputs.self.dirtyRev or "dev"; - lazydocker = pkgs.buildGoModule rec { - pname = "lazydocker"; - inherit version; + src = ./.; + vendorHash = null; - src = ./.; + # Disable integration tests that require specific environment + doCheck = false; - vendorHash = null; + ldflags = [ + "-s" + "-w" + "-X main.commit=${gitCommit}" + "-X main.version=${version}" + "-X main.buildSource=nix" + ]; - # 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"; + meta = { + description = "The lazier way to manage everything docker"; + homepage = "https://github.com/jesseduffield/lazydocker"; + license = pkgs.lib.licenses.mit; + maintainers = [ "jesseduffield" ]; + platforms = pkgs.lib.platforms.unix; + mainProgram = "lazydocker"; + }; }; - }; - - in - { - packages = { - default = lazydocker; - inherit lazydocker; - }; - - apps = { - default = flake-utils.lib.mkApp { - drv = lazydocker; - name = "lazydocker"; + in + { + packages = { + default = lazydocker; + inherit lazydocker; }; - lazydocker = flake-utils.lib.mkApp { - drv = lazydocker; - name = "lazydocker"; + + devShells.default = pkgs.mkShell { + name = "lazydocker-dev"; + + buildInputs = with pkgs; [ + # Go toolchain + go + gotools + + 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 = 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"; + flake = { + overlays.default = final: prev: { + lazydocker = inputs.self.packages.${final.system}.lazydocker; }; - - # 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; }; } diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..459e1526 --- /dev/null +++ b/shell.nix @@ -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