#+TITLE: Setting up Chimera
#+AUTHOR:Joshua Branson
#+PROPERTY: header-args :exports both :results output :tangle no :eval never-export

* chimera linux
** upgrading chimera linux


  #+BEGIN_SRC shell
  doas apk update

  doas apk upgrade
  #+END_SRC

** DONE Getting X applications and gdm to run on chimera

All power9 machines have trouble running X, when a discrete GPU is installed.
[[https://wiki.raptorcs.com/wiki/Troubleshooting/GPU#Xorg_will_not_start_.2F_crashes_when_a_discrete_GPU_is_installed][click here]] to read more on the raptor wiki.

I did have trouble getting my friend's Talos II to start gdm, but an update to
chimera linux fixed this issue.

gdm is not currently starting. Nor is any X application that I installed from
guix. The irc user (and chimera linux developer) q66 seems to think that gdm
will default to use wayland to launch.

*** raptor pdf user's guide:

https://wiki.raptorcs.com/w/images/e/e3/T2P9D01_users_guide_version_1_0.pdf
*** raptor wiki ways to fix this
**** Tell GDM to ignore a GPU

#+begin_src shell
lspci | grep VGA
#+end_src

#+RESULTS:
: 0005:02:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 41)
: 0030:01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon Pro WX 7100]

#+begin_src shell
cat /etc/udev/udev.conf
#+end_src

#+RESULTS:
#+begin_example
# see udev.conf(5) for details
#
# udevd is also started in the initrd.  When this file is modified you might
# also want to rebuild the initrd, so that it will include the modified configuration.

#udev_log=info
#children_max=
#exec_delay=
#event_timeout=180
#timeout_signal=SIGKILL
#resolve_names=early
TAG-="seat", ENV{ID_FOR_SEAT}=="drm-pci-0005_02_00_0"
TAG-="seat", ENV{ID_FOR_SEAT}=="graphics-pci-0005_02_00_0"
#+end_example

Do this to re-generate the initramfs.
~doas apk fix linux-lts~
**** Xorg will not start / crashes when a discrete GPU is installed
We chose to do the workaround 2: select a desired GPU at runtime, which means
that if we change the slot of the GPU, then we will have to re-create the Xorg
configuration file.

#+begin_src shell
lspci | grep VGA
#+end_src

#+RESULTS:
: 0005:02:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 41)
: 0030:01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon Pro WX 7100]

Aspped
lspci output
| hexadecimal | d | B | D | F |
|             | 5 | 2 | 0 | 0 |
| decimal     | 5 | 2 | 0 | 0 |
| Xorg format |   |   |   |   |
|             | B | d | D | F |
|             | 2 | 5 | 0 | 0 |

"PCI:B@d:D:F"
"PCI:2@5:0:0"

AMD card
| hexadecimal |  d |  B | D | F |
|             | 30 |  1 | 0 | 0 |
| decimal     | 48 |  1 | 0 | 0 |
| Xorg format |    |    |   |   |
|             |  B |  d | D | F |
|             |  1 | 48 | 0 | 0 |

"PCI:B@d:D:F"
"PCI:1@48:0:0"

#+BEGIN_src shell
cat /etc/X11/xorg.conf.d/21-gpu-driver.conf
#+END_SRC

#+RESULTS:
#+begin_example
# AST2500
Section "Device"
    Identifier     "GPU0"
    Driver         "modesetting"
    BusID          "PCI:2@5:0:0"
    VendorName     "ASpeed Corporation"
EndSection

# WX7100
Section "Device"
    Identifier     "GPU1"
    Driver         "modesetting" # or amdgpu if you have xf86-video-amdgpu installed
    BusID          "PCI:1@48:0:0"
    VendorName     "AMD Corporation"
EndSection

# this is absolutely necessary, it tells xorg which GPU to use for the screen
Section "Screen"
    Identifier     "Screen0"
    Device         "GPU1"
EndSection
#+end_example
**** NO upgrade openBMC bios/firmware and disable onboard GPU via

luke-jr says that the latest BMC v 2.00 is buggy.

ON-BOARD VGA DISABLE JUMPER

See the [[*raptor pdf user's guide:][raptor pdf user's guide:]] for details

I believe that we need to update the firmware in order to do this:

The current firmware has a web gui apparently, which is pretty cool!

I should be able to connect to the BMC firmware via ssh, when the machine has
power, but is not currently running an OS.  First find the machine's IP address:

***** find the ip address

#+BEGIN_SRC shell
ip address
#+END_SRC

#+RESULTS:
#+begin_example
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enP4p1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 2c:09:4d:00:08:9e brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.60/24 brd 192.168.1.255 scope global dynamic noprefixroute enP4p1s0f0
       valid_lft 82733sec preferred_lft 71933sec
    inet6 fe80::7596:9965:a3f3:a1a5/64 scope link
       valid_lft forever preferred_lft forever
3: enP4p1s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 2c:09:4d:00:08:9f brd ff:ff:ff:ff:ff:ff
4: wlP51p1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether e0:06:e6:72:03:91 brd ff:ff:ff:ff:ff:ff
#+end_example

It appears that the =2:= is the one that is actually working, so I used that ip
address:

~ssh root@192.168.1.60~

***** default BMC password
| username | password |
| root     | OpenBmc  |

In order to update to openbmc v2, I need to first ensure that the firmware is at
version Ensure that the BMC and PNOR was previously updated to System Package
v1.06, and that that your system successfully boots after that update.  Detailed
upgrade instructions can be found on the [[https://wiki.raptorcs.com/wiki/File:Talos-ii-openbmc-v2.00-bundle.tar][wiki]].

The wiki shows that there are 3 upgradeable things:

- BMC
- PNOR
- FPGA

marcus_c from irc in #talos-workstation seems to think that you do not need to
upgrade the FPGA. He has never updated his.  He also thinks that the PNOR does
not really need to be updated either.

***** [[https://wiki.raptorcs.com/wiki/Troubleshooting/BMC_Connection_Guide][troubleshooting BMC connection guide]]

does the BMC even have an IP address?

*** Where to find X logs
/var/log/gdm/greeter.log
/var/lib/gdm/.local/share/xorg/Xorg.1.log
*** toggling gdm to use X/wayland

This does not appear to work.

#+BEGIN_SRC shell
cat /etc/gdm/custom.conf | grep 'Wayland'
#+end_src

#+RESULTS:
: #WaylandEnable=false
: WaylandEnable=true

*** DONE install icewm, and put that in ~/.xinitrc & startx

This worked!  I can run startx on tty2!


*** q66's advice

**** DONE enable syslog-ng service

**** DONE make sure logind and dbus are started.

#+begin_src
dinitctl list
#+end_src
**** DONE start gdm and the read through /var/log/messages and /var/log/auth.log


*** The old hack to start wayland upon console login.

#+begin_src shell
cat ~/.profile
#+end_src

#+RESULTS:
: #!/usr/bin/bash
:
: export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
:
: if [[ -z "${DISPLAY}" && "${XDG_VTNR}" == 4 ]]; then
:     gnome-shell --wayland
: fi


* Setting up Bitcoin knots/bitcoin core or bitcoin
** github repo

  The github repo has lots of good information to help me out:


  https://bitcoinknots.org/#downl;;oad

  https://github.com/bitcoinknots/bitcoin

  https://github.com/bitcoinknots/bitcoin/tree/23.x-knots/doc

  https://github.com/bitcoinknots/bitcoin/blob/23.x-knots/doc/build-unix.md

  https://github.com/bitcoinknots/bitcoin/blob/23.x-knots/doc/build-fr;;eebsd.md

  https://github.com/bitcoinknots/bitcoin/blob/23.x-knots/doc/dependencies.md

  I can get help from webchat.freenode.net  #bitcoin-dev

  luke-jr says that I can compile bitcoin knots from source fairly easily.

  download a release.  Install dependencies:

  https://download.qt.io/official_releases/qt/

  
  #BEGIN_SRC shell
  doas apk add libevent 
  #+END_SRC

 ~./configure gmake && gmake check && gmake install~


** NO Packaging bitcoin knots for chimera linux

  q66 is NOT ok with me packagine qt5 for chimera linux.  He is going to
  package qt6 instead.  And he is not ok with me packaging bitcoin-knots
  either.

  This is the documentation for packaging in chimera.

  https://github.com/chimera-linux/cports
  https://github.com/chimera-linux/chimerautils



** Alternatively I can package bitcoin knots for guix and install
guix on chimera linux. And guix already has qt packaged. Do they have
5.15.2 packaged?

Guix has qt5compat, which are some libraries that allow you to run Qt5 applications on Qt6.

They also have qtbase version 5.15.8.

:ManuallyInstallingGPG:
  A showstopper for using guix on chimera linux at the moment, is that chimera
  does not have gpg packaged. BUT there is a pull request for it:

  https://github.com/chimera-linux/cports/pullshttps://github.com/chimera-linux/cports/pulls

  So I will use chimera's build system to install gpg, and then I should
  be able to install qt5 from guix.  And I can possibly package
  bitcoin knots for guix.

  First let's add the the eater's gpg package:

  #+BEGIN_SRC shell
  git remote add the-eater https://github.com/the-eater/cports
  git fetch the-eater
  #+END_SRC

  #+Results:
  #+begin_example:
  remote: Enumerating objects: 314, done.
  remote: Counting objects: 100% (184/184), done.
  remote: Compressing objects: 100% (68/68), done.
  remote: Total 314 (delta 102), reused 167 (delta 94), pack-reused 130
  Receiving objects: 100% (314/314), 63.49 KiB | 1.44 MiB/s, done.
  Resolving deltas: 100% (103/103), completed with 14 local objects.
  From https://github.com/the-eater/cports
   * [new branch]        cbuild/show-symlink-source -> the-eater/cbuild/show-symlink-source
   * [new branch]        master                -> the-eater/master
   * [new branch]        pkg/gcompat/new       -> the-eater/pkg/gcompat/new
   * [new branch]        pkg/libfuse2/new      -> the-eater/pkg/libfuse2/new
   * [new branch]        pkg/weechat/3.8       -> the-eater/pkg/weechat/3.8
   * [new branch]        pkg/xwayland/patch/allow-overflow -> the-eater/pkg/xwayland/patch/allow-overflow
   * [new branch]        pkg/yt-dlp/2023.02.17 -> the-eater/pkg/yt-dlp/2023.02.17
   * [new branch]        pkgbulk/flatpak/new   -> the-eater/pkgbulk/flatpak/new
   * [new branch]        pkgbulk/gfxtools/new  -> the-eater/pkgbulk/gfxtools/new
   * [new branch]        pkgbulk/gpg/new       -> the-eater/pkgbulk/gpg/new
   * [new branch]        pkgbulk/intel-stack/new -> the-eater/pkgbulk/intel-stack/new
   * [new branch]        pkgbulk/qemu          -> the-eater/pkgbulk/qemu
  #+end_example

  It looks like the gpg package is located in branch "pkgbulk/gpg/new".
  What is that branch name?

  #+Begin_SRC shell
  git branch -r
  #+End_SRC

  #+RESULTS:
  #+BEGIN_EXAMPLE
  EXPORT EDITOR=nano
  git merge the-eater/pkg/gpg/new
  ./cbuild pkg contrib/gnupg
  #+END_EXAMPLE

  #+Results:
  #+begin_example
  configure: WARNING:

  It seems that you are not using GNU make.  Some make tools have serious
  flaws and you may not be able to build this software at all. Before you
  complain, please try GNU make:  GNU make is easy to build and available
  at all GNU archives.  It is always available from ftp.gnu.org:/gnu/make.



bmake: stopped in /builddir/gnupg-2.4.0/build
=> A failure has occurred!
Traceback (most recent call last):
  File "/home/jeff/prog/chimera/cports/src/runner.py", line 1359, in fire
    case "check" | "install" | "pkg": do_pkg(cmd)
                                      ^^^^^^^^^^^
  File "/home/jeff/prog/chimera/cports/src/runner.py", line 1066, in do_pkg
    build.build(
  File "/home/jeff/prog/chimera/cports/src/cbuild/core/build.py", line 111, in build
    buildm.invoke(pkg, step)
  File "/home/jeff/prog/chimera/cports/src/cbuild/step/build.py", line 14, in invoke
    pkg.run_step("build", optional = True)
  File "/home/jeff/prog/chimera/cports/src/cbuild/core/template.py", line 1069, in run_step
    if not run_pkg_func(self, "do_" + stepn) and not optional:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeff/prog/chimera/cports/src/cbuild/core/template.py", line 165, in run_pkg_func
    func(pkg)
  File "/home/jeff/prog/chimera/cports/src/cbuild/build_style/gnu_configure.py", line 8, in do_build
    self.make.build()
  File "/home/jeff/prog/chimera/cports/src/cbuild/util/make.py", line 80, in build
    return self._invoke(
           ^^^^^^^^^^^^^
  File "/home/jeff/prog/chimera/cports/src/cbuild/util/make.py", line 63, in _invoke
    return self.template.do(
           ^^^^^^^^^^^^^^^^^
  File "/home/jeff/prog/chimera/cports/src/cbuild/core/template.py", line 1049, in do
    return chroot.enter(
           ^^^^^^^^^^^^^
  File "/home/jeff/prog/chimera/cports/src/cbuild/core/chroot.py", line 633, in enter
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['bwrap', '--unshare-all', '--hostname', 'cbuild', '--ro-bind', PosixPath('/home/jeff/prog/chimera/cports/bldroot'), '/', '--bind', PosixPath('/home/jeff/prog/chimera/cports/bldroot/builddir'), '/builddir', '--ro-bind', PosixPath('/home/jeff/prog/chimera/cports/bldroot/destdir'), '/destdir', '--ro-bind', PosixPath('/home/jeff/prog/chimera/cports/sources'), '/sources', '--dev', '/dev', '--proc', '/proc', '--tmpfs', '/tmp', '--tmpfs', '/var/tmp', '--new-session', '--die-with-parent', '--bind', PosixPath('/home/jeff/prog/chimera/cports/cbuild_cache'), '/cbuild_cache', '--uid', '1337', '--gid', '1337', '--chdir', PosixPath('/builddir/gnupg-2.4.0/build'), '--ro-bind-data', '5', '/tmp/cbuild-lld-args', 'linux64', '--', 'bmake', '-j64']' returned non-zero exit status 2.
  #+end_example


I had to make some minor changes to the template.py based on suggestions from
q66:

Add gmake to hostmakedepends and add
make_cmd = "gmake"

q66 says that I need to add a local repository.

[15:05] <q66> you add your local repo to repositories and install your packages
[15:23] <newChimeraUser> ok.  I think that is with apk.  don't tell me the answer...I will try to figure it out.
[15:25] <newChimeraUser> I think I need to edit /etc/apk/repositories.d/
[15:25] <newChimeraUser> I will go ahead and create a repo on notabug and go from there.
[15:29] <newChimeraUser> ok...I'm not certain how to add a local repository.
[15:52] <q66> uh, it's just a path
[15:53] <q66> /path/to/cports/packages/main
[15:53] <q66> /path/to/cports/packages/contrib
[15:56] <newChimeraUser> ok. thanks

#+BEGIN_SRC shell
cat /etc/apk/repositories.d/02-local-repo-for-gpg.list
#+END_SRC

#+RESULTS
: /home/jeff/prog/chimera/cports/packages/contrib


  Now I can install gpg via:
  ~doas apk add --allow-untrusted gnupg~


  :END:

guix has packaged =bitcoin-core=, I can modify that package definition to
package bitcoin-knots.

The current package definition is [[file:~/prog/gnu/guix/guix-packages/gnu/packages/bitcoin-knots.scm::(list autoconf][here.]]

** DONE Or I can just install bitcoin-core from guix and run that
* guix stuff
** installing guix on chimera linux

You can install guix via these commands:

#+BEGIN_src shell
wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
doas chmod u+x guix-install.sh
doas ./guix-install.sh
#+END_SRC

Add in the export line so I can use the guix binaries.

#+BEGIN_src shell
cat ~/.profile
#+END_SRC

#+RESULTS:
#+begin_example
#!/usr/bin/bash

export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"

gnome-shell --wayland
#+end_example

** starting the guix daemon manually

  [1682531003.3N]: [ FAIL ] unsupported init system; run the daemon manually:
  ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild

hint: Consider installing the `glibc-locales' package and defining
`GUIX_LOCPATH', along these lines:

** set up guix daemon via dinit

  #+BEGIN_SRC shell
  cat /etc/dinit.d/guix-daemon
  #+END_SRC

  #+RESULTS:
  #+begin_example
  # guix-daemon service
  type = process

  # run this command as root
  run-as = root
  command = /root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild
  # depends-on = bar
  # waits-for = baz

  # uncomment this next line once you know this works
  # before = login.target
  before = network.target
  #+end_example


https://davmac.org/projects/dinit/man-pages-html/dinitcheck.8.html

https://davmac.org/projects/dinit/man-pages-html/dinit-service.5.html 

So if you cannot get the daemon to autostart, then this will

~doas dinitctl start guix-daemon~ work.
