-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (72 loc) · 2.4 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
{
description = "A devShell example";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
devshell.url = "github:numtide/devshell";
};
outputs = { self, nixpkgs, rust-overlay, crane, devshell }:
let
package_overlay = final: prev:
let system = final.system;
in
{
vf-backend = crane.lib.${system}.buildPackage {
src = ./.;
buildInputs = with final; lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
];
};
};
# taken from https://github.com/ngi-nix/project-template/blob/master/flake.nix
# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = self.overlays; });
in
{
overlays = [ rust-overlay.overlay package_overlay devshell.overlay ];
packages = forAllSystems (system:
{
inherit (nixpkgsFor.${system}) vf-backend;
});
defaultPackage = forAllSystems (system: self.packages.${system}.vf-backend);
nixosModules.backend = import ./module.nix;
devShell = forAllSystems
(system:
let
pkgs = nixpkgsFor.${system};
in
pkgs.devshell.mkShell {
packages = with pkgs; [
rust-bin.stable.latest.default
sqlite
] ++ lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
];
env = [
{
name = "RUST_LOG";
value = "info";
}
{
name = "DATABASE_URL";
value = "sqlite:db/try.db";
}
{
name = "HTTP_PORT";
value = "8080";
}
];
}
);
};
}