From 3b77dfcc7e271c94da22fabe8e2b4f29cf80016d Mon Sep 17 00:00:00 2001 From: max-amb Date: Sat, 9 Sep 2023 05:53:18 +0100 Subject: [PATCH 1/5] nwg-look: init at v0.2.4 --- pkgs/applications/misc/nwg-look/default.nix | 72 +++++++++++++++++++ .../misc/nwg-look/fix-paths.patch | 35 +++++++++ pkgs/applications/misc/nwg-look/go.mod | 10 +++ 3 files changed, 117 insertions(+) create mode 100644 pkgs/applications/misc/nwg-look/default.nix create mode 100644 pkgs/applications/misc/nwg-look/fix-paths.patch create mode 100644 pkgs/applications/misc/nwg-look/go.mod diff --git a/pkgs/applications/misc/nwg-look/default.nix b/pkgs/applications/misc/nwg-look/default.nix new file mode 100644 index 000000000000..b9c092fa5939 --- /dev/null +++ b/pkgs/applications/misc/nwg-look/default.nix @@ -0,0 +1,72 @@ +{ lib +, stdenv +, fetchFromGitHub +, substituteAll +, buildGoModule +, go +, glib +, pkg-config +, cairo +, gtk3 +, xcur2png +, libX11 +, zlib +}: + +buildGoModule rec { + pname = "nwg-look"; + version = "0.2.4"; + + src = fetchFromGitHub { + owner = "nwg-piotr"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-wUI58qYkVYgES87HQ4octciDlOJ10oJldbUkFgxRUd4="; + }; + + vendorHash = "sha256-dev+TV6FITd29EfknwHDNI0gLao7gsC95Mg+3qQs93E="; + + # Replace /usr/ directories with the packages output location + # This means it references the correct path + patches = [ ./fix-paths.patch ]; + + postPatch = '' + sed -i 's|@out@|'"''${out}"'|g' main.go tools.go + ''; + + ldflags = [ "-s" "-w" ]; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + cairo + xcur2png + libX11.dev + zlib + gtk3 + ]; + + CGO_ENABLED = 1; + + postInstall = '' + mkdir -p $out/share + mkdir -p $out/share/nwg-look/langs + mkdir -p $out/share/applications + mkdir -p $out/share/pixmaps + cp stuff/main.glade $out/share/nwg-look/ + cp langs/* $out/share/nwg-look/langs + cp stuff/nwg-look.desktop $out/share/applications + cp stuff/nwg-look.svg $out/share/pixmaps + ''; + + meta = with lib; { + homepage = "https://github.com/nwg-piotr/nwg-look"; + description = "Nwg-look is a GTK3 settings editor, designed to work properly in wlroots-based Wayland environment."; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ max-amb ]; + mainProgram = "nwg-look"; + }; +} diff --git a/pkgs/applications/misc/nwg-look/fix-paths.patch b/pkgs/applications/misc/nwg-look/fix-paths.patch new file mode 100644 index 000000000000..3b56e0052213 --- /dev/null +++ b/pkgs/applications/misc/nwg-look/fix-paths.patch @@ -0,0 +1,35 @@ +diff --git a/main.go b/main.go +index 23c4756..c52e9c3 100644 +--- a/main.go ++++ b/main.go +@@ -335,7 +335,7 @@ func main() { + + gtkSettings, _ = gtk.SettingsGetDefault() + +- builder, _ := gtk.BuilderNewFromFile("/usr/share/nwg-look/main.glade") ++ builder, _ := gtk.BuilderNewFromFile("@out@/share/nwg-look/main.glade") + win, _ := getWindow(builder, "window") + + win.Connect("destroy", func() { +diff --git a/tools.go b/tools.go +index e6e7665..59d6f35 100644 +--- a/tools.go ++++ b/tools.go +@@ -1034,7 +1034,7 @@ func getDataDirs() []string { + if os.Getenv("XDG_DATA_DIRS") != "" { + xdgDataDirs = os.Getenv("XDG_DATA_DIRS") + } else { +- xdgDataDirs = "/usr/local/share/:/usr/share/" ++ xdgDataDirs = "@out@/local/share/:@out@/share/" + } + + for _, d := range strings.Split(xdgDataDirs, ":") { +@@ -1280,7 +1280,7 @@ func detectLang() string { + } + + func loadVocabulary(lang string) map[string]string { +- langsDir := "/usr/share/nwg-look/langs/" ++ langsDir := "@out@/share/nwg-look/langs/" + enUSFile := filepath.Join(langsDir, "en_US.json") + if pathExists(enUSFile) { + log.Infof(">>> Loading basic lang from '%s'", enUSFile) diff --git a/pkgs/applications/misc/nwg-look/go.mod b/pkgs/applications/misc/nwg-look/go.mod new file mode 100644 index 000000000000..0446058e56c2 --- /dev/null +++ b/pkgs/applications/misc/nwg-look/go.mod @@ -0,0 +1,10 @@ +module github.com/nwg-piotr/nwg-look + +go 1.20 + +require ( + github.com/gotk3/gotk3 v0.6.2 + github.com/sirupsen/logrus v1.9.3 +) + +require golang.org/x/sys v0.6.0 // indirect From 4d1423771d142a659c423dfc5f7740bea10cbe27 Mon Sep 17 00:00:00 2001 From: max-amb Date: Sat, 9 Sep 2023 05:54:06 +0100 Subject: [PATCH 2/5] nwg-look: init at v0.2.4 --- pkgs/top-level/all-packages.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c692e4b4ee9d..1bd102054df5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33711,6 +33711,8 @@ with pkgs; nwg-launchers = callPackage ../applications/misc/nwg-launchers { }; + nwg-look = callPackage ../applications/misc/nwg-look { }; + nwg-menu = callPackage ../applications/misc/nwg-menu { }; nwg-panel = callPackage ../applications/misc/nwg-panel { }; From 1487dcccf30252e7b4eb5fe05057aaf912e4c614 Mon Sep 17 00:00:00 2001 From: max-amb Date: Sat, 9 Sep 2023 05:56:24 +0100 Subject: [PATCH 3/5] mantainers: update max-amb email --- maintainers/maintainer-list.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index c3dac5d13841..5884f3588173 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -10591,7 +10591,7 @@ }]; }; max-amb = { - email = "maxpeterambaum@gmail.com"; + email = "max_a@e.email"; github = "max-amb"; githubId = 137820334; name = "Max Ambaum"; From 4c713a347949fd3558745b1c242ec0be33ffa1ea Mon Sep 17 00:00:00 2001 From: max-amb Date: Sat, 9 Sep 2023 07:12:13 +0100 Subject: [PATCH 4/5] nwg-look: init at v0.2.4 --- pkgs/applications/misc/nwg-look/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/misc/nwg-look/default.nix b/pkgs/applications/misc/nwg-look/default.nix index b9c092fa5939..50bfa5f123dd 100644 --- a/pkgs/applications/misc/nwg-look/default.nix +++ b/pkgs/applications/misc/nwg-look/default.nix @@ -21,7 +21,7 @@ buildGoModule rec { owner = "nwg-piotr"; repo = pname; rev = "v${version}"; - sha256 = "sha256-wUI58qYkVYgES87HQ4octciDlOJ10oJldbUkFgxRUd4="; + hash = "sha256-wUI58qYkVYgES87HQ4octciDlOJ10oJldbUkFgxRUd4="; }; vendorHash = "sha256-dev+TV6FITd29EfknwHDNI0gLao7gsC95Mg+3qQs93E="; From 9bf511d4e37759195ccffdb709ec3059c0992600 Mon Sep 17 00:00:00 2001 From: Max Ambaum <137820334+max-amb@users.noreply.github.com> Date: Sat, 9 Sep 2023 07:29:58 +0000 Subject: [PATCH 5/5] nwg-look: init at v0.2.4 Co-authored-by: Pol Dellaiera --- pkgs/applications/misc/nwg-look/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/misc/nwg-look/default.nix b/pkgs/applications/misc/nwg-look/default.nix index 50bfa5f123dd..21b5a7a83324 100644 --- a/pkgs/applications/misc/nwg-look/default.nix +++ b/pkgs/applications/misc/nwg-look/default.nix @@ -31,7 +31,7 @@ buildGoModule rec { patches = [ ./fix-paths.patch ]; postPatch = '' - sed -i 's|@out@|'"''${out}"'|g' main.go tools.go + substituteInPlace main.go tools.go --replace '@out@' $out ''; ldflags = [ "-s" "-w" ];