From 8255b3e36b7ceba9b83bc753971913265155b3ae Mon Sep 17 00:00:00 2001 From: Dmitriy Kholkin Date: Fri, 22 Apr 2022 02:16:24 +0300 Subject: [PATCH] attempt to seadrive-fuse automount --- modules/seadrive.nix | 75 +++++++++++++++++++++++++++++ profiles/applications/packages.nix | 1 + profiles/overlay.nix | 1 + profiles/packages/seadrive-fuse.nix | 64 ++++++++++++++++++++++++ profiles/services.nix | 11 +++++ roles/base.nix | 1 + 6 files changed, 153 insertions(+) create mode 100644 modules/seadrive.nix create mode 100644 profiles/packages/seadrive-fuse.nix diff --git a/modules/seadrive.nix b/modules/seadrive.nix new file mode 100644 index 0000000..ac76938 --- /dev/null +++ b/modules/seadrive.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.seadrive; + settingsFormat = pkgs.formats.ini { }; + seadriveConf = if (cfg.settingsFile != null) then + cfg.settingsFile + else + settingsFormat.generate "seadrive.conf" cfg.settings; +in { + ###### Interface + options.services.seadrive = { + enable = mkEnableOption "Seadrive"; + + settings = mkOption { + type = types.submodule { + freeformType = settingsFormat.type; + }; + default = { + account = { + server = ""; + username = ""; + token = ""; + is_pro = false; + }; + general = { + client_name = "nixos"; + }; + cache = { + size_limit = "10GB"; + clean_cache_interval = 10; + }; + }; + description = '' + Configuration for Seadrive. + ''; + }; + + settingsFile = mkOption { + default = null; + type = types.nullOr types.path; + }; + + package = mkOption { + type = types.package; + description = "Which package to use for the seadrive."; + default = pkgs.seadrive-fuse; + defaultText = literalExpression "pkgs.seadrive-fuse"; + }; + + mountPoint = mkOption { + type = types.str; + default = "/media/seadrive"; + }; + }; + + ###### Implementation + + config.home-manager.users.alukard = mkIf cfg.enable { + systemd.user.services.seadrive-daemon = { + Service = { + Type = "simple"; + # Restart = "always"; + ExecStart = '' + ${cfg.package}/bin/seadrive -c ${seadriveConf} -f -d %h/.seadrive/data ${cfg.mountPoint} + ''; + }; + Unit = rec { + After = [ "network.target" ]; + Wants = After; + }; + Install.WantedBy = [ "multi-user.target" ]; + }; + }; +} \ No newline at end of file diff --git a/profiles/applications/packages.nix b/profiles/applications/packages.nix index c64fddc..29d6e8a 100644 --- a/profiles/applications/packages.nix +++ b/profiles/applications/packages.nix @@ -96,5 +96,6 @@ with config.deviceSpecific; { # winetricks ] ++ lib.optionals isLaptop [ acpi + seadrive-fuse ]; } diff --git a/profiles/overlay.nix b/profiles/overlay.nix index 1ad1404..23e84bc 100644 --- a/profiles/overlay.nix +++ b/profiles/overlay.nix @@ -31,6 +31,7 @@ with lib; { mpris-ctl = pkgs.callPackage ./packages/mpris-ctl.nix { }; multimc = pkgs.qt5.callPackage ./packages/multimc.nix { multimc-repo = inputs.multimc-cracked; }; reshade-shaders = pkgs.callPackage ./packages/reshade-shaders.nix { }; + seadrive-fuse = pkgs.callPackage ./packages/seadrive-fuse.nix { }; tidal-dl = pkgs.callPackage ./packages/tidal-dl.nix { }; vscode = master.vscode; vscode-fhs = master.vscode-fhs; diff --git a/profiles/packages/seadrive-fuse.nix b/profiles/packages/seadrive-fuse.nix new file mode 100644 index 0000000..0fbaae2 --- /dev/null +++ b/profiles/packages/seadrive-fuse.nix @@ -0,0 +1,64 @@ +{ fetchFromGitHub +, pkgconfig +, stdenv +, autoreconfHook +, lib +# Package dependencies +, libsearpc +, libselinux +, libuuid +, pcre +, libtool +, libevent +, sqlite +, openssl +, fuse +, vala +, intltool +, jansson +, curl +, python +}: + +stdenv.mkDerivation rec { + pname = "seadrive-fuse"; + version = "2.0.16"; + + src = fetchFromGitHub { + owner = "haiwen"; + repo = pname; + rev = "v${version}"; + sha256 = "072sx4wvj3gbslv3hn4sifr28fy812b8aja9d7phl1w4yix9l55z"; + }; + + patches = []; + + nativeBuildInputs = [ + autoreconfHook + pkgconfig + ]; + buildInputs = [ + libsearpc + libselinux + libuuid # Satisfies the 'mount' package requirement. Contains 'mount.pc' + pcre + libtool + libevent + sqlite + openssl.dev + fuse + vala + intltool + jansson + curl + python + ]; + + meta = with lib; { + homepage = https://github.com/haiwen/seadrive-fuse; + description = "SeaDrive daemon with FUSE interface"; + license = licenses.gpl3; + platforms = platforms.all; + maintainers = with maintainers; []; + }; +} \ No newline at end of file diff --git a/profiles/services.nix b/profiles/services.nix index 743bd8f..3a40728 100644 --- a/profiles/services.nix +++ b/profiles/services.nix @@ -28,6 +28,8 @@ with config.deviceSpecific; { interval = "weekly"; }; + services.gvfs.enable = !isServer; + # FIX! #services.thermald.enable = isLaptop; @@ -74,6 +76,15 @@ with config.deviceSpecific; { temperature.night = 3000; }; + secrets.seadrive = { + owner = "alukard"; + }; + services.seadrive = { + enable = true; + settingsFile = config.secrets.seadrive.decrypted; + mountPoint = "/media/seadrive"; + }; + services.upower.enable = true; systemd.services.systemd-udev-settle.enable = false; diff --git a/roles/base.nix b/roles/base.nix index 4a16c20..7236e32 100644 --- a/roles/base.nix +++ b/roles/base.nix @@ -16,6 +16,7 @@ network nix overlay + seadrive secrets secrets-envsubst security