commit d1cdcf6ffeda04a99dd87d9bfec1ef6ec75fb076 Author: guochao Date: Fri Mar 1 16:53:15 2024 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3f2741d --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1699725108, + "narHash": "sha256-NTiPW4jRC+9puakU4Vi8WpFEirhp92kTOSThuZke+FA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "911ad1e67f458b6bcf0278fa85e33bb9924fed7e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..976fe5b --- /dev/null +++ b/flake.nix @@ -0,0 +1,63 @@ +{ + description = "Nutstore on NixOS"; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" ]; + forEachSystem = nixpkgs.lib.genAttrs systems; + in + { + packages = forEachSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + rec { + nutstore-unwrapped = (pkgs.buildFHSEnv { + name = "nutstore-unwrapped"; + targetPkgs = pkgs: (with pkgs; [ + udev + alsa-lib + zlib + cairo + glib + webkitgtk + + gtk3 + libnotify + (python3.withPackages (pythonPackages: with pythonPackages; [ + pygobject3 + ])) + ]) ++ (with pkgs.xorg; [ + libX11 + libXcursor + libXrandr + ]); + multiPkgs = pkgs: (with pkgs; [ + udev + alsa-lib + ]); + runScript = ''env GI_TYPELIB_PATH=/usr/lib/girepository-1.0 python $HOME/.nutstore/dist/bin/nutstore-pydaemon.py''; + }); + nutstore = pkgs.stdenv.mkDerivation { + name = "nutstore"; + pname = "0.0.1"; + + src = ./.; + + buildInputs = [ + pkgs.makeWrapper + ]; + + installPhase = let + desktopEntry = ./nutstore-menu.desktop; + in '' + mkdir -p $out/bin $out/share/applications + makeWrapper ${nutstore-unwrapped}/bin/nutstore-unwrapped $out/bin/nutstore + sed "s,Exec=.*,Exec=$out/bin/nutstore,; s,Icon=.*,Icon=${./share/icons/hicolor/512x512/apps/nutstore.png}," ${desktopEntry} > $out/share/applications/nutstore-menu.desktop + ''; + }; + + default = nutstore; + }); + }; +} diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..a275131 --- /dev/null +++ b/install.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +set -eu pipefail + +if [ ! -d ~/.nutstore/dist ]; then + TEMP=$(mktemp -d) + BASE_DIR=$TEMP/dist + + curl -sSL https://www.jianguoyun.com/static/exe/installer/nutstore_linux_dist_x64.tar.gz -o $TEMP/nutstore_linux_dist_x64.tar.gz + mkdir $BASE_DIR + tar xvf $TEMP/nutstore_linux_dist_x64.tar.gz -C $BASE_DIR + + AUTOSTART_DIR=~/.config/autostart + MENU_DIR=~/.local/share/applications + ICON_DIR=~/.local/share/icons/hicolor/512x512/apps + + mkdir -p $AUTOSTART_DIR + cp $BASE_DIR/gnome-config/autostart/*.desktop $AUTOSTART_DIR + + mkdir -p $MENU_DIR + cp $BASE_DIR/gnome-config/menu/*.desktop $MENU_DIR + + mkdir -p $ICON_DIR + cp $BASE_DIR/app-icon/nutstore.png $ICON_DIR + + # we need to update icon cache + gtk-update-icon-cache --ignore-theme-index $ICON_DIR/../.. > /dev/null 2>&1 + + echo "Install Nutstore done." + echo "Now you can start Nutstore from menu: Applications > Internet > Nutstore" +fi + diff --git a/nutstore-menu.desktop b/nutstore-menu.desktop new file mode 100644 index 0000000..925aefc --- /dev/null +++ b/nutstore-menu.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Terminal=false +Icon=nutstore +Exec=/usr/bin/bash install.sh +StartupWMClass=Nutstore +Name=Nutstore +Name[zh_CN]=坚果云 +Comment=Data Sync, Sharing, Backup +Comment[zh_CN]=数据同步,共享和备份 +Categories=Network;Application; diff --git a/share/icons/hicolor/512x512/apps/nutstore.png b/share/icons/hicolor/512x512/apps/nutstore.png new file mode 100644 index 0000000..a0cc604 Binary files /dev/null and b/share/icons/hicolor/512x512/apps/nutstore.png differ