-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
97 lines (82 loc) · 2.7 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, fenix, crane }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system:
let
version = "0.1.0-alpha";
pkgs = import nixpkgs { inherit system; overlays = [ ]; };
craneLib = (crane.mkLib pkgs).overrideToolchain
fenix.packages.${system}.stable.toolchain;
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(pkgs.lib.hasSuffix "\.css" path) ||
(pkgs.lib.hasSuffix "\.js" path) ||
(pkgs.lib.hasSuffix "\.html" path) ||
(pkgs.lib.hasSuffix "\.webp" path) ||
(pkgs.lib.hasSuffix "VERSION" path) ||
(pkgs.lib.hasInfix "/assets/" path) ||
(pkgs.lib.hasInfix "/templates/" path) ||
(craneLib.filterCargoSources path type)
;
};
commonArgs = {
inherit src;
inherit version;
strictDeps = true;
pname = "puggle";
buildInputs = [
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
libiconv
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
]);
nativeBuildInputs = with pkgs; [
pkg-config
esbuild
gzip
git
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
puggle = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
CARGO_PROFILE = "release";
});
in
{
checks = {
inherit puggle;
puggle-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
};
packages = {
inherit puggle;
default = puggle;
};
devShells = {
default = craneLib.devShell {
inputsFrom = [ self.packages.${system}.puggle ];
packages = with pkgs; [
nil
nixpkgs-fmt
cargo-watch
just
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin ([ pkgs.libiconv ]);
};
};
});
}