hover: init at 0.43.0 (#80075)

This commit is contained in:
Eric Dallo 2020-12-12 07:43:21 -03:00 committed by GitHub
parent f448ec3365
commit 7bb9e5053b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 180 additions and 0 deletions

View File

@ -0,0 +1,100 @@
{ lib
, buildGoModule
, buildFHSUserEnv
, dejavu_fonts
, pkgconfig
, fetchFromGitHub
, stdenv
, roboto
, writeScript
, xorg
, libglvnd
, addOpenGLRunpath
, makeWrapper
, gcc
, go
, flutter
}:
let
pname = "hover";
version = "0.43.0";
libs = with xorg; [
libX11.dev
libXcursor.dev
libXext.dev
libXi.dev
libXinerama.dev
libXrandr.dev
libXrender.dev
libXfixes.dev
libXxf86vm
libglvnd.dev
xorgproto
];
hover = buildGoModule rec {
inherit pname version;
meta = with stdenv.lib; {
description = "A build tool to run Flutter applications on desktop";
homepage = "https://github.com/go-flutter-desktop/hover";
license = licenses.bsd3;
platforms = platforms.linux ++ platforms.darwin;
maintainers = [ maintainers.ericdallo maintainers.thiagokokada];
};
subPackages = [ "." ];
vendorSha256 = "1wr08phjm87dxim47i8449rmq5wfscvjyz65g3lxmv468x209pam";
src = fetchFromGitHub {
rev = "v${version}";
owner = "go-flutter-desktop";
repo = pname;
sha256 = "0iw6sxg86wfdbihl2hxzn43ppdzl1p7g5b9wl8ac3xa9ix8759ax";
};
nativeBuildInputs = [ addOpenGLRunpath makeWrapper ];
buildInputs = libs;
checkRun = false;
patches = [
./fix-assets-path.patch
];
postPatch = ''
sed -i 's|@assetsFolder@|'"''${out}/share/assets"'|g' internal/fileutils/assets.go
'';
postInstall = ''
mkdir -p $out/share
cp -r assets $out/share/assets
chmod -R a+rx $out/share/assets
wrapProgram "$out/bin/hover" \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath libs}
'';
postFixup = ''
addOpenGLRunpath $out/bin/hover
'';
};
in
buildFHSUserEnv rec {
name = pname;
targetPkgs = pkgs: [
dejavu_fonts
flutter
gcc
go
hover
pkgconfig
roboto
] ++ libs;
runScript = "hover";
}

View File

@ -0,0 +1,78 @@
diff --git a/internal/fileutils/assets.go b/internal/fileutils/assets.go
index 83eacd9..0b80e51 100644
--- a/internal/fileutils/assets.go
+++ b/internal/fileutils/assets.go
@@ -1,28 +1,7 @@
//go:generate rice embed
package fileutils
-import (
- "os"
- "sync"
-
- rice "github.com/GeertJohan/go.rice"
- "github.com/go-flutter-desktop/hover/internal/log"
-)
-
-var (
- assetsBox *rice.Box
- assetsBoxOnce sync.Once
-)
-
// AssetsBox hover's assets box
-func AssetsBox() *rice.Box {
- assetsBoxOnce.Do(func() {
- var err error
- assetsBox, err = rice.FindBox("../../assets")
- if err != nil {
- log.Errorf("Failed to find hover assets: %v", err)
- os.Exit(1)
- }
- })
- return assetsBox
+func AssetsBox() string {
+ return "@assetsFolder@"
}
diff --git a/internal/fileutils/file.go b/internal/fileutils/file.go
index cb75563..3822e80 100644
--- a/internal/fileutils/file.go
+++ b/internal/fileutils/file.go
@@ -11,8 +11,6 @@ import (
"strings"
"text/template"
- rice "github.com/GeertJohan/go.rice"
-
"github.com/go-flutter-desktop/hover/internal/log"
)
@@ -215,24 +213,24 @@ func ExecuteTemplateFromFile(boxed, to string, templateData interface{}) {
}
// ExecuteTemplateFromAssetsBox create file from a template asset
-func ExecuteTemplateFromAssetsBox(boxed, to string, assetsBox *rice.Box, templateData interface{}) {
- templateString, err := assetsBox.String(boxed)
+func ExecuteTemplateFromAssetsBox(boxed, to string, assetsBox string, templateData interface{}) {
+ templateString, err := ioutil.ReadFile(boxed + "/" + boxed)
if err != nil {
log.Errorf("Failed to find template file: %v\n", err)
os.Exit(1)
}
- executeTemplateFromString(templateString, to, templateData)
+ executeTemplateFromString(string(templateString), to, templateData)
}
// CopyAsset copies a file from asset
-func CopyAsset(boxed, to string, assetsBox *rice.Box) {
+func CopyAsset(boxed string, to string, assetsBox string) {
file, err := os.Create(to)
if err != nil {
log.Errorf("Failed to create %s: %v", to, err)
os.Exit(1)
}
defer file.Close()
- boxedFile, err := assetsBox.Open(boxed)
+ boxedFile, err := os.OpenFile(assetsBox + "/" + boxed, os.O_RDONLY, 0666)
if err != nil {
log.Errorf("Failed to find boxed file %s: %v", boxed, err)
os.Exit(1)

View File

@ -21831,6 +21831,8 @@ in
gtk = gtk3;
};
hover = callPackage ../development/tools/hover { };
hovercraft = python3Packages.callPackage ../applications/misc/hovercraft { };
howl = callPackage ../applications/editors/howl { };