Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nix to create distribution-independent binary releases (or AppImages) #22

Closed
balsoft opened this issue Jan 28, 2019 · 17 comments
Closed

Comments

@balsoft
Copy link

balsoft commented Jan 28, 2019

There is a wonderful project, nix-bundle, which allows to create distribution-independent executables with arx from nix expressions. I have created some sample executables (google drive, 35MB, zip) from master, which I encourage you to try and run on your distro. In theory, all it takes to run is to mark them as executable. Unfortunately, they're quite slow and big as they need to carry all the dependencies with them. nix-bundle also provides some support functions to create AppImages, which would be much faster, but they need additional work to be built.

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

It looks like building AppImages requires a .desktop file. I think it would be a good idea to add them anyways (one for termNote, one for noted).

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

I think I can build AppImages now. I am going to test everything to see if it works (AppImages don't work on NixOS by default, I'll have to install some additional scripts to test them)

@balsoft balsoft changed the title Use nix to create distribution-independent binary releases Use nix to create distribution-independent binary releases (or AppImages) Jan 28, 2019
@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

I get some strange errors. Still, here's an AppImage for termNote (the executable itself; I can also build an AppImage for noted, but it has strange errors as well).

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

Well, I don't know how to fix errors with AppImages, but I've got bundles to be smaller and run faster. Maybe they're good enough for the first couple of releases?
Going for a PR.

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

We can automatically add releases from travis: https://docs.travis-ci.com/user/deployment/releases/
On the nix side, that will mean something like

language: nix
script:
  - nix-build 
  - nix-build -A bundles.termNote -o termNote 
  - nix-build -A bundles.noted -o noted
deploy:
  # Other setup here
  file:
    - noted
    - termNote

(Although I am not sure script can be a list)

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

Verified that bundles work on Tiny Core Linux 64 bit. That probably means that they work practically everywhere.

@ghost
Copy link

ghost commented Jan 28, 2019

Will test on Arch, altho i couldn't get nix itself to work.

@balsoft
Copy link
Author

balsoft commented Jan 28, 2019

i couldn't get nix itself to work.

What did you do and what was the problem? Last time I tried to run nix on arch it worked fine (I think that was summer of 2018). curl https://nixos.org/nix/install | sh worked for me.

@balsoft
Copy link
Author

balsoft commented Jan 29, 2019

Anyways, it seems automatic travis deploys are working! https://github.com/balsoft/termNote/releases/tag/v1.2.4
Please see .travis.yml from my fork to see what's going on. I recommend running travis setup releases first, then edit the resulting file manually (importantly, add file, draft and skip_cleanup).

@ghost
Copy link

ghost commented Jan 29, 2019

How do these work? does it create an automatic release when you push a new tag? also, i don't quite get what you mean with running travis setup releases

@balsoft
Copy link
Author

balsoft commented Jan 29, 2019

With configuration that I used, it makes a release for every build, but it puts them in drafts so that you can manually un-draft them. You can also make releases when tags are pushed by adding

deploy:
  on:
    tags: true

to .travis.yml

travis setup releases

travis is a CLI utility that allows you to configure .travis.yml automatically (e.g. it added the api_key token in my .travis.yml)
I got it from nixpkgs, but it can be installed from AUR, I suppose.

@ghost
Copy link

ghost commented Jan 29, 2019

Will look into it tomorrow.

@balsoft
Copy link
Author

balsoft commented Jan 30, 2019

Do bundles work for you on arch? They give some strange errors in Virtualbox liveISO.

$ wget https://github.com/balsoft/termNote/releases/download/v1.2.3/termNote
$ chmod +x termNote
$ ./termNote
terminate called after throwing an instance of 'std::experimental::filesystem::v1::__cxx11::filesystem_error'
   what():  filesystem error: cannot create directory: No such file or directory [/root/.termNote/]

I don't know if that comes from glibc version mismatch, or some other cause.

@balsoft
Copy link
Author

balsoft commented Jan 30, 2019

Hmm, it seems to be kind of deliberate - it runs termNote in sandbox essentially, thus limiting it's abilities to read/write. Investigating right now.

@balsoft
Copy link
Author

balsoft commented Jan 30, 2019

matthewbauer/nix-bundle#33 seems to be the issue here.

@balsoft
Copy link
Author

balsoft commented Jan 30, 2019

Ah. It looks like it fails because /root is not passed through to sandbox, while /home is. That's why it worked in tiny core - you are logged in as non-root user there by default.

@balsoft
Copy link
Author

balsoft commented Jan 30, 2019

matthewbauer/nix-bundle#43 is the solution.

@muxelplexer muxelplexer closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants