srid / neuron

Future-proof note-taking and publishing based on Zettelkasten (superseded by Emanote: https://github.com/srid/emanote)
https://neuron.zettel.page
GNU Affero General Public License v3.0
1.52k stars 150 forks source link

Static builds are broken #626

Open srid opened 3 years ago

srid commented 3 years ago

To reproduce, run nix-build static.nix (will take hours to compile).

Looks to be https://github.com/NixOS/nixpkgs/issues/118731

image

Originally posted by @srid in https://github.com/srid/neuron/discussions/622#discussioncomment-774879

ghost commented 3 years ago

@srid Is this issue related to the 404 error on https://github.com/srid/neuron/releases/tag/nightly ?

srid commented 3 years ago

@oponkork Nope, not related.

This is because static build of GHC is broken on nixpkgs, and the fix for this is here: https://github.com/NixOS/nixpkgs/pull/129289

ghost commented 3 years ago

Oh, I thought you have taken down the nightly temporarily because of it.

srid commented 3 years ago

Apparently fixed in https://github.com/NixOS/nixpkgs/commit/da1cf8cb90c6675356106905422bbbe767261e9b ... once that gets to the nix channel, we can re-try static builds.

srid commented 3 years ago

After the nixpkgs update, I get failed to access 'libpython3.9.so.1.0': No such file or directory:

In function ‘assemble_lnotab’,
    inlined from ‘assemble_emit’ at Python/compile.c:5717:0,
    inlined from ‘assemble’ at Python/compile.c:6056:0:
Python/compile.c:5671: warning: writing 1 byte into a region of size 0 [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-overflow=-Wstringop-overflow=8;;]
 5671 |         *lnotab++ = k;
      |
/nix/store/vf20zcyqr3qzcjhdidzk377qankcqsqa-binutils-2.35.1/bin/ld: libpython3.9.so.1.0.lto.o: warning: relocation against `PyDictValues_Type' in read-only section `.text'
/nix/store/vf20zcyqr3qzcjhdidzk377qankcqsqa-binutils-2.35.1/bin/ld: libpython3.9.so.1.0.lto.o: relocation R_X86_64_PC32 against symbol `PyBool_Type' can not be used when making a shared object; recompile with -fPIC
/nix/store/vf20zcyqr3qzcjhdidzk377qankcqsqa-binutils-2.35.1/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
ln: failed to access 'libpython3.9.so.1.0': No such file or directory
make: *** [Makefile:659: libpython3.9.so] Error 1
error: builder for '/nix/store/81jzmjv1bxn3kclr06nll4r2sqkjc7f4-python3-3.9.5.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/fv29z8xqlgnka5zsw81lh6hshahyj0yd-ghc-8.10.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/jyg99rxjk0i6qw5xai33w9fiwnijxpz2-cabal2nix-2.17.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gcfc3k512lscy8maggdfz043lfc0d7hv-cabal2nix-neuron.drv' failed to build
(use '--show-trace' to show detailed location information)

EDIT: This appears to be https://github.com/NixOS/nixpkgs/issues/131557

srid commented 3 years ago

Now failing at time-compat tests

    resolution
      getCurrentTime:                                                             FAIL (0.15s)
        test/main/Test/Clock/Resolution.hs:57:
        resolution
        expected: 0.000000001s
         but got: 0.0000001s
      taiClock:                                                                   FAIL (0.15s)
        test/main/Test/Clock/Resolution.hs:57:
        resolution
        expected: 0.000000001s
         but got: 0.0000001s

Not the same as https://github.com/haskellari/time-compat/issues/23 but ...

Using dontCheck in project.nix has no effect however ...

srid commented 3 years ago

Using dontCheck in project.nix has no effect however ...

Yes, no idea how to fix it.

To reproduce run nix-build static.nix on https://github.com/srid/neuron/commit/9bdcdf6b491d56ca96d0bccb153878ecb4c6a88b

1 of 2 test suites (1 of 2 test cases) passed.
error: builder for '/nix/store/jgll2h7s5r3yqgy51x490m56l6jn7cqy-time-compat-1.9.5.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/h8wr1mcqi12jv85is5bpsmcw3d80x93s-aeson-1.5.6.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/d7hq9a3hdwddlswdqagypynvl187z8fm-quickcheck-instances-0.3.25.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ffz65rph57i4137q3qpagwv0nm9rsz7w-cabal2nix-2.17.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2yir3appck4x9y0p5h7prh1927dw5w3d-cabal2nix-neuron.drv' failed to build
(use '--show-trace' to show detailed location information)
srid commented 3 years ago

Wontfix (unless someone volunteers to fix), but an alternative is uploaded here: https://github.com/srid/neuron/releases/tag/1.9.35.0

ouuan commented 3 years ago

Wontfix, but an alternative is uploaded here: 1.9.35.0 (release)

This doesn't work on my Arch Linux :thinking: It gives many permission errors. Does it work on your machine, or did others test it?

srid commented 3 years ago

It works for me in WSL (Ubuntu). Same for Emanote.

What error do you see? You might have better luck reporting, and seeking help, in the Nix forum (as it was the experimental nix bundle -- which appears to use arx) that produced it).

ouuan commented 3 years ago

I tested again, and it seems that the only thing that doesn't work correctly is the PWD. It doesn't work without -d, nor with -d <relative path>, but works with -d <absolute path>.

It seems that the PWD is /, the root directory.

ouuan commented 3 years ago

Same for Emanote.

I noticed this just now:

Footnotes

  1. If the relative path passed in command-line does not work, try passing absolute paths instead.
srid commented 3 years ago

Yup, I had just added it after your comment above. I'm guessing the executable changes directory internally before launching app (neuron or emanote), thus necessitating absolute paths.

I just also realized that a bare neuron gen -wS or emanote won't work; so we always have to pass an absolute path.

ouuan commented 3 years ago

This wrapper script seems to work:

#!/bin/bash

neuron_dir="$PWD"
args=()

while [[ $# -gt 0 ]]; do
  key="$1"

  case $key in
    -d)
      neuron_dir="$(realpath "$2")"
      shift
      shift
      ;;
    *)
      args+=("$1")
      shift
      ;;
  esac
done

/opt/neuron-zettelkasten-bin/neuron -d "$neuron_dir" "${args[@]}"
srid commented 3 years ago

Re-opening because I did a new build out of curiosity using new nixpkgs and it built this time.

Anybody wanna give it a try? https://ipfs.infura.io/ipfs/QmcZ8amU7z16x2vV2CEuEGe836GMq3h5FWip9DLnzCHi6F?filename=neuron

ouuan commented 3 years ago

Re-opening because I did a new build out of curiosity using new nixpkgs and it built this time.

Anybody wanna give it a try? ipfs.infura.io/ipfs/QmcZ8amU7z16x2vV2CEuEGe836GMq3h5FWip9DLnzCHi6F?filename=neuron

neuron search gives this error:

neuron: /nix/store/1120fbipilhpsqpnbqff50cibfr6qkq2-neuron-1.9.35.3/bin/neuron-search: executeFile: does not exist (No such file or directory)

Other commands work fine.

srid commented 3 years ago

Yes, for neuron search we need to resolve #432