-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2abaf2
commit 8023a1e
Showing
2 changed files
with
68 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,5 @@ | ||
{ | ||
config, | ||
inputs, | ||
lib, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs.stdenv.hostPlatform) system; | ||
pname = "tmesh"; | ||
|
||
package = inputs.self.packages.${system}.${pname}; | ||
cfg = config.programs.${pname}; | ||
jsonConfig = builtins.toJSON cfg.settings; | ||
jsonConfigFile = pkgs.writeText "config.json" jsonConfig; | ||
in { | ||
options.programs.${pname} = { | ||
enable = lib.mkEnableOption "${pname}"; | ||
|
||
settings = lib.mkOption { | ||
type = lib.types.attrs; | ||
default = {}; | ||
description = "Configuration settings."; | ||
}; | ||
|
||
package = lib.mkOption { | ||
type = lib.types.package; | ||
default = package; | ||
description = "The package to use for ${pname}."; | ||
}; | ||
|
||
tmeshServerTmuxConfig = lib.mkOption { | ||
type = lib.types.lines; | ||
default = ""; | ||
description = "Tmux configuration for tmesh server."; | ||
}; | ||
|
||
tmeshTmuxConfig = lib.mkOption { | ||
type = lib.types.lines; | ||
default = ""; | ||
description = "Tmux configuration for tmesh."; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
environment.etc."${pname}/config.json".source = jsonConfigFile; | ||
|
||
environment.etc."${pname}/tmesh-server.tmux.conf" = { | ||
text = cfg.tmeshServerTmuxConfig; | ||
mode = "0644"; | ||
}; | ||
|
||
environment.etc."${pname}/tmesh.tmux.conf" = { | ||
text = cfg.tmeshTmuxConfig; | ||
mode = "0644"; | ||
}; | ||
|
||
environment.systemPackages = [ | ||
(pkgs.writeScriptBin "${pname}" '' | ||
#!${pkgs.stdenv.shell} | ||
exec ${pkgs.lib.meta.getExe cfg.package} --config ${jsonConfigFile} "$@" | ||
'') | ||
]; | ||
}; | ||
{...}: { | ||
import = [ | ||
../tmesh | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
config, | ||
inputs, | ||
lib, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (pkgs.stdenv.hostPlatform) system; | ||
pname = "tmesh"; | ||
|
||
package = inputs.self.packages.${system}.${pname}; | ||
cfg = config.programs.${pname}; | ||
jsonConfig = builtins.toJSON cfg.settings; | ||
jsonConfigFile = pkgs.writeText "config.json" jsonConfig; | ||
in { | ||
options.programs.${pname} = { | ||
enable = lib.mkEnableOption "${pname}"; | ||
|
||
settings = lib.mkOption { | ||
type = lib.types.attrs; | ||
default = {}; | ||
description = "Configuration settings."; | ||
}; | ||
|
||
package = lib.mkOption { | ||
type = lib.types.package; | ||
default = package; | ||
description = "The package to use for ${pname}."; | ||
}; | ||
|
||
tmeshServerTmuxConfig = lib.mkOption { | ||
type = lib.types.lines; | ||
default = ""; | ||
description = "Tmux configuration for tmesh server."; | ||
}; | ||
|
||
tmeshTmuxConfig = lib.mkOption { | ||
type = lib.types.lines; | ||
default = ""; | ||
description = "Tmux configuration for tmesh."; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
environment.etc."${pname}/config.json".source = jsonConfigFile; | ||
|
||
environment.etc."${pname}/tmesh-server.tmux.conf" = { | ||
text = cfg.tmeshServerTmuxConfig; | ||
mode = "0644"; | ||
}; | ||
|
||
environment.etc."${pname}/tmesh.tmux.conf" = { | ||
text = cfg.tmeshTmuxConfig; | ||
mode = "0644"; | ||
}; | ||
|
||
environment.systemPackages = [ | ||
(pkgs.writeScriptBin "${pname}" '' | ||
#!${pkgs.stdenv.shell} | ||
exec ${pkgs.lib.meta.getExe cfg.package} --config ${jsonConfigFile} "$@" | ||
'') | ||
]; | ||
}; | ||
} |