-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
103 lines (96 loc) · 2.79 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
# Copyright 2024 3WEBS LLC
# SPDX-License-Identifier: GPL-3.0-or-later
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
crate2nix = {
url = "github:nix-community/crate2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
};
outputs = inputs @ { self, nixpkgs, parts, ... }: parts.lib.mkFlake { inherit inputs; } (
let
cargoToml = builtins.readFile ./Cargo.toml;
packageData = nixpkgs.lib.getAttr "package" (builtins.fromTOML cargoToml);
customPackageData = nixpkgs.lib.getAttr "metadata" packageData;
in {
systems = [
"x86_64-linux"
"aarch64-linux"
];
perSystem = {
system,
pkgs,
lib,
inputs',
...
}: let
libraries = with pkgs; [
gtk4
webkitgtk_6_0
glib
libadwaita
];
cratesNeedOverriding = [
"gobject-sys"
"javascriptcore6-sys"
"gio-sys"
"soup3-sys"
"gdk-pixbuf-sys"
"libadwaita-sys"
"webkit6-sys"
];
cargoNix = pkgs.callPackage (inputs.crate2nix.tools.${system}.generatedCargoNix {
name = packageData.name;
src = ./.;
}) {
defaultCrateOverrides = pkgs.defaultCrateOverrides // (builtins.listToAttrs (builtins.map (crate: {
name = crate;
value = (attrs: {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = libraries;
});
}) cratesNeedOverriding));
};
defaultPackage = cargoNix.rootCrate.build.overrideAttrs (oldAttrs: {
postInstall = ''
mkdir -p $out/share/applications $out/share/pixmaps
cat > $out/share/applications/${packageData.name}.desktop <<EOF
[Desktop Entry]
Name=${customPackageData.human_readable_name}
Exec=${packageData.name}
Icon=${packageData.name}
Type=Application
Categories=Network;WebBrowser;
EOF
cp $src/assets/icon.svg $out/share/pixmaps/${packageData.name}.svg
'';
});
in rec {
packages = {
default = defaultPackage;
};
checks = {
rustnix = packages.default.override {
runTests = true;
};
};
devShells.default = defaultPackage.overrideAttrs (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [
pkg-config
]);
buildInputs = oldAttrs.buildInputs ++ libraries ++ (with pkgs; [
yamllint
reuse
]);
});
};
}
);
}