diff --git a/NOTES.md b/NOTES.md index eb61722..247d0f7 100644 --- a/NOTES.md +++ b/NOTES.md @@ -28,6 +28,10 @@ library: - -dcore-lint ``` +To build with nix (using workers): + +`nix-build --show-trace --max-jobs 0` + To debug the GHC runtime (scheduler, gc, capabilities): `+RTS -N -Dg -DG -Ds -Di -RTS` @@ -44,6 +48,30 @@ To get the binary before it is striped from it's debugging information in nix: > NIX_PATH='' nix-build -K --show-trace and it will keep and print the build directory. +To inspect a derivation: + +``` +> nix repl +nix-repl> d = import ./nix/default.nix { inputs = (import ./default.nix).inputs; } +nix-repl> d.unmodified_static-haskell.haskellPackages.callPackage +``` + +alternatively: + +`nix repl --extra-experimental-features repl-flake .#` + +To debug a derivation: + +`nix show-derivation /nix/store/hngwpk25qnj35r6pkdb3zy5mnhlrfzrf-test-0.1.0.0.drv` + +To update a flake input: + +`nix flake lock --update-input vty` + +To push to cachix cache: + +`nix-build --show-trace --max-jobs 0 | cachix push gg` + Alternatives ============ @@ -119,4 +147,3 @@ https://discourse.nixos.org/t/static-libraries-discarded/991 https://sourceware.org/binutils/docs/binutils/nm.html https://renenyffenegger.ch/notes/development/languages/C-C-plus-plus/GCC/create-libraries/index https://github.com/NixOS/nixpkgs/issues/36883 - diff --git a/flake.lock b/flake.lock index 31d2cfa..04d294c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,5 @@ { "nodes": { - "MissingH": { - "flake": false, - "locked": { - "lastModified": 1557866336, - "narHash": "sha256-SOB1gVWp23y90s3mts3YmZidNpRgsCYijiJ4whU945M=", - "owner": "haskell-hvr", - "repo": "missingh", - "rev": "6581653b3a60f5343e631ed14223c8db462e96e3", - "type": "github" - }, - "original": { - "owner": "haskell-hvr", - "ref": "v1.4.2.0", - "repo": "missingh", - "type": "github" - } - }, "base16-schemes": { "flake": false, "locked": { @@ -84,61 +67,57 @@ "type": "github" } }, - "nh2-nixpkgs": { - "flake": false, + "nixpkgs": { "locked": { - "lastModified": 1572803313, - "narHash": "sha256-3m6CD1TOrNF8xTbPjruUFP4PBDhzy+6/ru92Fwow2vI=", - "owner": "nh2", + "lastModified": 1689277352, + "narHash": "sha256-dhriG/Uq73gwdNuCbjxEnFD60DyAuIH1YAj5rERrHIM=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "11aa987ea5b5a593c9ca7a38b391804959f905e5", + "rev": "9e49f8f1f37bc906cda1adb33064c325d760819a", "type": "github" }, "original": { - "owner": "nh2", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "11aa987ea5b5a593c9ca7a38b391804959f905e5", + "rev": "9e49f8f1f37bc906cda1adb33064c325d760819a", "type": "github" } }, "root": { "inputs": { - "MissingH": "MissingH", "base16-schemes": "base16-schemes", "brick": "brick", "flake-compat": "flake-compat", "libgit2": "libgit2", - "nh2-nixpkgs": "nh2-nixpkgs", + "nixpkgs": "nixpkgs", "static-haskell": "static-haskell", - "vty": "vty", - "yesodweb-authenticate": "yesodweb-authenticate" + "vty": "vty" } }, "static-haskell": { "flake": false, "locked": { - "lastModified": 1572807435, - "narHash": "sha256-zEMyTsVevC7AhKJPKpz8O4xXCO9PbsMxbLp3EDpY0yM=", + "lastModified": 1689279840, + "narHash": "sha256-0xZIgywfj+XRKXPISxVz/HS+cwtiJmql/LKrlMEhwcE=", "owner": "nh2", "repo": "static-haskell-nix", - "rev": "e3823be4caba6917c7c9f9dde9bece8ed8a4179b", + "rev": "88f1e2d57e3f4cd6d980eb3d8f99d5e60040ad54", "type": "github" }, "original": { "owner": "nh2", "repo": "static-haskell-nix", - "rev": "e3823be4caba6917c7c9f9dde9bece8ed8a4179b", "type": "github" } }, "vty": { "flake": false, "locked": { - "lastModified": 1689512592, - "narHash": "sha256-f+poPfxJcqdv09QftWFOp4Tdf9iSapT2EBp7NZKRsH0=", + "lastModified": 1697979126, + "narHash": "sha256-um/v1bufLeVq8OKOZL/lAb3pshR+uQ4d8MMiLj/o3P4=", "owner": "u-quark", "repo": "vty", - "rev": "7fd0d7de00b77af6cab8b95e7c11a49b19bdc881", + "rev": "781fff10814412760e657ca1add131a8b2774b6a", "type": "github" }, "original": { @@ -147,23 +126,6 @@ "repo": "vty", "type": "github" } - }, - "yesodweb-authenticate": { - "flake": false, - "locked": { - "lastModified": 1573918230, - "narHash": "sha256-tBNgn5Q7AEC8rY7rfxreepPP3iCII/clo+0mIYGivwY=", - "owner": "yesodweb", - "repo": "authenticate", - "rev": "b16d342db7b1a7f88b613d628ee5093305b50a62", - "type": "github" - }, - "original": { - "owner": "yesodweb", - "ref": "authenticate-1.3.5", - "repo": "authenticate", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4b7b1cc..9c56d21 100644 --- a/flake.nix +++ b/flake.nix @@ -2,36 +2,25 @@ description = "gg - git (G)UI"; inputs = { - MissingH = { - url = "github:haskell-hvr/missingh?ref=v1.4.2.0"; - flake = false; - }; - base16-schemes = { - url = "github:tinted-theming/base16-schemes?rev=9a4002f78dd1094c123169da243680b2fda3fe69"; - flake = false; - }; - brick = { - url = "github:jtdaugherty/brick?rev=3d34ef115631700ab6d46088357f7e2ab13c424e"; + nixpkgs.url = "github:NixOS/nixpkgs?rev=9e49f8f1f37bc906cda1adb33064c325d760819a"; + static-haskell = { + url = "github:nh2/static-haskell-nix"; flake = false; }; libgit2 = { url = "github:libgit2/libgit2?ref=v1.6.4"; flake = false; }; - nh2-nixpkgs = { - url = "github:nh2/nixpkgs?rev=11aa987ea5b5a593c9ca7a38b391804959f905e5"; - flake = false; - }; - static-haskell = { - url = "github:nh2/static-haskell-nix?rev=e3823be4caba6917c7c9f9dde9bece8ed8a4179b"; - flake = false; - }; vty = { url = "github:u-quark/vty?ref=gg"; flake = false; }; - yesodweb-authenticate = { - url = "github:yesodweb/authenticate?ref=authenticate-1.3.5"; + brick = { + url = "github:jtdaugherty/brick?rev=3d34ef115631700ab6d46088357f7e2ab13c424e"; + flake = false; + }; + base16-schemes = { + url = "github:tinted-theming/base16-schemes?rev=9a4002f78dd1094c123169da243680b2fda3fe69"; flake = false; }; flake-compat = { diff --git a/gg.iml b/gg.iml deleted file mode 100644 index 6ac6898..0000000 --- a/gg.iml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/nix/default.nix b/nix/default.nix index ddd9f78..f7c22ed 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,16 +1,17 @@ { inputs }: let - ghc = "ghc881"; - pkgs = import inputs.nh2-nixpkgs { system = "x86_64-linux"; }; + ghc = "ghc962"; + pkgs = import inputs.nixpkgs { system = "x86_64-linux"; }; static-pkgs-overlay = import ./static-pkgs-overlay.nix { inherit inputs; inherit pkgs; }; haskell-pkgs-overlay = import ./haskell-pkgs-overlay.nix { inherit inputs; - haskellLib = pkgs.haskell.lib; - callCabal2nix = pkgs.haskell.packages."${ghc}".callCabal2nix; + lib = pkgs.lib; + haskellLib = pkgs.pkgsMusl.haskell.lib; + callCabal2nix = pkgs.pkgsMusl.haskell.packages."${ghc}".callCabal2nix; }; haskellPkgsExtend = hp: f: hp.override (oldArgs: { overrides = pkgs.lib.composeExtensions (oldArgs.overrides or (_: _: {})) f; @@ -32,18 +33,11 @@ let pybase16-builder = tools.pybase16-builder; base16-schemes = inputs.base16-schemes; }; - gg = static-haskell.haskellPackagesWithLibsReadyForStaticLinking.callPackage (import ./gg.nix) { - ncurses = patched-pkgs.pkgsMusl.static-ncurses; - zlib = patched-pkgs.pkgsMusl.zlib; + gg = static-haskell.haskellPackages.callPackage (import ./gg.nix) { inherit haskell-base16-schemes; + MissingH = static-haskell.pkgsWithStaticHaskellBinaries.haskellPackages.MissingH_1_6_0_0; }; - devShell = pkgs.mkShell { - buildInputs = [ - static-haskell.haskellPackagesWithLibsReadyForStaticLinking.ghc - static-haskell.haskellPackagesWithLibsReadyForStaticLinking.Cabal_3_0_0_0 - static-haskell.haskellPackagesWithLibsReadyForStaticLinking.cabal-install - ]; - }; + devShell = pkgs.mkShell { nativeBuildInputs = gg.nativeBuildInputs; }; in { inherit gg; diff --git a/nix/gg.nix b/nix/gg.nix index abb045a..70c22c0 100644 --- a/nix/gg.nix +++ b/nix/gg.nix @@ -1,6 +1,6 @@ { mkDerivation, - stdenv, + lib, # Build deps hpack, c2hs, @@ -22,9 +22,6 @@ colour, # C deps libgit2, - # Transitive Haskell C deps - ncurses, - zlib, # Generated haskell-base16-schemes }: @@ -32,7 +29,7 @@ mkDerivation { pname = "gg"; version = "0.1.0.0"; - src = stdenv.lib.sourceByRegex ./.. [ + src = lib.sourceByRegex ./.. [ "app" "app/.*" "src" "src/.*" "test" "test/.*" "stack.yaml" "package.yaml" "Setup.hs" "LICENSE" "README.md" "ChangeLog.md" ]; @@ -43,11 +40,13 @@ mkDerivation { isExecutable = true; enableSharedLibraries = false; enableSharedExecutables = false; + enableLibraryProfiling = false; + enableExecutableProfiling = false; + dontStrip = false; preConfigure = "hpack"; configureFlags = [ "--ghc-option=-optl=-static" "--ghc-option=-optl=-pthread" - "--extra-lib-dirs=${zlib.static}/lib" ]; executableHaskellDepends = [ # Haskell deps @@ -67,11 +66,9 @@ mkDerivation { wreq # C deps libgit2 - # Transitive Haskell C deps - ncurses ]; buildDepends = [ hpack c2hs ]; homepage = "https://github.com/u-quark/gg#readme"; - license = stdenv.lib.licenses.gpl3Plus; + license = lib.licenses.gpl3Plus; } diff --git a/nix/haskell-base16-schemes.nix b/nix/haskell-base16-schemes.nix index f228682..50b7f6b 100644 --- a/nix/haskell-base16-schemes.nix +++ b/nix/haskell-base16-schemes.nix @@ -9,9 +9,9 @@ with pkgs; stdenv.mkDerivation { name = "gg-haskell-base16-schemes"; - src = stdenv.lib.sourceByRegex ../base16-haskell-template [".*"]; + src = ../base16-haskell-template; - buildInputs = [ base16-schemes pybase16-builder ]; + buildInputs = [ pybase16-builder ]; buildPhase = '' for scheme in ${base16-schemes}/*yaml; do scheme_name=$(basename $scheme) diff --git a/nix/haskell-pkgs-overlay.nix b/nix/haskell-pkgs-overlay.nix index 4373926..ddc3b32 100644 --- a/nix/haskell-pkgs-overlay.nix +++ b/nix/haskell-pkgs-overlay.nix @@ -1,27 +1,13 @@ -{ inputs, haskellLib, callCabal2nix }: +{ inputs, lib, haskellLib, callCabal2nix }: with haskellLib; let modifyPkg = pkg: dontHaddock (disableExecutableProfiling (disableLibraryProfiling (doJailbreak (dontCheck pkg)))); in self: super: -{ - MissingH = modifyPkg (callCabal2nix "MissingH" inputs.MissingH { - hslogger = self.hslogger; - regex-compat = self.regex-compat; - }); - vty = modifyPkg (callCabal2nix "vty" inputs.vty { - microlens-th = self.microlens-th; - }); +rec { + vty = modifyPkg (callCabal2nix "vty" inputs.vty {}); brick = modifyPkg (callCabal2nix "brick" inputs.brick { - vty = self.vty; - microlens-th = self.microlens-th; - }); - hslogger = self.hslogger_1_3_1_0; - microlens-th = self.microlens-th_0_4_3_2; - regex-compat = self.regex-compat_0_95_2_0; - RSA = self.RSA_2_4_1; - authenticate-oauth = modifyPkg (callCabal2nix "authenticate-oauth" "${inputs.yesodweb-authenticate}/authenticate-oauth" { - RSA = self.RSA; + vty = vty; }); } diff --git a/nix/static-pkgs-overlay.nix b/nix/static-pkgs-overlay.nix index 46d8115..09fe4fb 100644 --- a/nix/static-pkgs-overlay.nix +++ b/nix/static-pkgs-overlay.nix @@ -14,11 +14,6 @@ self: super: nativeBuildInputs = [ pkgs.binutils ]; } ); - # We cannot override regular ncurses because all the tools - # ghc etc depend on this and then nothing works! - static-ncurses = super.ncurses.override { - enableStatic = true; - }; libgit2 = super.libgit2.overrideAttrs (old: { src = inputs.libgit2; version = inputs.libgit2.rev; @@ -36,6 +31,8 @@ self: super: ADDLIB ${self.openssl.out}/lib/libssl.a ADDLIB ${self.openssl.out}/lib/libcrypto.a ADDLIB ${self.http-parser}/lib/libhttp_parser.a + ADDLIB ${self.pcre_static.out}/lib/libpcre.a + ADDLIB ${self.pcre_static.out}/lib/libpcreposix.a SAVE END EOM diff --git a/nix/tools/default.nix b/nix/tools/default.nix index 82d8a26..a88111c 100644 --- a/nix/tools/default.nix +++ b/nix/tools/default.nix @@ -3,5 +3,5 @@ with pkgs; { - pybase16-builder = python37Packages.callPackage (import ./pybase16-builder.nix) {}; + pybase16-builder = python311Packages.callPackage (import ./pybase16-builder.nix) {}; } diff --git a/package.yaml b/package.yaml index ae50804..48442b1 100644 --- a/package.yaml +++ b/package.yaml @@ -81,16 +81,18 @@ executables: dependencies: - gg -tests: - gg-test: - main: Spec.hs - source-dirs: test - ghc-options: - - -Wall - - -threaded - - -rtsopts - - -with-rtsopts=-N - extra-libraries: - - git2 - dependencies: - - gg +#tests: +# gg-test: +# main: Spec.hs +# source-dirs: test +# ghc-options: +# - -Wall +# - -threaded +# - -rtsopts +# - -with-rtsopts=-N +# - -v +# - -g0 +# extra-libraries: +# - git2 +# dependencies: +# - gg diff --git a/src/GG/UI.hs b/src/GG/UI.hs index 876413c..5c45c52 100644 --- a/src/GG/UI.hs +++ b/src/GG/UI.hs @@ -108,7 +108,7 @@ handleEvent s (AppEvent S.Tick) = tickEventHandler (s ^. field @"timers") s handleEvent s _ = continue s handleScrolling :: S.State -> V.Event -> EventM S.Name (Next S.State) -handleScrolling s@S.State {openCommit = Just _, ..} ev = do +handleScrolling s@S.State {openCommit = Just _} ev = do handleOpenCommitScrolling ev continue s handleScrolling s@S.State {openCommit = Nothing} ev = handleCommitsListScrolling s ev diff --git a/stack.yaml b/stack.yaml index 532f1b6..118b411 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-13.19 +resolver: nightly # does not matter # User packages to be built. # Various formats can be used as shown in the example below.