From de580749e2852b5e6e2c3e3eba6613a48c40adbb Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Sat, 22 Jan 2022 20:10:44 -0800 Subject: Add Nix flake --- .gitignore | 3 +++ Makefile | 6 ++++-- flake.lock | 40 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4e1c8a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.envrc +/result +/.direnv/ diff --git a/Makefile b/Makefile index 88ed5f4..999a677 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,8 @@ lint: $(MAKE) -C test lint test: - $(MAKE) -C test + $(MAKE) -C test all -.PHONY: install uninstall lint test +check: lint test + +.PHONY: install uninstall lint test check diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..18ef0a5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1642281915, + "narHash": "sha256-jcMsXmmO1knyf99o242A+2cy1A0eKa9afly0cwBknPA=", + "path": "/nix/store/1q3bx2vjp4afq1wglhxgva9rhs69k8ri-source", + "rev": "d5dae6569ea9952f1ae4e727946d93a71c507821", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3fb9ad2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "A pass extension for managing one-time-password (OTP) tokens"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; in + { + defaultPackage = with pkgs; stdenv.mkDerivation { + pname = "pass-otp"; + version = "unstable"; + src = ./.; + + buildInputs = [ oathToolkit ]; + + checkInputs = [ + bash + expect + git + gnumake + gnupg + pass + shellcheck + which + ]; + + dontBuild = true; + doCheck = true; + + patchPhase = '' + sed -i -e 's|OATH=\$(which oathtool)|OATH=${oathToolkit}/bin/oathtool|' otp.bash + ''; + + checkPhase = '' + make SHELL=$SHELL check + ''; + + installFlags = [ + "PREFIX=$(out)" + "BASHCOMPDIR=$(out)/share/bash-completions/completions" + ]; + + meta = with lib; { + description = "A pass extension for managing one-time-password (OTP) tokens"; + homepage = "https://github.com/tadfisher/pass-otp"; + license = licenses.gpl3; + maintainers = with maintainers; [ tadfisher ]; + platforms = platforms.unix; + }; + }; + + checks.pass-otp = self.defaultPackage.${system}; + } + ); +} -- cgit v1.2.3