summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristopher League <league@contrapunctus.net>2016-12-27 13:39:53 -0500
committerChristopher League <league@contrapunctus.net>2016-12-27 17:47:38 -0500
commit6eead52e1252413ea835fa1261bbf73ff569d23d (patch)
treefedfb30ca32a4ce4c0a12dd2c0fb3e3ff27c997a
parent02c65bdac919fcb0cecc1a157744156ed39b9fc6 (diff)
downloadnixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar.gz
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar.bz2
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar.lz
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar.xz
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.tar.zst
nixpkgs-6eead52e1252413ea835fa1261bbf73ff569d23d.zip
gphoto2: nixos programs module to configure udev
Closes #21420.
-rw-r--r--lib/maintainers.nix1
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/programs/gphoto2.nix31
-rw-r--r--pkgs/development/libraries/libgphoto2/default.nix6
4 files changed, 38 insertions, 1 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index 7ed8ae953bc..a06f1695294 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -240,6 +240,7 @@
   lassulus = "Lassulus <lassulus@gmail.com>";
   layus = "Guillaume Maudoux <layus.on@gmail.com>";
   ldesgoui = "Lucas Desgouilles <ldesgoui@gmail.com>";
+  league = "Christopher League <league@contrapunctus.net>";
   lebastr = "Alexander Lebedev <lebastr@gmail.com>";
   leenaars = "Michiel Leenaars <ml.software@leenaa.rs>";
   leonardoce = "Leonardo Cecchi <leonardo.cecchi@gmail.com>";
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index cd12fe4f9b3..b3177589716 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -71,6 +71,7 @@
   ./programs/environment.nix
   ./programs/fish.nix
   ./programs/freetds.nix
+  ./programs/gphoto2.nix
   ./programs/info.nix
   ./programs/java.nix
   ./programs/kbdlight.nix
diff --git a/nixos/modules/programs/gphoto2.nix b/nixos/modules/programs/gphoto2.nix
new file mode 100644
index 00000000000..47822562aee
--- /dev/null
+++ b/nixos/modules/programs/gphoto2.nix
@@ -0,0 +1,31 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+  meta.maintainers = [ maintainers.league ];
+
+  ###### interface
+  options = {
+    programs.gphoto2 = {
+      enable = mkOption {
+        default = false;
+        example = true;
+        type = types.bool;
+        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:
+          <code>users.extraUsers.alice.extraGroups = ["camera"];</code>
+        '';
+      };
+    };
+  };
+
+  ###### implementation
+  config = mkIf config.programs.gphoto2.enable {
+    services.udev.packages = [ pkgs.libgphoto2 ];
+    environment.systemPackages = [ pkgs.gphoto2 ];
+    users.extraGroups.camera = {};
+  };
+}
diff --git a/pkgs/development/libraries/libgphoto2/default.nix b/pkgs/development/libraries/libgphoto2/default.nix
index 68736608ad4..e9b6968d13b 100644
--- a/pkgs/development/libraries/libgphoto2/default.nix
+++ b/pkgs/development/libraries/libgphoto2/default.nix
@@ -25,6 +25,11 @@ stdenv.mkDerivation rec {
 
   hardeningDisable = [ "format" ];
 
+  postInstall = ''
+    mkdir -p $out/lib/udev/rules.d
+    $out/lib/libgphoto2/print-camera-list udev-rules version 175 group camera >$out/lib/udev/rules.d/40-gphoto2.rules
+  '';
+
   meta = {
     homepage = http://www.gphoto.org/proj/libgphoto2/;
     description = "A library for accessing digital cameras";
@@ -41,4 +46,3 @@ stdenv.mkDerivation rec {
     maintainers = with stdenv.lib.maintainers; [ jcumming ];
   };
 }
-