Skip to content

Commit

Permalink
📦 Added a custome package knock
Browse files Browse the repository at this point in the history
  • Loading branch information
theobori committed Jan 7, 2025
1 parent 5fa10a3 commit 3f412bd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/home/cli/programs/knock/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
config,
lib,
pkgs,
namespace,
...
}:
let
inherit (lib) mkIf;
inherit (lib.${namespace}) mkBoolOpt;

cfg = config.${namespace}.cli.programs.knock;
in
{
options.${namespace}.cli.programs.knock = {
enable = mkBoolOpt false "Whether or not to enable knock.";
};

config = mkIf cfg.enable { home.packages = [ pkgs.${namespace}.knock ]; };
}
1 change: 1 addition & 0 deletions modules/home/roles/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ in
file-tools = enabled;
xclip = enabled;
manix = enabled;
knock = enabled;
};
};

Expand Down
38 changes: 38 additions & 0 deletions packages/knock/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
lib,
stdenv,
fetchFromGitHub,
pkg-config,
libpcap,
autoreconfHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "knock";
version = "0.8";

src = fetchFromGitHub {
owner = "jvinet";
repo = "knock";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-GOg6wovyr6J5qHm5EsOxrposFtwwx/FyJs7g0dagFmk=";
};

nativeBuildInputs = [
autoreconfHook
pkg-config
];

buildInputs = [ libpcap ];

patches = [ ./makefile.patch ];

meta = {
description = "A port-knocking implementation";
homepage = "https://github.com/jvinet/knock";
changelog = "https://github.com/jvinet/knock/releases";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ theobori ];
mainProgram = "knock";
platforms = lib.platforms.unix;
};
})
20 changes: 20 additions & 0 deletions packages/knock/makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/Makefile.am b/Makefile.am
index c5b15ab..9f83379 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,14 +5,10 @@ bin_PROGRAMS = knock
man_MANS = doc/knock.1

if BUILD_KNOCKD
-sbin_PROGRAMS = knockd
-dist_sbin_SCRIPTS = src/knock_helper_ipt.sh
+bin_PROGRAMS += knockd
man_MANS += doc/knockd.1
-sysconf_DATA = knockd.conf
endif

-dist_doc_DATA = README.md TODO ChangeLog COPYING
-
knock_SOURCES = src/knock.c
knockd_SOURCES = src/knockd.c src/list.c src/list.h src/knock_helper_ipt.sh

0 comments on commit 3f412bd

Please sign in to comment.