blob: d3fa6524d75d2ee7b9c46bbf3ebe7a77a407e23c (
plain)
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
|
self:
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.programs.openBambooNetworking;
mkClientPlugin =
clientType: obnVersion: pkgs.callPackage (self + "/package.nix") { inherit clientType obnVersion; };
# home.file targets are relative to $HOME; configDir is given as an
# absolute path (so it composes naturally whether it comes from
# config.xdg.configHome, a Flatpak path, or something else entirely).
relToHome =
path:
if lib.hasPrefix (config.home.homeDirectory + "/") path then
lib.removePrefix (config.home.homeDirectory + "/") path
else
throw "programs.openBambooNetworking: configDir (${path}) must be under $HOME (${config.home.homeDirectory})";
orcaPlugin = mkClientPlugin "orca_slicer" cfg.orcaSlicer.obnVersion;
in
{
options.programs.openBambooNetworking = {
enable = mkEnableOption ''
open-bamboo-networking (https://github.com/ClusterM/open-bamboo-networking),
an open-source replacement for Bambu Lab slicers' proprietary network
plugin, built from source
'';
# Each supported client gets its own nested option group. Only
# orcaSlicer is wired up today; add siblings here (e.g. bambuStudio)
# as upstream support for them matures.
orcaSlicer = {
enable = mkOption {
type = types.bool;
default = true;
description = "Build and link the plugin for OrcaSlicer (or a compatible fork).";
};
obnVersion = mkOption {
type = types.str;
default = "02.03.00.99";
description = ''
Plugin ABI version baked into the built filename. Must match what
the slicer expects: check with
jq -r '.app.network_plugin_version // "not set"' <configDir>/OrcaSlicer.conf
First three components should match what the app reports; the
last component should stay .99 (see README).
'';
};
configDir = mkOption {
type = types.str;
default = "${config.xdg.configHome}/OrcaSlicer";
defaultText = literalExpression ''"''${config.xdg.configHome}/OrcaSlicer"'';
description = ''
Directory containing OrcaSlicer.conf and its plugins/ subfolder.
Override this if you're on a fork with a different config
directory (e.g. ~/.config/BambuStudio, ~/.config/OrcaSlicer-Nightly),
or a Flatpak install (e.g. ~/.var/app/io.github.softfever.OrcaSlicer/config/OrcaSlicer).
Must be a path under $HOME.
'';
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.orcaSlicer.enable {
home.packages = [ orcaPlugin ];
home.file = {
"${relToHome cfg.orcaSlicer.configDir}/plugins/libbambu_networking_${cfg.orcaSlicer.obnVersion}.so".source =
"${orcaPlugin}/plugins/libbambu_networking_${cfg.orcaSlicer.obnVersion}.so";
"${relToHome cfg.orcaSlicer.configDir}/plugins/libBambuSource.so".source =
"${orcaPlugin}/plugins/libBambuSource.so";
};
})
]);
}
|