Skip to content

Commit

Permalink
Add Nix packaging
Browse files Browse the repository at this point in the history
Co-authored-by: dvn <git@dvn.me>
  • Loading branch information
ehmry and dvn0 committed Apr 15, 2023
1 parent a9d4ad4 commit f6484e8
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ sign.keystore

# state files
*.state

# Nix build symlinks
result
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ pkgs ? import <nixpkgs> { } }: pkgs.callPackage (import ./katzen.nix { }) { }
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
description = "Katzenpost development flake";

outputs = { self, nixpkgs }:
let inherit (nixpkgs) lib;
in {

overlays.default = final: prev: {
katzen = final.callPackage (import ./katzen.nix {
src = self;
version = "unstable-${self.lastModifiedDate}";
}) { };
};

legacyPackages = lib.attrsets.mapAttrs (system: pkgs:
pkgs.appendOverlays (builtins.attrValues self.overlays)) {
inherit (nixpkgs.legacyPackages)
i686-linux x86_64-linux aarch64-linux;
};

packages = lib.attrsets.mapAttrs (system: pkgs: rec {
inherit (pkgs) katzen;
default = katzen;
}) self.legacyPackages;
};

}
61 changes: 61 additions & 0 deletions katzen.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{ src ? ./., version ? "unstable" }:
{ lib, buildGoModule, fetchFromGitHub, copyDesktopItems, makeDesktopItem
, pkg-config, librsvg, libGL, libX11, libXfixes, libxkbcommon, vulkan-headers
, wayland, xorg }:

buildGoModule rec {
pname = "katzen";
inherit src version;

vendorHash = "sha256-4/AteWLY9biTspcXcyzK1gNwzkQfFoNq89yJheswf4s=";
# This hash is may drift from the actual vendoring and break the build,
# see https://nixos.org/manual/nixpkgs/unstable/#ssec-language-go.

nativeBuildInputs = [ pkg-config copyDesktopItems librsvg ];
buildInputs = [
libGL
libX11
libXfixes
libxkbcommon
vulkan-headers
wayland
xorg.libXcursor
];

CGO_CFLAGS_ALLOW = "-DPARAMS=sphincs-shake-256f";

postInstall = ''
## Both of the configs are embedded in the binary; "without_tor" being the default.
## Another config may be specified by using '-f' flag.
install -D -t $out/share/ ./default_config_without_tor.toml
install -D -t $out/share/ ./default_config_with_tor.toml
install -D \
./assets/katzenpost_logo.svg \
$out/share/icons/hicolor/scalable/apps/${pname}.svg
mkdir -p $out/share/icons/hicolor/48x48/apps
rsvg-convert \
--output $out/share/icons/hicolor/48x48/apps/${pname}.png \
--width 48 --height 48 \
./assets/katzenpost_logo.svg
'';

desktopItems = [
(makeDesktopItem {
name = pname;
exec = pname;
icon = pname;
desktopName = "Katzen";
genericName = meta.description;
categories = [ "Chat" "Network" ];
})
];

meta = with lib; {
description = "Traffic analysis resistant messaging";
homepage = "https://katzenpost.mixnetworks.org/";
license = licenses.agpl3;
maintainers = with maintainers; [ ehmry ];
};
}

0 comments on commit f6484e8

Please sign in to comment.