-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generic-device-plugin
package and module
#49
Open
MagicRB
wants to merge
3
commits into
master
Choose a base branch
from
generic-device-plugin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,18 @@ | ||
{ lib, nglib, ... }: | ||
{ | ||
mkUserOption = | ||
user: description: | ||
lib.mkOption { | ||
inherit description; | ||
type = lib.types.str; | ||
default = user; | ||
}; | ||
|
||
mkGroupOption = | ||
group: description: | ||
lib.mkOption { | ||
inherit description; | ||
type = lib.types.str; | ||
default = group; | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -50,4 +50,5 @@ | |
./services/dnsmasq.nix | ||
./services/attic.nix | ||
./services/ntfy-sh.nix | ||
./services/generic-device-plugin.nix | ||
] |
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,105 @@ | ||
# SPDX-FileCopyrightText: 2021 Richard Brežák and NixNG contributors | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
{ | ||
pkgs, | ||
config, | ||
lib, | ||
nglib, | ||
... | ||
}: | ||
let | ||
cfg = config.services.genericDevicePlugin; | ||
settingsFormat = pkgs.formats.json { }; | ||
usageLink = "https://github.com/squat/generic-device-plugin/tree/main?tab=readme-ov-file#usage"; | ||
in | ||
{ | ||
options.services.genericDevicePlugin = { | ||
enable = lib.mkEnableOption "Whether to enable the generic-device-plugin"; | ||
|
||
package = lib.mkPackageOption pkgs "generic-device-plugin" { }; | ||
|
||
settings = { | ||
devices = lib.mkOption { | ||
type = lib.types.listOf (settingsFormat.type); | ||
default = [ ]; | ||
description = '' | ||
See [upstream documentation](${usageLink}); | ||
''; | ||
example = lib.literalExpression '' | ||
[ | ||
{ | ||
name = "zigbee"; | ||
groups = lib.singleton { paths = lib.singleton { path = "/dev/ttyZigbee"; }; }; | ||
} | ||
{ | ||
name = "ender3"; | ||
groups = lib.singleton { paths = lib.singleton { path = "/dev/ttyEnder3"; }; }; | ||
} | ||
] | ||
''; | ||
}; | ||
domain = lib.mkOption { | ||
type = lib.types.nullOr lib.types.str; | ||
default = null; | ||
description = '' | ||
See [upstream documentation](${usageLink}). If `null`, upstream default is used. | ||
''; | ||
}; | ||
listen = lib.mkOption { | ||
type = lib.types.nullOr lib.types.str; | ||
default = null; | ||
description = '' | ||
See [upstream documentation](${usageLink}). If `null`, upstream default is used. | ||
''; | ||
}; | ||
logLevel = lib.mkOption { | ||
type = lib.types.enum [ | ||
"all" | ||
"debug" | ||
"info" | ||
"warn" | ||
"error" | ||
"none" | ||
"info" | ||
]; | ||
default = "info"; | ||
description = '' | ||
Log level to use. | ||
''; | ||
}; | ||
pluginDirectory = lib.mkOption { | ||
type = lib.types.nullOr lib.types.path; | ||
default = null; | ||
description = '' | ||
See [upstream documentation](${usageLink}). If `null`, upstream default is used. | ||
''; | ||
}; | ||
}; | ||
user = nglib.mkUserOption "generic-device-plugin" "User to run `generic-device-plugin` as."; | ||
group = nglib.mkGroupOption "generic-device-plugin" "Group to run `generic-device-plugin` as."; | ||
}; | ||
config = lib.mkIf cfg.enable { | ||
|
||
users.users.${cfg.user} = nglib.mkDefaultRec { | ||
description = "generic-device-plugin"; | ||
group = cfg.group; | ||
createHome = false; | ||
home = "/var/empty"; | ||
useDefaultShell = false; | ||
uid = config.ids.uids.generic-device-plugin; | ||
}; | ||
|
||
users.groups.${cfg.group} = nglib.mkDefaultRec { gid = config.ids.gids.generic-device-plugin; }; | ||
|
||
init.services.generic-device-plugin = { | ||
shutdownOnExit = true; | ||
enabled = true; | ||
execStart = "${lib.getExe cfg.package} --config ${settingsFormat.generate "settings.json" cfg.settings}"; | ||
}; | ||
}; | ||
} |
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,31 @@ | ||
{ | ||
buildGoModule, | ||
fetchFromGitHub, | ||
lib, | ||
... | ||
}: | ||
|
||
buildGoModule { | ||
pname = "generic-device-plugin"; | ||
version = "20241207-unstable"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "squat"; | ||
repo = "generic-device-plugin"; | ||
rev = "36bfc606bba2064de6ede0ff2764cbb52edff70d"; | ||
hash = "sha256-xztISJxFWKFWvanWY6WBx7KBIbJdUUkVX+YM0xLgBzk="; | ||
}; | ||
|
||
vendorHash = "sha256-L0OYB6iI4z1o4FEmzpL0Qbc9uamyJZ89HWV77D10p3M="; | ||
|
||
# requires a docker instance running | ||
doCheck = false; | ||
|
||
meta = with lib; { | ||
description = "The generic-device-plugin enables allocating generic Linux devices, such as serial devices, the FUSE device, or video cameras, to Kubernetes Pods."; | ||
homepage = "https://github.com/squat/generic-device-plugin"; | ||
license = licenses.asl20; | ||
maintainers = with maintainers; [ ]; | ||
mainProgram = "generic-device-plugin"; | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead use the
user
andgroup
options underconfig.init.services.generic-device-plugin
? Also I think the user and group are currently unused?