Add jwt-tool

This commit is contained in:
bad 2021-12-01 00:11:05 +01:00
commit b7e9a9b356
3 changed files with 115 additions and 0 deletions

57
flake.lock Normal file
View file

@ -0,0 +1,57 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"jwt-tool": {
"flake": false,
"locked": {
"lastModified": 1638313307,
"narHash": "sha256-k92mXf7H/n+gkOyStFQ+EWPXE0f7odCqqAexxAUK2jM=",
"owner": "MaeIsBad",
"repo": "jwt_tool",
"rev": "d2c8b3b934f91ec5fefea460deb97be31401550c",
"type": "github"
},
"original": {
"owner": "MaeIsBad",
"repo": "jwt_tool",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1638268913,
"narHash": "sha256-AVatTvYxylGXdEgmF45vEO1onbKrlU6EqaOEaNF1TEY=",
"path": "/nix/store/fqaykkfjzcy4x3fz4k6jiss0vc28wldj-source",
"rev": "69caefdbc691850f37148ca0dd16dfd649d66fd9",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"jwt-tool": "jwt-tool",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

27
flake.nix Normal file
View file

@ -0,0 +1,27 @@
{
description = "A very basic flake";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
jwt-tool = {
url = "github:MaeIsBad/jwt_tool";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, jwt-tool }:
flake-utils.lib.eachDefaultSystem
(system:
let
nixpkgs = import self.inputs.nixpkgs { system = "x86_64-linux"; };
in
rec {
packages.jwt-tool = (import ./jwt-tool.nix { inherit nixpkgs jwt-tool; });
defaultPackage = packages.jwt-tool;
apps.jwt-tool = {
type = "app";
program = "${packages.jwt-tool}/bin/jwt_tool";
};
}
);
}

31
jwt-tool.nix Normal file
View file

@ -0,0 +1,31 @@
{ nixpkgs, jwt-tool }:
let
python = (nixpkgs.python3.withPackages (p: with p; [ termcolor pycryptodomex requests ]));
in
nixpkgs.python3Packages.buildPythonApplication
{
format = "other";
pname = "jwt-tool";
version = "v2.2.4";
propagatedBuildInputs = [ python ];
src = jwt-tool.outPath;
buildPhase = ''
chmod +x jwt_tool.py
'';
postPatch = ''
patchShebangs .
'';
installPhase = ''
mkdir -p $out/bin
mv * $out
ln -s $out/jwt_tool.py $out/bin/jwt_tool
chmod +x $out/bin/jwt_tool
for i in "$out/bin/"*
do
wrapProgram "$i" --prefix PYTHONPATH : \
"$out/${python.sitePackages}" || \
exit 2
done
'';
}