-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ivan Kuznetsov <[email protected]>
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 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
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
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,56 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ lib, pkgs, config, ... }: | ||
with lib; | ||
let | ||
cfg = config.services.fmo-dci-passthrough; | ||
in { | ||
options.services.fmo-dci-passthrough = { | ||
enable = mkEnableOption "Docker Compose Infrastructure devices passthrough"; | ||
|
||
compose-path = mkOption { | ||
type = types.str; | ||
description = "Path to docker-compose's .yml file"; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = with pkgs; [ | ||
docker-compose | ||
]; | ||
|
||
dockerDevPassScript = pkgs.writeShellScriptBin "docker-dev-pass" '' | ||
''; | ||
|
||
udev = { | ||
extraRules = '' | ||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1050", RUN+="/usr/local/bin/operation-yubikey.sh 'plugged' '%E{DEVNAME}' '%M' '%m' '%E{PRODUCT}'" | ||
ACTION=="remove", SUBSYSTEM=="usb", RUN+="/usr/local/bin/operation-yubikey.sh 'unplugged' '%E{DEVNAME}' '%M' '%m' '%E{PRODUCT}'" | ||
''; | ||
}; | ||
|
||
systemd.services.fmo-dci-passthrough = { | ||
script = '' | ||
echo "Start docker-compose" | ||
${pkgs.docker-compose}/bin/docker-compose -f $DCPATH up | ||
''; | ||
|
||
wantedBy = ["multi-user.target"]; | ||
# If you use podman | ||
# after = ["podman.service" "podman.socket"]; | ||
# If you use docker | ||
after = [ | ||
"docker.service" | ||
"docker.socket" | ||
"network-online.target" | ||
]; | ||
|
||
# TODO: restart always | ||
serviceConfig = { | ||
Restart = lib.mkForce "always"; | ||
RestartSec = "30"; | ||
}; | ||
}; | ||
}; | ||
} |