-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
116 lines (105 loc) · 3.37 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
utils.url = "github:numtide/flake-utils";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, utils, fenix, naersk, treefmt-nix }:
utils.lib.eachDefaultSystem (system:
let
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages."${system}";
treefmt' = {
projectRootFile = "flake.nix";
settings = with builtins; (fromTOML (readFile ./treefmt.toml));
};
toolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
stable.clippy
stable.rustfmt
targets.wasm32-unknown-unknown.stable.rust-std
];
naersk-lib = (naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
});
requiredLibs = with pkgs;
[
libGL
wayland
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
xorg.libXxf86vm
xorg.libxcb
] ++ lib.optionals stdenv.isLinux [ libxkbcommon wayland ];
libPath = lib.makeLibraryPath requiredLibs;
in
rec {
# nix build
packages.advisory_viewer = naersk-lib.buildPackage rec {
name = "advisory_viewer";
src = ./.;
doCheck = true;
cargoBuildOptions = x: x ++ [ "-p" name ];
cargoTestOptions = x: x ++ [ "-p" name ];
# nativeBuildInputs = with pkgs; [ pkg-config ];
overrideMain = (_: {
postFixup = ''
patchelf --set-rpath "${libPath}" $out/bin/${name}
'';
});
};
packages.opencas = naersk-lib.buildPackage rec {
name = "opencas";
src = ./.;
doCheck = true;
cargoBuildOptions = x: x ++ [ "-p" name ];
cargoTestOptions = x: x ++ [ "-p" name ];
doDoc = true;
copyBins = false;
doDocFail = true;
copyTarget = true;
};
# nix run
apps.advisory_viewer = utils.lib.mkApp rec {
name = "advisory_viewer";
drv = packages.${name};
};
# nix develop
devShells.default = pkgs.mkShell {
inputsFrom = with self.packages.${system}; [
advisory_viewer
opencas
];
nativeBuildInputs = with pkgs; [
cargo-flamegraph # for performance stuff
toolchain # our rust toolchain
trunk # for web stuff
# keep everything neat
nixpkgs-fmt
nodePackages.prettier
treefmt
# dev stuff
];
buildInputs = packages.advisory_viewer.buildInputs;
LD_LIBRARY_PATH = libPath;
shellHook = ''
export IS_NIX_BUILD=true
'';
};
checks = {
treefmt = ((treefmt-nix.lib.evalModule pkgs treefmt').config.build.check self).overrideAttrs (o: {
buildInputs = devShells.default.nativeBuildInputs ++ [ pkgs.git ];
});
};
});
}