-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
139 lines (127 loc) · 3.91 KB
/
Copy pathflake.nix
File metadata and controls
139 lines (127 loc) · 3.91 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
description = "Himitsu — age-based secrets management with transport-agnostic sharing";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt.url = "github:numtide/treefmt-nix";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
};
outputs =
inputs@{
self,
nixpkgs,
flake-utils,
treefmt,
flake-parts,
}:
flake-parts.lib.mkFlake { inherit inputs; } (
{
config,
...
}:
{
systems = flake-utils.lib.defaultSystems;
imports = [
treefmt.flakeModule
];
perSystem =
{
self',
pkgs,
system,
...
}:
{
# _module.args.pkgs = import inputs.nixpkgs { inherit system; };
treefmt = {
programs.rustfmt.enable = true;
settings.formatter.rustfmt.options = pkgs.lib.mkForce [
"--config"
"skip_children=true"
"--edition"
"2024"
];
};
packages.himitsu = pkgs.rustPlatform.buildRustPackage {
pname = "himitsu";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [
pkgs.git
pkgs.protobuf
];
meta = with pkgs.lib; {
description = "Age-based secrets management with transport-agnostic sharing";
license = licenses.mit;
platforms = platforms.unix;
};
};
packages.default = self'.packages.himitsu;
# ── Helper: emit the raw age secret key from the local keyring ─
packages.age-key-cmd = pkgs.writeShellScriptBin "himitsu-age-key-cmd" ''
HIMITSU_HOME="''${HIMITSU_HOME:-$HOME/.himitsu}"
KEY_FILE="$HIMITSU_HOME/keys/age.txt"
if [ -f "$KEY_FILE" ]; then
grep -v '^#' "$KEY_FILE"
else
echo "No age key found at $KEY_FILE" >&2
exit 1
fi
'';
apps.default = {
type = "app";
program = "${self'.packages.himitsu}/bin/himitsu";
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
clippy
rustfmt
git
gh
age
protobuf
];
shellHook = ''
alias himitsu="$(git rev-parse --show-toplevel)/target/debug/himitsu"
'';
};
devShells.coverage = pkgs.mkShell {
inputsFrom = [
self'.devShells.default
];
};
checks = {
himitsu = self'.packages.himitsu;
himitsu-smoke = (
pkgs.runCommand "himitsu-smoke" { buildInputs = [ self'.packages.himitsu ]; } ''
himitsu --help
touch $out
''
);
};
};
# Per-system lib for downstream flakes: himitsu.lib.${system}.mkDevShell, etc.
# See nix/lib/default.nix and docs/nix-integration.md for the full API.
flake.lib = nixpkgs.lib.genAttrs config.systems (
system:
let
s = config.allSystems.${system};
in
import ./nix/lib {
pkgs = s.pkgs;
himitsu = s.packages.himitsu;
age-key-cmd = s.packages.age-key-cmd;
}
);
}
)
// {
herculesCI = {
onPush = { };
};
};
}