Skip to content
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

gphoto2: Add option for group name #296832

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions nixos/modules/programs/gphoto2.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:

{
meta.maintainers = [ lib.maintainers.league ];
Expand All @@ -9,12 +14,18 @@
enable = lib.mkOption {
default = false;
type = lib.types.bool;
description = "Whether to configure system to use gphoto2.";
};
group = lib.mkOption {
description = ''
Whether to configure system to use gphoto2.
To grant digital camera access to a user, the user must
be part of the camera group:
`users.users.alice.extraGroups = ["camera"];`
Group created when gphoto2 is enabled.

To grant digital camera access to a user, the user must be part of this group:
`users.users.alice.extraGroups = [ config.programs.gphoto2.group ];`.
'';
type = lib.types.str;
default = "camera";
example = "gphoto2";
};
};
};
Expand All @@ -23,6 +34,6 @@
config = lib.mkIf config.programs.gphoto2.enable {
services.udev.packages = [ pkgs.libgphoto2 ];
environment.systemPackages = [ pkgs.gphoto2 ];
users.groups.camera = {};
users.groups."${config.programs.gphoto2.group}" = { };
};
}
46 changes: 24 additions & 22 deletions pkgs/by-name/li/libgphoto2/package.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{ lib
, stdenv
, fetchFromGitHub
, buildPackages
, autoreconfHook
, pkg-config
, gettext
, libusb1
, libtool
, libexif
, libgphoto2
, libjpeg
, curl
, libxml2
, gd
{
lib,
nixos,
stdenv,
fetchFromGitHub,
buildPackages,
autoreconfHook,
pkg-config,
gettext,
libusb1,
libtool,
libexif,
libgphoto2,
libjpeg,
curl,
libxml2,
gd,
}:

let
inherit (nixos { }) config;
group = config.programs.gphoto2.group or "camera";
in
stdenv.mkDerivation rec {
pname = "libgphoto2";
version = "2.5.31";
Expand Down Expand Up @@ -56,18 +61,15 @@ stdenv.mkDerivation rec {
postInstall =
let
executablePrefix =
if stdenv.buildPlatform == stdenv.hostPlatform then
"$out"
else
buildPackages.libgphoto2;
if stdenv.buildPlatform == stdenv.hostPlatform then "$out" else buildPackages.libgphoto2;
in
''
mkdir -p $out/lib/udev/{rules.d,hwdb.d}
${executablePrefix}/lib/libgphoto2/print-camera-list \
udev-rules version 201 group camera \
udev-rules version 201 group ${group} \
>$out/lib/udev/rules.d/40-libgphoto2.rules
${executablePrefix}/lib/libgphoto2/print-camera-list \
hwdb version 201 group camera \
hwdb version 201 group ${group} \
>$out/lib/udev/hwdb.d/20-gphoto.hwdb
'';

Expand Down
Loading