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

Focus on stable Nix with npins instead of Flakes #166

Merged
merged 3 commits into from
Mar 15, 2024
Merged

Focus on stable Nix with npins instead of Flakes #166

merged 3 commits into from
Mar 15, 2024

Conversation

infinisil
Copy link
Member

Focus on stable Nix and use npins for dependencies.
With this PR, the flake.nix relies on default.nix, rather than the other way around.

I believe the only negative impact is that downstream Flake users can't use the follows mechanism anymore to override nixpkgs. Unfortunately there's no way to give a better error in such a case.

Instead what works is

import inputs.nixfmt {
  inherit system;
  nixpkgs = inputs.nixpkgs;
}

Though I don't really expect this to be very necessary.

As a side benefit, this allows passing in a patched Nixpkgs just using e.g. pkgs.applyPatches, without needing Nix to support such functionality like in NixOS/nix#6530.

- Simplifies the whole thing due to not having to mess with `system`, see NixOS/nix#3843
- Makes the lockfile _way_ smaller, see NixOS/nix#7730
@infinisil infinisil requested a review from piegamesde March 14, 2024 21:35
@infinisil infinisil changed the title Npins Focus on stable Nix with npins instead of Flakes Mar 14, 2024
@infinisil infinisil requested a review from a team March 14, 2024 21:38
@infinisil infinisil mentioned this pull request Mar 14, 2024
@dasJ dasJ merged commit 136005f into master Mar 15, 2024
1 check passed
@dasJ dasJ deleted the npins branch March 15, 2024 16:40
@Mic92
Copy link
Member

Mic92 commented Mar 15, 2024

Also how can I do offline evaluation with npins? With flakes, I can nix flake archive to get a gcroot over all inputs.

@Mic92
Copy link
Member

Mic92 commented Mar 15, 2024

Also is there a way to avoid the nixpkgs re-import? This can be costly in terms of memory? Is it maybe possible to just override nixfmt from nixpkgs with this version?

@Mic92
Copy link
Member

Mic92 commented Mar 15, 2024

Much better:

with import <nixpkgs> {};
nixfmt.overrideAttrs (old: {
  name = "nixfmt-2024-03-15";
  src = fetchFromGitHub {
    owner = "NixOS";
    repo = "nixfmt";
    rev = "136005fc3dd34ff0d6af9f8c57cd1d3d7d342537";
    sha256 = "sha256-g0MTMQZeRlKFQiKdEVc1IQ73nNeRwu0+GtUIvcm2NV4=";
  };
})

@Mic92
Copy link
Member

Mic92 commented Mar 15, 2024

Ah. There is actually: nixfmt-rfc-style

@infinisil
Copy link
Member Author

Also how can I do offline evaluation with npins? With flakes, I can nix flake archive to get a gcroot over all inputs.

I didn't know about nix flake archive, but it's a hard sell, it's documentation is pretty much just FIXME. After looking at the source code to understand what it does, it doesn't seem to gcroot anything. Also this won't work for offline builds anyways since it doesn't include any dependencies of the derivations, but let me know if I'm mistaken.

With stable Nix there's a relatively easy way to gcroot all inputs to a derivation using .inputDerivation (introduced by me a while ago, admittedly also underdocumented):

nix-build -A inputDerivation -o inputs

Though this won't gcroot any Nix inputs, so if you do a gc you'll still need internet, so it's not a complete solution either. Would be nice to see something like npins that also makes this easy.

@Mic92
Copy link
Member

Mic92 commented Mar 16, 2024

Well. It still has more documentation than inputDerivation, which doesn't appear in any manual.

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

Successfully merging this pull request may close these issues.

6 participants