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

Support builds without network access #273

Open
jalil-salame opened this issue Dec 26, 2023 · 7 comments
Open

Support builds without network access #273

jalil-salame opened this issue Dec 26, 2023 · 7 comments
Labels
feature request Request for new functionality

Comments

@jalil-salame
Copy link

Issue

I am trying to package idris2-pack for nix so I can easily access idris2-pack from NixOS. nix does not allow network accesses during the build process; you need a fetch step, where all dependencies are fetched, then a build step.

Solution

Do not access the network during builds by having a fetch script that clones idris2 and idris2-pack-db, then the build only accesses them and does not need to fetch them.

Alternatives considered

  • Do not build with nix (status quo)
  • Fetch the dependencies after building pack (Using the os's idris2 compiler)

Conclusion

This seems like a nice project for me to start learning idris, would you be open to such contributions?

@buzden
Copy link
Collaborator

buzden commented Dec 26, 2023

This seems like a nice project for me to start learning idris, would you be open to such contributions?

I'm not the project author, but I'm sure such contribution would be considered unless it breaks existing workflow. I personally think that the ability of separate fetching and building is good. As an example, I use this sometimes in the Gentoo build system, when I need to build something big without an internet connection, I fetch sources first, when I have a connection, and then I can build the stuff without.

Having said that, I still don't understand your proposition. I mean, when I do pack build my-lib, at which point would you split fetching the dependencies and the build process? Or, do you propose this split between fetching and building only when you are talking about updates like pack switch?

@jalil-salame
Copy link
Author

jalil-salame commented Dec 26, 2023

Having said that, I still don't understand your proposition. I mean, when I do pack build my-lib, at which point would you split fetching the dependencies and the build process? Or, do you propose this split between fetching and building only when you are talking about updates like pack switch?

When building pack itself c:

Currently the Makefile fetches idris which is easy to patch out, but micropack tries to access/download at least one git repo.

@buzden
Copy link
Collaborator

buzden commented Dec 26, 2023

So are you talking about micropack only, or about pack update command too?

Are you talking only about those two cases, or potentially about some more commands, like pack switch and/or pack build?

@jalil-salame
Copy link
Author

So are you talking about micropack only, or about pack update command too?

Are you talking only about those two cases, or potentially about some more commands, like pack switch and/or pack build?

Just micropack for now, I am in the process of getting idris2 set up so I can learn how to use it c:

@stefan-hoeck
Copy link
Owner

If this is only about building and installing the pack application under nix, I suggest to not use micropack but write something similar to our installation script. This will make it straight forward to separate fetching all necessary libraries (plus Idris itself) from building the whole thing.

@jalil-salame
Copy link
Author

If this is only about building and installing the pack application under nix, I suggest to not use micropack but write something similar to our installation script. This will make it straight forward to separate fetching all necessary libraries (plus Idris itself) from building the whole thing.

The installation script looks easy to replicate in nix. I will see how far I can go with just that.

My main worry is that pack is inside PACK_DIR and it would be a problem for it to be outside the pack dir.

My knowledge comes from Rust, where rustup can either be installed to the system and fetch the tool chain (compiler, formatter, etc) to .rustup or the install script installs it to .rustup/bin, and then you have cargo (the package manager) that can also be installed system wide or to .rustup/bin and it installs binaries to .cargo/bin

@buzden buzden added the feature request Request for new functionality label Jul 2, 2024
@mattpolzin
Copy link
Contributor

This is an old issue, but I can offer a couple of different pieces of input.

First, Pack is now packaged in nixpkgs, so if you just want to install via nixpkgs on NixOS, you can snag it there (or pop over to that repo and snag the derivation code to make it your own). Note that Pack's self-update functionality doesn't make sense for a nix-based install of Pack and it is not supported, but other than that Pack works well under NixOS!

Second, if you want to develop Pack itself using a nix shell rather than installing its dependencies by hand, you may find something you want to borrow from the following shell.nix file:

let
  pkgs = import <nixpkgs> {};
  packageset = import (pkgs.fetchgit {
    url = "https://github.com/mattpolzin/nix-idris2-packages";
    # snag a newer revision probably if you're copying this in the future:
    rev = "14194b349a7d4e720803d6b8700d6e5f38e88a9a";
    hash = "sha256-OEWtim0UNVN3HwxmCVyHbe0SCD+dA+JMlJKd+bX569E=";
  }) {};

  inherit (packageset) idris2 idris2Lsp buildIdris';

  pack = buildIdris' {
    ipkgName = "pack";
    src = ./.;
  };
in pkgs.mkShell {
  inputsFrom = [ pack ];
  packages = [ idris2 idris2Lsp ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new functionality
Projects
None yet
Development

No branches or pull requests

4 participants