-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
81 lines (76 loc) · 2.09 KB
/
flake.nix
File metadata and controls
81 lines (76 loc) · 2.09 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
{
description = "smartconsole";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, crane }:
let
pname = "smartconsole";
version = "0.1.0";
system = "x86_64-linux";
crane-overlay = final: prev: {
# crane's lib is not exposed as an overlay in its flake (should be added
# upstream ideally) so this interface might be brittle, but avoids
# accidentally passing a detached nixpkgs from its flake (or its follows)
# on to consumers.
craneLib = crane.mkLib prev;
};
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default crane-overlay ];
};
lib = nixpkgs.lib;
buildInputs = with pkgs; [
binutils
linux-pam
zbar.dev
];
outputPackages = {
"${pname}-cli" = {
buildInputs = [
"zbar"
];
cargoExtraArgs = "-p smccli";
};
"${pname}-libpam" = {
buildInputs = [
"linux-pam"
];
cargoExtraArgs = "-p smartconsole";
};
};
in {
packages.${system} = lib.mapAttrs (n: _: pkgs.${n}) outputPackages;
defaultPackage.${system} = self.packages.${system}."${pname}-cli";
overlays.default = final: prev:
let
cratePackage = name: opts:
(final.craneLib.buildPackage {
pname = name;
inherit version;
src = with final; lib.cleanSourceWith {
src = ./.;
filter = path: type: true;
};
#cargoVendorDir = final.craneLib.vendorCargoDeps { cargoLock = ./Cargo.lock; };
nativeBuildInputs = with final; [
pkg-config
];
buildInputs = map (p: final.${p}) opts.buildInputs;
inherit (opts) cargoExtraArgs;
});
in
lib.mapAttrs cratePackage outputPackages;
devShell.${system} = with pkgs; mkShell {
buildInputs = [
cargo
openssl.dev
pkg-config
rustc
rustfmt
] ++ buildInputs;
};
};
}