diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..35703c8 --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +{ buildGoModule, libpcap }: +buildGoModule { + name = "gont"; + src = ./.; + vendorHash = "sha256-9/TPK8MD1lA9s3jhKmHweY7quw383kHgrcL2XLyuQ54="; + buildInputs = [ libpcap ]; + doCheck = false; +} diff --git a/flake.lock b/flake.lock index 5e9fe1f..90b5b72 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716137900, - "narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=", + "lastModified": 1718318537, + "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1", + "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ace243d..698f612 100644 --- a/flake.nix +++ b/flake.nix @@ -17,31 +17,62 @@ flake-utils.lib.eachDefaultSystem ( system: let - pkgs = nixpkgs.legacyPackages.${system}; - in - rec { - packages.gont = pkgs.buildGoModule { - name = "gont"; - src = ./.; - vendorHash = "sha256-QOh1jBR7FL/fKFmJv7wGxuCghRLR3DV/0TzXd+bUFP0="; - buildInputs = with pkgs; [ libpcap ]; - doCheck = false; + pkgs = import nixpkgs { + inherit system; + inherit overlays; }; - devShell = pkgs.mkShell { - packages = with pkgs; [ - golangci-lint - reuse - traceroute - gnumake - tshark - packages.gont - ]; - - inputsFrom = [ packages.gont ]; + overlay = final: prev: { gont = final.callPackage ./default.nix { }; }; + overlays = [ overlay ]; + + luaPkgs = { + lua-struct = pkgs.lua.pkgs.buildLuarocksPackage { + pname = "lua-struct"; + version = "0.9.2-1"; + + src = pkgs.fetchFromGitHub { + owner = "iryont"; + repo = "lua-struct"; + rev = "0.9.2-1"; + hash = "sha256-tyZU+Cm/f3urG3A5nBFC2NZ9nwtWh1yD4Oj0MHRtDlI="; + }; + }; }; + in + { + inherit overlays; + + packages.default = pkgs.gont; + + devShell = + let + tshark = pkgs.tshark.overrideAttrs ( + final: prev: { + # Make sure we can load our own Lua dissector plugin + # by Wiresharks Lua interpreter when tests are executed by root + postFixup = '' + echo "run_user_scripts_when_superuser = true" >> $out/lib/wireshark/plugins/init.lua + ''; + } + ); + in + pkgs.mkShell { + packages = with pkgs // luaPkgs; [ + golangci-lint + reuse + traceroute + gnumake + tshark + gont + lua-struct + ]; + + inputsFrom = with pkgs; [ gont ]; + + hardeningDisable = [ "fortify" ]; + }; - formatter = nixpkgs.nixfmt-rfc-style; + formatter = pkgs.nixfmt-rfc-style; } ); }