sane-extra-config.nixos.nix (1120B)
1 { config, lib, pkgs, ... }: 2 3 with lib; 4 let 5 cfg = config.hardware.sane; 6 pkg = 7 if cfg.snapshot 8 then pkgs.sane-backends-git 9 else pkgs.sane-backends; 10 backends = [ pkg ] ++ cfg.extraBackends; 11 saneConfig = pkgs.mkSaneConfig { paths = backends; }; 12 # saneExtraConfig = 13 # pkgs.runCommand "sane-extra-config" 14 # { } '' 15 # cp -Lr '${pkgs.mkSaneConfig { paths = [ pkgs.sane-backends ]; }}'/etc/sane.d $out 16 # chmod +w $out 17 # ${concatMapStrings 18 # ( 19 # c: '' 20 # f="$out/${c.name}.conf" 21 # [ ! -e "$f" ] || chmod +w "$f" 22 # cat ${builtins.toFile "" (c.value + "\n")} >>"$f" 23 # chmod -w "$f" 24 # '' 25 # ) 26 # (mapAttrsToList nameValuePair cfg.extraConfig)} 27 # chmod -w $out 28 # ''; 29 in 30 { 31 options = { 32 hardware.sane.extraConfig = mkOption { 33 type = types.attrsOf types.lines; 34 default = { }; 35 example = { "some-backend" = "# some lines to add to its .conf"; }; 36 }; 37 }; 38 39 config = mkIf (cfg.enable && cfg.extraConfig != { }) { 40 # hardware.sane.configDir = saneExtraConfig.outPath; 41 }; 42 }