mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-19 03:14:03 +00:00
nixos/modules/services/network-filesystems/ipfs: refactor
Add `package` option to change the package used for the service.
This commit is contained in:
parent
13839daecc
commit
acd3d3dd20
@ -44,6 +44,13 @@ in {
|
||||
|
||||
enable = mkEnableOption "Interplanetary File System (WARNING: may cause severe network degredation)";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.ipfs;
|
||||
defaultText = "pkgs.ipfs";
|
||||
description = "Which IPFS package to use.";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "ipfs";
|
||||
@ -176,7 +183,7 @@ in {
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ pkgs.ipfs ];
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
environment.variables.IPFS_PATH = cfg.dataDir;
|
||||
|
||||
programs.fuse = mkIf cfg.autoMount {
|
||||
@ -207,14 +214,14 @@ in {
|
||||
"d '${cfg.ipnsMountDir}' - ${cfg.user} ${cfg.group} - -"
|
||||
];
|
||||
|
||||
systemd.packages = [ pkgs.ipfs ];
|
||||
systemd.packages = [ cfg.package ];
|
||||
|
||||
systemd.services.ipfs-init = {
|
||||
description = "IPFS Initializer";
|
||||
|
||||
environment.IPFS_PATH = cfg.dataDir;
|
||||
|
||||
path = [ pkgs.ipfs ];
|
||||
path = [ cfg.package ];
|
||||
|
||||
script = ''
|
||||
if [[ ! -f ${cfg.dataDir}/config ]]; then
|
||||
@ -239,7 +246,7 @@ in {
|
||||
};
|
||||
|
||||
systemd.services.ipfs = {
|
||||
path = [ "/run/wrappers" pkgs.ipfs ];
|
||||
path = [ "/run/wrappers" cfg.package ];
|
||||
environment.IPFS_PATH = cfg.dataDir;
|
||||
|
||||
wants = [ "ipfs-init.service" ];
|
||||
@ -267,7 +274,7 @@ in {
|
||||
cfg.extraConfig))
|
||||
);
|
||||
serviceConfig = {
|
||||
ExecStart = ["" "${pkgs.ipfs}/bin/ipfs daemon ${ipfsFlags}"];
|
||||
ExecStart = ["" "${cfg.package}/bin/ipfs daemon ${ipfsFlags}"];
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
} // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
|
||||
|
Loading…
Reference in New Issue
Block a user