Skip to content

Commit

Permalink
Add a nix Flake
Browse files Browse the repository at this point in the history
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
  • Loading branch information
doronbehar authored and wiktor-k committed Nov 20, 2023
1 parent 417b2fa commit 5679c01
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
60 changes: 60 additions & 0 deletions flake.lock

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

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
# See https://github.com/mhwombat/nix-for-numbskulls/blob/main/flakes.md
# for a brief overview of what each section in a flake should or can contain.

# TODO: Fix this to something better
description = "a very simple and friendly flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self
, nixpkgs
, flake-utils
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.python3
pkgs.python3.pkgs.virtualenv
pkgs.python3.pkgs.pip
];
};
};
packages = {
# Besides the `src` and `version` arguments, this package.nix could
# be copied as is to Nixpkgs'
# pkgs/development/python-modules/pysequoia/default.nix, and should be
# maintained in parallel to this local version of it.
pysequoia = pkgs.python3.pkgs.callPackage ./package.nix {
src = self;
# Get the version defined in pyproject.toml
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
};
};
}
);
}
59 changes: 59 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ lib
, buildPythonPackage
, src
, version
, pkg-config
, rustPlatform
, cargo
, rustc
, bzip2
, nettle
, openssl
, pcsclite
, stdenv
, darwin
, libiconv
}:

buildPythonPackage rec {
pname = "pysequoia";
inherit src version;
pyproject = true;

# This attribute is defined differently in Nixpkgs - using
# `rustPlatform.fetchCargoTarball`. Since we have a Cargo.lock file available
# here, we can use it instead.
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};

nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
cargo
rustc
];

buildInputs = [
bzip2
nettle
openssl
pcsclite
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
libiconv
];

pythonImportsCheck = [ "pysequoia" ];

meta = with lib; {
description = "This library provides OpenPGP facilities in Python through the Sequoia PGP library";
downloadPage = "https://codeberg.org/wiktor/pysequoia";
homepage = "https://sequoia-pgp.gitlab.io/pysequoia";
license = licenses.asl20;
maintainers = with maintainers; [ doronbehar ];
};
}

0 comments on commit 5679c01

Please sign in to comment.