juspay / nixos-unified-template

A multi-platform Nix configuration template optimized as development environment, based on nixos-unified.
GNU Affero General Public License v3.0
173 stars 40 forks source link

Use stable Nix version #84

Closed srid closed 2 months ago

srid commented 2 months ago

Currently using latest: https://github.com/juspay/nix-dev-home/commit/b65f5b459d1bb9c2db9d8604c516e5293b5c581d

But we should use pkgs.nix. When doing this, ensure that it:

  1. Overwrites the latest Nix installed by DetSys installer (via $PATH)
  2. Ensures that /etc/nix/nix.conf is in sync with effective Nix, so as to avoid #77
srid commented 2 months ago

(2) is possible with nix-darwin, but not straightforward with home-manager.

niksingh710 commented 2 months ago

It seems the issue arises from DetSys using the latest nix package, while nix-dev-home is on the stable version, which lacks support for the new configuration variables. To resolve this, switching to the unstable branch and keeping the flake updated as DetSys's Nix package evolves should work.

However, it raises the question: why use the DetSys installer for Nix if Home Manager is already installing Nix? If DetSys is essential, setting nix.package = null in Home Manager ensures it uses the system-wide Nix package.

Currently, both Nix packages—one from DetSys (system-level) and one from Home Manager (user-level)—coexist, and the PATH order determines which one takes precedence. Ideally, there should be only one Nix package, and if it's from DetSys, you can safely set nix.package = null in Home Manager to avoid conflicts.

srid commented 2 months ago

Yes, that's probably what we should do. However, I believe it was already like that before (isn't null the default value here?) when we had those warnings (#77).

Also, relevant: https://github.com/DeterminateSystems/nix-installer/issues/1165

srid commented 2 months ago

But since home-manager cannot manage /etc/nix/nix.conf we probably should give up control of Nix version and let DetSys manage that ...

(Unless using nix-darwin, because that manage /etc/nix/nix.conf)

niksingh710 commented 2 months ago

Yes, that's probably what we should do. However, I believe it was already like that before (isn't null the default value here?) when we had those warnings (#77).

Yep, The default value is null.

The diff you mentioned in https://github.com/juspay/nix-dev-home/issues/77#issuecomment-2347123240 shows that the value before was pkgs.nix. The state of the repo at sept 10 is https://github.com/juspay/nix-dev-home/blob/138a8151e60304a70c341791a8f6cb6d1aefd390/nix/modules/home/nix.nix stating that home manager having package value pkgs.nix

niksingh710 commented 2 months ago

But since home-manager cannot manage /etc/nix/nix.conf we probably should give up control of Nix version and let DetSys manage that ...

(Unless using nix-darwin, because that manage /etc/nix/nix.conf)

yep, nixos/nix-darwin are the only ways to get root control, and iirc there is something like nixos on wsl.

with the respect of this project nix package should be managed by DetSys.

srid commented 2 months ago

I was referring to this change on aug 8

https://github.com/juspay/nix-dev-home/commit/803cdc304cbd0df45d7b34f42813295026210b12

niksingh710 commented 2 months ago

ig reverting 803cdc3 should fix then (if the issue is caused by version mismatch)

srid commented 2 months ago

And potentially revert

https://github.com/juspay/nix-dev-home/blob/b65f5b459d1bb9c2db9d8604c516e5293b5c581d/nix/modules/home/direnv.nix#L8-L9

But all of this was added as an attempt to fix these warnings in the first place! So this needs some testing.

srid commented 2 months ago

See https://github.com/nix-community/home-manager/pull/5773

So upstream nix-direnv uses pkgs.nix: https://github.com/NixOS/nixpkgs/blob/eb28b94bd14835836b539bc3854a6abf929876d4/pkgs/by-name/ni/nix-direnv/package.nix#L51 - and this conflicts with what DetSys installs, which is why we have #84

How do solve this so that nix-direnv uses whatever DetSys installs?

srid commented 2 months ago

Hmm, I see it uses "ambient Nix" and fallsback to pkgs.nix only when it not in PATH.

image

Okay, I'll revert those changes and see what happens. This time let's thoroughly solve this if it reoccurs.

srid commented 2 months ago

af55a164bb75692e75c90878d9030af736e1ed82

niksingh710 commented 2 months ago

This time let's thoroughly solve this if it reoccurs.

git bisect should help to figure out after which commit the issue popped up.

srid commented 2 months ago

nix-darwin has the same issue, btw:

https://github.com/LnL7/nix-darwin/issues/931

niksingh710 commented 2 months ago

Based on the discussion in LnL7/nix-darwin#931, it appears that NixOS manages its own Nix package, which is maintained through the NixOS configuration. However, on non-NixOS systems, such as other Linux distributions and macOS, issues arise due to inconsistent Nix installations. For instance, nix-darwin and DetSys may install different versions, leading to conflicts. To ensure consistency, it is essential for tools like nix-darwin and DetSys to check for existing Nix installations and guide users to either remove them or verify compatibility with the installed version.

niksingh710 commented 2 months ago

https://github.com/juspay/nix-dev-home/discussions/85

ig it should be discuused here.