-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
70 lines (65 loc) · 1.86 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
{
description = "wharfix-web";
inputs = {
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
};
outputs = { self, crane, nixpkgs }:
let
pname = "wharfix-web";
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay crane-overlay ];
};
lib = nixpkgs.lib;
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;
};
outputPackages = {
"${pname}" = [];
};
in {
packages.${system} = lib.mapAttrs (n: _: pkgs.${n}) outputPackages;
defaultPackage.${system} = pkgs.${pname};
overlay = final: prev:
let
cratePackage = name: features:
(final.craneLib.buildPackage {
src = with final; lib.cleanSourceWith {
src = ./.;
filter = path: type:
let
templates = lib.hasInfix "/templates/" path;
webroot = lib.hasInfix "/webroot/" path;
in
(craneLib.filterCargoSources path type) || webroot || templates;
};
nativeBuildInputs = with final; [
pkg-config
];
buildInputs = with final; [
openssl
];
cargoExtraArgs = final.lib.concatMapStringsSep " " (f: "--features=${f}") features;
});
in
lib.mapAttrs cratePackage outputPackages;
devShell.${system} = with pkgs; mkShell {
buildInputs = [
cargo
nix
openssl.dev
pkgconfig
rustc
rustfmt
zlib.dev
];
};
};
}