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

Keep splitting libcmd headers & files #7748

Merged
merged 3 commits into from
Feb 20, 2023

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Feb 4, 2023

Motivation

More splitting things up for tidiness and/or NixOS/rfcs#134 sake.

Each commit can be understood in isolation:

Split out InstallableFlake and InstallableAttrPath

Picking up where #7744 left off.

Slight cleanup of InstallablesCommand::load

See comments below, just removing dead code and deduplicate branches.

Split out CmdRepl and editorFor

The REPL itself and the nix repl CLI are conceptually different things, and thus deserve to be in different files.

I also think libcmd should have the infrastructure for making the commands, but not the commands themselves. CmdRepl, previously there, not back inside the Nix binary with the other commands, would be one of those "commands themselves".

An existing "obvious home" for editorFor didn't pop into my mind, so I just gave it its own header and file.

Context

Depends on #7744, see the PR's context for additional information.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or bug fix: updated release notes

@Ericson2314 Ericson2314 changed the title Split other installables Keep splitting libcmd headers & files Feb 4, 2023
@Ericson2314 Ericson2314 marked this pull request as draft February 4, 2023 04:07
@Ericson2314 Ericson2314 assigned Ericson2314 and unassigned edolstra Feb 10, 2023
@@ -103,6 +103,7 @@ outputs/

*.a
*.o
*.o.tmp
Copy link
Member Author

Choose a reason for hiding this comment

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

Oh oops sorry this snuck in here. Clang build temp files like this, which I noticed when I started developing with clang, and so I added this line while working. They are deleted by Clang after the build is complete, but if you run git status while a build is in progress (say in another terminal), they clutter the output.

I had meant to PR this separately; let me know if I still should.

@dpulls
Copy link

dpulls bot commented Feb 13, 2023

🎉 All dependencies have been resolved !

@Ericson2314 Ericson2314 marked this pull request as ready for review February 13, 2023 13:57
@Ericson2314 Ericson2314 marked this pull request as draft February 13, 2023 13:57
@Ericson2314 Ericson2314 marked this pull request as ready for review February 13, 2023 13:58
@Ericson2314 Ericson2314 changed the base branch from master to 0.7-release February 13, 2023 14:05
@Ericson2314 Ericson2314 changed the base branch from 0.7-release to master February 13, 2023 14:05
@Ericson2314 Ericson2314 assigned tomberek and unassigned Ericson2314 Feb 13, 2023
@@ -1000,8 +715,8 @@ void InstallablesCommand::prepare()
installables = load();
}

Installables InstallablesCommand::load() {
Installables installables;
Copy link
Member Author

Choose a reason for hiding this comment

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

This variable was unused; surprised there was no warning!

if (_installables.empty()) {
if (useDefaultInstallables())
return {"."};
return {};
Copy link
Member Author

Choose a reason for hiding this comment

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

Since _installables is empty, this is the same as return _installables; below.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-02-10-nix-team-meeting-minutes-31/25438/1

@@ -6,7 +6,7 @@ libcmd_DIR := $(d)

libcmd_SOURCES := $(wildcard $(d)/*.cc)

libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers -I src/nix
Copy link
Member Author

Choose a reason for hiding this comment

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

This layer violation is no longer needed after moving these things around.

Copy link
Member Author

@Ericson2314 Ericson2314 Feb 17, 2023

Choose a reason for hiding this comment

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

The issue was the #include "repl.md", which was left behind in src/nix not moved to src/libcmd. It could of been moved over, but this PR solves it by moving (the CmdRepl part of) repl.cc back.

@Ericson2314 Ericson2314 mentioned this pull request Feb 20, 2023
10 tasks
@fricklerhandwerk fricklerhandwerk added the RFC Related to an accepted RFC label Feb 20, 2023
@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Feb 20, 2023

Discussed on the Nix team meeting:

  • @tomberek: lots of changes, would be comfortable with having more eyes on it

    refactoring is just like transformation into a different coordinate frame where the desired user-facing change is small

  • @edolstra: move of the REPL into the header is questionable. the problem is, C++ being what it is, it leaks half of the implementation into the interface
    • (some discussion about how to wire up the REPL)
    • otherwise looks good
  • @edolstra: add an abstract REPL class to keep the header small

The REPL itself and the `nix repl` CLI are conceptually different
things, and thus deserve to be in different files.
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-02-20-nix-team-meeting-minutes-34/25625/1

@tomberek tomberek merged commit 924ef67 into NixOS:master Feb 20, 2023
@Ericson2314 Ericson2314 deleted the split-other-installables branch February 20, 2023 15:29
@edolstra
Copy link
Member

This broke the noGC builds: https://hydra.nixos.org/build/210107828

And the aarch64-linux build is segfaulting: https://hydra.nixos.org/build/210107827

@tomberek
Copy link
Contributor

looking….

@Ericson2314
Copy link
Member Author

I know how to fix the first, I guess I will try to do a binfmt misc qemu GDB for the second.

@Ericson2314
Copy link
Member Author

The aarch64-linux failure is not due to this but instead #6538

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-team-report-2022-10-2023-03/27486/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Related to an accepted RFC
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants