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

Nix, package manager migration. Defaults to nixpkgs as specified at nix installation. #20

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bjgavilanes
Copy link
Contributor

The main reason about this migration is explained at 7891ace. It resumes to point out we need a way to provide a stable/maintained development environtment. In that commit, too, explains a tentative roadmap, if this PR gets merge.

At commit 52b06c8, added nix-related information to the README.md

Commits 7b10016 and aa022ad are the formatter and linting process. I would like to point out that biome has partial support to HTML and supersets, but that can be easily fix using dprint, a rust-based formatter with integrations; so we use biome just as linter.

Linter, formatter, and related tools will get managed in their own PR.

Setting up a task runner -- I'm debating wether to use make, as God intented, or just a rust-based make-inspired alternative, as the young lads out there do.

Nix is a package manager --such as apt-- based on nix, a functional programming language. We can use nix to declare global dependencies of this project -- such as pnpm and biome --; as well as project-specific.

The main reason I'm looking to use nix in this repo is I'll be able to make reproducible development environtments, declare and pin dependencies, to ensure a local-first CI pipeline. We can even containerized such workflow, allowing is to deploy, almost, everywhere.

This is the first step of our nix integration. In this commit, there's a `shell.nix` file that deploys our development environtment. It currently pins to nixpkgs repository that you configured when you installed NixOS or Nix.

This file was generated using `lorri` (https://github.com/nix-community/lorri/) and we intend to deploy the next toolkit:

lorri, for shell.nix and related files management,
direnv, for automatic integration to shell.nix -- and .envrc / .env --
npins, to pin specific dependency, a-la package-lock.json
@bjgavilanes bjgavilanes self-assigned this Dec 10, 2024
@bjgavilanes bjgavilanes added the enhancement New feature or request label Dec 10, 2024
@IvanM9
Copy link
Collaborator

IvanM9 commented Dec 10, 2024

Hi Brayen!

I have these problems when running nix-shell:

Screenshot from 2024-12-10 11-30-55
Screenshot from 2024-12-10 12-02-00

I was testing on arch linux and debian

If the user hasn't configure a nix-channel yet, `nix-shell` invocation
won't work for it expectas a <nixpkgs> channel -- that the user hasn't
configured!--

This fixes that.
@bjgavilanes
Copy link
Contributor Author

Hi, @IvanM9!, thank you for your input.

The problem is nix-shell is looking for channel; that's, the registry of nix and nix-related packages -- this is like adding a repo in Debian -- but is not declared.

At cf4d5f8, I tagged the lastes stable release at nix-shell, now this should work as expected.

Sure, this can be fixed at user side, adding channels using nix-channel command, but we intend for this to be a plug-and-play setting.

Let me know if this helps you!,
Brayen

@bjgavilanes
Copy link
Contributor Author

This is a great resource on how to install nix in imperative distribution:

https://nix-community.github.io/nix-installers/

It supports deb, pacman and rpm. We should consider writing a script for this to be setup.

mkShellNoCC is a variant that doesn't ships a C compiler. Also, remove
bashInteractive as dependency.

This changes provide us a leaner development environtment.
@IvanM9
Copy link
Collaborator

IvanM9 commented Dec 11, 2024

Works, but still sometimes there are problems with the daemon :(

Screenshot from 2024-12-10 21-12-44

@bjgavilanes
Copy link
Contributor Author

bjgavilanes commented Dec 11, 2024 via email

@IvanM9
Copy link
Collaborator

IvanM9 commented Dec 11, 2024

Yes, works

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bjgavilanes

Please include instructions on what to do when there is a problem with the nix daemon.

@bjgavilanes
Copy link
Contributor Author

bjgavilanes commented Dec 11, 2024 via email

@bjgavilanes
Copy link
Contributor Author

I haven't troubleshot problem in debian installation -- I know Arch Linux and Void Linux repo install do okay, I've done it --

I'll update README and point out potential problems / solutions. And I don't like it, but I'll make more obvious that upstream install -- a curl into sh pipe X.X -- would be best bet for anyone not having native package manager support for nix.


I have thunk deeply about this. I'll dockerize -- throught podman! -- nix workflow, for best compatibility... But that'll get done in another PR.

@bjgavilanes
Copy link
Contributor Author

I'm using distrobox to troubleshoot debian nix problem.

I haven't been able to reproduce problem with nix-daemon as @IvanM9 has pointed out.

(ins)📦[bjgavilanes@debian www]$ nix-shell 
unpacking 'https://github.com/NixOS/nixpkgs/tarball/nixos-24.11' into the Git cache...
these 44 paths will be fetched (49.76 MiB download, 235.27 MiB unpacked):
  /nix/store/nrl5m466dwdscvavf1nqzdnqhszjyy9n-acl-2.3.2
  /nix/store/nmq6s9l9zlym3qjx76zzrqbp05a63y90-attr-2.5.2
  /nix/store/p6k7xp1lsfmbdd731mlglrdj2d66mr82-bash-5.2p37
  /nix/store/2bpqfzq78d0li8hn21flnpydnmkngw3k-biome-1.9.4
  /nix/store/hl3iw85v12gh9mwgvr9yfgjgy0rk81hb-bzip2-1.0.8

Altought, reading history log shows

  489  sudo apt-get update
# (...)
  495  sudo apt install nix-setup-systemd

That I did and apt-get and then apt invocation. I don't believe this is the problem, but will try to install nix as documented in the README.

For the record, I'm testing in debian-unstable

distrobox list
ID           | NAME                 | STATUS             | IMAGE                         
6c613be53703 | debian               | Up 35 minutes      | docker.io/library/debian:unstable

Using distrobox

distrobox --version
distrobox: 1.8.0

@bjgavilanes
Copy link
Contributor Author

So, I remove nix-setup-systemd and then sudo apt autoremove

(ins)📦[bjgavilanes@debian ~]$ sudo apt remove nix-setup-systemd
The following packages were automatically installed and are no longer required:
  bash-static             libdbi-perl
  libarchive13t64         liblowdown1
  libboost-context1.83.0  libsodium23
  libcpuid17              libwww-curl-perl
  libdbd-sqlite3-perl     nix-bin
Use 'sudo apt autoremove' to remove them.

REMOVING:
  nix-setup-systemd

Summary:
  Upgrading: 0, Installing: 0, Removing: 1, Not Upgrading: 5
  Freed space: 36.9 kB

Continue? [Y/n] 
(ins)📦[bjgavilanes@debian ~]$ sudo apt autoremove
REMOVING:                       
  bash-static      libboost-context1.83.0  libdbd-sqlite3-perl  liblowdown1  libwww-curl-perl
  libarchive13t64  libcpuid17              libdbi-perl          libsodium23
# (...)

And then perform apt-get as documented in README. I worked, as previously reported.

I began to think that maybe it did work because distrobox was communicating with my host-machine's nix-daemon.service, but no!

● nix-daemon.service - Nix Daemon
     Loaded: loaded (/etc/systemd/system/nix-daemon.service; linked; preset: ignored)
    Drop-In: /nix/store/qxahi9pkgfdanxj2bfswvn44cx9wk21v-system-units/nix-daemon.service.d
             └─overrides.conf
     Active: active (running) since Wed 2024-12-25 03:03:13 -03; 1 day 19h ago
 Invocation: 276ff05ef67b4ef7b77d94f1b9c202a6
TriggeredBy: ● nix-daemon.socket
       Docs: man:nix-daemon
             https://nixos.org/manual
   Main PID: 1726 (nix-daemon)
         IP: 330.3M in, 4.1M out
         IO: 358M read, 1.7G written
      Tasks: 2 (limit: 1048576)
     Memory: 607.9M (peak: 870.2M swap: 3.4M swap peak: 3.5M)
        CPU: 2min 5.834s
     CGroup: /system.slice/nix-daemon.service
             └─1726 nix-daemon --daemon

Dec 26 15:04:41 natja nix-daemon[1726]: accepted connection from pid 130001
# (...)
Dec 26 22:42:18 natja nix-daemon[1726]: accepted connection from pid 190377, user bjgavilanes (trusted)

As last resource, I can troubleshoot in a Debian VM... However, I would advise to reinstall nix. Preferably, using upstream method IF local package manager installation still doesn't work.

@bjgavilanes
Copy link
Contributor Author

According to this thread you can fix problem with nix-daemon.socket by adding your user to the nix-users group. I added that e information to the README, too.

@IvanM9 IvanM9 self-requested a review December 30, 2024 16:25
@IvanM9
Copy link
Collaborator

IvanM9 commented Dec 30, 2024

Still having problems :(
I tried again on Arch and Debian

@bjgavilanes
Copy link
Contributor Author

bjgavilanes commented Dec 31, 2024 via email

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

Successfully merging this pull request may close these issues.

2 participants