This repository has been archived by the owner on Oct 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
97 lines (80 loc) · 2.58 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
description = "A crabby rewrite of `pass`, the standard unix password manager";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
naersk = { url = "github:nmattia/naersk"; };
};
outputs = { self, nixpkgs, naersk }:
let
systems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems
(system: f {
inherit system;
pkgs = nixpkgsFor.${system};
});
# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems
({ system, ... }: import nixpkgs { inherit system; });
deps = pkgs: with pkgs; {
nativeBuildInputs = [
pkg-config
git # for build script to retrieve git hash and add to version info
gpgme # `gpgme-config` required by crate gpgme
installShellFiles
libgpgerror # `gpg-error-config` required by crate libgpg-error-sys
];
buildInputs = [
gpgme
libgit2
libgpgerror
];
};
# A bit hacky, but whatever. At least `nix flake check` doesn't complain
# about this not being a package anymore.
passrs =
{ release ? true
, doCheck ? false
, pkgs
}:
let
inherit (pkgs.callPackage naersk { }) buildPackage;
version = self.shortRev or "dirty";
in
buildPackage {
pname = "passrs";
inherit version;
src = ./.;
PASSRS_REV = version;
RUST_BACKTRACE = 1;
inherit (deps pkgs) nativeBuildInputs buildInputs;
inherit release doCheck;
cargoTestOptions = opts: opts ++ [ "--" "--include-ignored" "-Z unstable-options" ];
overrideMain = { ... }: {
# NOTE: Completions require the gpg2 binary to be in path in order to complete
# keys for commands like `passrs init`
postInstall = ''
installShellCompletion completions/passrs.{fi,ba,z}sh
'';
};
};
in
{
defaultPackage = forAllSystems ({ system, pkgs, ... }:
self.packages.${system}.passrs);
packages = forAllSystems ({ system, pkgs, ... }: {
passrs = passrs {
inherit pkgs;
};
test = passrs {
inherit pkgs;
release = false;
doCheck = true;
};
});
devShell = forAllSystems ({ system, pkgs, ... }:
pkgs.stdenv.mkDerivation {
name = "passrs";
inherit (deps pkgs) buildInputs nativeBuildInputs;
});
};
}