first commit

This commit is contained in:
guochao 2024-03-01 16:53:15 +08:00
commit d1cdcf6ffe
6 changed files with 133 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

25
flake.lock generated Normal file
View File

@ -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
}

63
flake.nix Normal file
View File

@ -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;
});
};
}

32
install.sh Normal file
View File

@ -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

12
nutstore-menu.desktop Normal file
View File

@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB