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

Refactor Nix Code (remove iogx) #6795

Merged
merged 15 commits into from
Feb 4, 2025
Merged

Refactor Nix Code (remove iogx) #6795

merged 15 commits into from
Feb 4, 2025

Conversation

zeme-wana
Copy link
Contributor

@zeme-wana zeme-wana commented Jan 16, 2025

iogx was created as a top-level abstraction layer for Haskell projects at IOG. It wraps haskell.nix, simplifying the process of setting up a working Flake. It makes several assumptions and provides additional features like a more powerful development shell, Read the Docs integration, and pre-configured pre-commit hooks.

Since its integration into Plutus, some of these features have become obsolete (e.g., Read the Docs), and we’ve realized we can rely more directly on haskell.nix for the rest.

nixpkgs-2405.follows = "haskell-nix/nixpkgs-2405";

nixpkgs.follows = "haskell-nix/nixpkgs";
Copy link
Contributor

Choose a reason for hiding this comment

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

Used to follow nixpkgs-unstable, switched to nixpkgs now. Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I recall correctly, we used to follow nixpkgs-unstable in order to access some packages not available in nixpkgs.
But in general we want to follow a stable nixpkgs if possible.

@@ -2,18 +2,10 @@
description = "Plutus Core";

inputs = {

iogx = {
Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, this PR has no explanation, and I am not clear on the following:

  • what is the problem with using iogx ?
  • why is it used in the first place? What value does it add?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I added a comment, and a follow up here:
I wanted to explore what the code would look like without iogx and whether the shell would be lighter as a result (it is).
At this point, iogx doesn’t seem to provide enough value to justify its (future) maintenance cost. Removing it also makes the codebase more accessible to future maintainers.

Comment on lines +34 to +36
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
import ./nix/outputs.nix { inherit inputs system; }
);
Copy link
Contributor

Choose a reason for hiding this comment

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

What I understand here is that instead of using iogx to create flake outputs we're creating outputs ourselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes iogx worked some magic and included some outputs in addition to the one explicitly defined by the user.

};

flake-utils.url = "github:numtide/flake-utils";

pre-commit-hooks.url = "github:cachix/git-hooks.nix";
Copy link
Contributor

@Unisay Unisay Jan 31, 2025

Choose a reason for hiding this comment

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

IIUC, before this output was added by iogx.lib.mkFlake, right? Are there any other outputs that were added by iogx and are not present now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this input was added by iogx. There are no other hidden inputs.

@@ -1,6 +1,6 @@
{ repoRoot, inputs, pkgs, system, lib }:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get what exactly do these changes in the agda-related file have to do with iogx removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iogx expected each nix file to be a function from { repoRoot, inputs, pkgs, system, lib }:.
This is no longer the case.

@@ -1,12 +1,14 @@
{ repoRoot, inputs, pkgs, system, lib }:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: not clear how these changes are related to the iogx removal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

in

{
inherit __internal;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this __internal indirection needed? Can't you inherit what's int the __internal directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to pollute the top-level flake namespace with a bunch of things.
This is only used for debugging.
The top-level should only have packages, devShells, etc...


flattened-ci-jobs = utils.flattenDerivationTree ":" nested-ci-jobs;

ciJobs = utils.flattenDerivationTree ":" nested-ci-jobs.${system};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you refer to the flattened-ci-jobs above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish, but no, we'll have to live with a little repetition

@@ -1,6 +1,5 @@
# editorconfig-checker-disable-file

{ repoRoot, inputs, pkgs, system, lib }:
{ inputs, pkgs, lib, agda-with-stdlib, r-with-packages }:
Copy link
Contributor

Choose a reason for hiding this comment

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

YaY! this way the dependencies are more explicit, liking it!

@@ -12,18 +11,9 @@ let

src = ../.;

shell = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this shell getting removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been moved to nix/shell.nix:project.shellFor which is now the only source of truth for all shell things

@@ -1,4 +1,4 @@
{ repoRoot, inputs, pkgs, system, lib }:
{ pkgs }:
Copy link
Contributor

Choose a reason for hiding this comment

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

its only the rPackages that's used, I suggest declaring it as a parameter directly, avoiding passing in all the unnecessary pkgs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather draw the line at pkgs and let consumers pull from it.
Also it's both rPackages and rWrapper

@@ -0,0 +1,16 @@
{ lib }:
{
flattenDerivationTree = separator: set:
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is only used in the outputs.nix, I'd simply keep it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True but I prefer it here. One day it could be used elsewhere, or nix/utils.nix could have more functions.

@zeme-wana zeme-wana enabled auto-merge (squash) February 4, 2025 08:43
@zeme-wana zeme-wana disabled auto-merge February 4, 2025 10:19
@zeme-wana zeme-wana merged commit bb1ff54 into master Feb 4, 2025
4 of 7 checks passed
@zeme-wana zeme-wana deleted the no-iogx branch February 4, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants