-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
90 lines (83 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
81
82
83
84
85
86
87
88
89
90
{
description = "A simple CLI utility to add rounded borders, padding, and shadows to images.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
naersk = {
url = "github:nmattia/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
naersk,
}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
supportedSystems = ["x86_64-linux" "aarch64-linux"];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in {
overlay = final: prev: {
"${cargoToml.package.name}" = final.callPackage ./. {};
};
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlay];
};
in {
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
});
defaultPackage = forAllSystems (system:
(import nixpkgs {
inherit system;
overlays = [self.overlay];
})
."${cargoToml.package.name}");
checks = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlay
];
};
in {
format =
pkgs.runCommand "check-format"
{
buildInputs = with pkgs; [rustfmt cargo];
} ''
${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
touch $out # it worked!
'';
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
});
devShell = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlay];
};
in
pkgs.mkShell.override { stdenv = pkgs.clang15Stdenv; } {
inputsFrom = [
pkgs."${cargoToml.package.name}"
];
NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.clangStdenv.cc.cc
pkgs.openssl
#pkgs.skia
];
NIX_LD = "/run/current-system/sw/share/nix-ld/lib/ld.so";
SKIA_NINJA_COMMAND = "${pkgs.ninja}/bin/ninja";
SKIA_GN_COMMAND = "${pkgs.gn}/bin/gn";
buildInputs = with pkgs; [
rustfmt
rust-analyzer
nixpkgs-fmt
ninja
clang
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
});
};
}