-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
134 lines (125 loc) · 4.54 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "Application to set wallpapers from reddit as desktop-background";
inputs = {
os_flake.url = "github:septias/nixos-config";
nixpkgs.follows = "os_flake/nixpkgs";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.follows = "rust-overlay/flake-utils";
naersk.url = "github:nix-community/naersk";
};
outputs = inputs:
with inputs;
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
overlays = [(import rust-overlay)];
inherit system;
};
unstable = import nixpkgs-unstable {
inherit system;
};
libraries = with pkgs; [
webkitgtk
gtk3
cairo
gdk-pixbuf
glib
dbus
openssl_3
librsvg
];
buildInputs = with pkgs; [
curl
wget
pkg-config
dbus
openssl_3
openssl
glib
gtk3
libsoup
webkitgtk
librsvg
makeWrapper
];
rust-toolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src" "rustfmt" "rust-docs" "clippy" "rust-analyzer"];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-toolchain;
rustc = rust-toolchain;
};
name = "better-ilias";
version = "1.0.1";
frontend = pkgs.stdenv.mkDerivation (finalAttrs: {
inherit version;
pname = "better-ilias-frontend";
src = pkgs.lib.cleanSource ./frontend;
nativeBuildInputs = with unstable; [
nodejs
unstable.pnpm.configHook
];
pnpmDeps = unstable.pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-fQ+6cYSNHX8U/hdWBNK2bKz8UvurHZrgrGeYSnNWb4k=";
};
installPhase = ''
pnpm build
cp -r dist $out
'';
});
desktopItem = pkgs.makeDesktopItem {
name = "Better Ilias";
desktopName = "Better Ilias";
icon = "better-ilias";
exec = "better-ilias";
categories = [ "Office" ];
};
icon = ./src-tauri/icons/icon.png;
icon-small = ./src-tauri/icons/128x128.png;
in rec {
formatter = pkgs.alejandra;
packages = {
${name} = rustPlatform.buildRustPackage rec {
inherit buildInputs name desktopItem version;
nativeBuildInputs = buildInputs;
src = ./src-tauri;
cargoLock = {
lockFile = ./src-tauri/Cargo.lock;
};
postPatch = ''
substituteInPlace tauri.conf.json --replace-fail '"distDir": "../frontend/dist",' '"distDir": "${frontend}",'
'';
postInstall = ''
mkdir -p $out/share/icons/hicolor/128x128/apps
mkdir -p $out/share/icons/hicolor/512x512/apps
cp ${icon-small} $out/share/icons/hicolor/128x128/apps/better-ilias.png
cp ${icon} $out/share/icons/hicolor/512x512/apps/better-ilias.png
mkdir -p "$out/share/applications"
cp $desktopItem/share/applications/* $out/share/applications
wrapProgram $out/bin/${name} --prefix PATH : ${pkgs.glib}/bin --set WEBKIT_DISABLE_COMPOSITING_MODE 1
'';
meta = {
description = "Sync Ilias to your local system";
homepage = "https://github.com/Septias/reddit-wallpapers";
mainProgram = "reddit-wallpapers";
};
};
default = packages.${name};
};
devShells.default = pkgs.mkShell {
buildInputs = buildInputs ++ [rust-toolchain pkgs.cargo-tauri];
RUST_BACKTRACE = 1;
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
export WEBKIT_DISABLE_COMPOSITING_MODE=1
'';
};
}
);
}