-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
flake: defragment lib+wrappers, also cleanup tests #2104
Draft
MattSturgeon
wants to merge
2
commits into
nix-community:main
Choose a base branch
from
MattSturgeon:wrappers_in_lib
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+95
−103
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
lib: include standalone wrapper in top-level
lib
- Defragment lib-related flake-modules - Expose the standalone-wrapper functions in the `lib`
commit 7aa0fa372dc14d9f7fadb9737d398a33e8c72504
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
{ | ||
self, | ||
config, | ||
lib, | ||
withSystem, | ||
getSystem, | ||
... | ||
}: | ||
{ | ||
flake.lib = lib.genAttrs config.systems ( | ||
lib.flip withSystem ({ pkgs, ... }: import ../lib { inherit pkgs lib; }) | ||
); | ||
perSystem = | ||
{ self', pkgs, ... }: | ||
{ | ||
# `helpers` is used throughout the flake modules | ||
_module.args = { | ||
inherit (self'.lib) helpers; | ||
}; | ||
|
||
legacyPackages = { | ||
# Export nixvim's lib in legacyPackages | ||
lib = import ../lib { | ||
inherit pkgs lib; | ||
flake = self; | ||
}; | ||
|
||
# Historically, we exposed these at the top-level of legacyPackages | ||
# TODO: Consider renaming the new location, and keeping the old name here? | ||
inherit (self'.legacyPackages.lib) makeNixvimWithModule makeNixvim; | ||
}; | ||
}; | ||
|
||
# Also expose `legacyPackages.<system>.lib` as `lib.<system>` | ||
flake.lib = lib.genAttrs config.systems (system: (getSystem system).legacyPackages.lib); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
# Args probably only needs pkgs and lib | ||
{ | ||
flake, | ||
pkgs, | ||
lib ? pkgs.lib, | ||
_nixvimTests ? false, | ||
... | ||
}@args: | ||
{ | ||
lib.fix (self: { | ||
# Add all exported modules here | ||
check = import ./tests.nix { inherit lib pkgs; }; | ||
helpers = import ./helpers.nix (args // { inherit _nixvimTests; }); | ||
} | ||
|
||
# TODO: Consider renaming these? | ||
makeNixvimWithModule = import ../wrappers/standalone.nix pkgs flake; | ||
makeNixvim = module: self.makeNixvimWithModule { inherit module; }; | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what were you thinking for these names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mkNixvim
andmkNixvimWith
mk
overmake
, although it's not consistentWith
suffix is conventionally used in nixpkgs for a more powerful function variant that takes structured attr argsWithModule
is misleading, because both functions take a moduleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was throwing me when looking at their definitions, as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'd like to rename these, I'm hesitant to do so yet as there's other changes I'd like to make and I think we should minimize user-facing refactoring where possible.
In particular, I'd like to get to a point where our
lib
(including the standalone wrapper) doesn't depend onpkgs
orsystem
. This matches the design of other similar flakes like nixos and home-manager, whose equivalent function (e.g.nixpkgs.lib.nixosSystem
) is made available without being in the "perSystem" part of the flake outputs.Achieving this goal may be fairly involved though and require a few breaking changes and ugly compromises, including re-imagining the standalone wrapper and it's function signature. That'd be the optimal time to rename it, I think.
EDIT: #2186