Previously, meta.platforms would be checked for each package when
generating package attributes for a system, so that unsupported packages
would not have an output attribute. This commit removes that behavior.
Now `nix flake show` will succeed even if packages fail to evaluate on
other platforms. `nix flake show --all-systems` will still fail though.
This results in not enabling shorthandOnlyDefinesConfig, allowing
imports to be set in submodules. This can, for example, allow a devShell
to import another devShell's config to extend it.
If the `src` passed to flakelight contains a flake.lock, it will now be
read and used to set defaults for `inputs`. Explicitly passed inputs
will override this.
Since the formatter always depended on devShell packages, building the
formatter involved building all the devShell packages, which can be
slow.
In the case where formatters are set to plain strings, such as
"nixpkgs-fmt", depending on the devShell packages is necessary in order
to put the formatting utility on the path. But when a formatters option
is set to an package, such as "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt",
then that formatter option does not depend on the devShell packages.
Flakelight now detects if any of the configured formatters are using the
first form, and only if so does it add the devShell packages dependency.
This allows the first form to still work, without incurring a cost for
flakes that only use the second form.
Users can use the second form for all formatters options if they wish to
not build the devShell packages when using the formatter.
A user whose flake only has a package would expect it to be used when
running `nix develop`. But since theres probably an automatically
created devShell, the package's deps will not be available in the shell.
If a default package exists, it makes sense for its deps to be available
by default in the default devShell.
`devShell` accepted either a package def, a submodule value, or a
function to a submodule value. `devShells` only accepted package defs.
This brings all the options of `devShells` to any devShell configured
with `devShells`.
`nullOr`'s merge function requires definitions to all be null or all be
non-null. It was being used where the intent was that null be used as a
value representing unset, and as such the merge should return null if
all definitions are null and ignore nulls otherwise. This adds a type
with that merge semantics.
Before, devShell could be set to a submodule config, a package def, or a
function taking module args and returning a submodule config. This
changes the last form to take the package set instead.
This enables cleaner configuration by not needing each option to
individually be a function of pkgs. Passing pkgs also gives more
flexibility as all the module args are available under the `moduleArgs`
attr.
Code that relied on module args not directly in the package set will now
have to access them from the `moduleArgs` attr.
Accessing some of the stdenvs would cause an infinite recursion. We can
continue to rely on base stdenv and also bail if any field other than
mkDerivation is used. All the stdenvs supported have a subset of the
attrs of base stdenv, so this is safe.
If a package uses `pkgs` and tries to get a non-existing package, there
will be an uncachable error. As we cannot control this, this method
needs to be removed. Instead of using this method, the mocked pkgs
should be extended to support more cases.
If a package depends on a package with same name, this causes an
infinite recursion as it tries to depend on itself. This is not likely
what was intended, and breaks ability to re-export packages, so instead
if a package depends on the same name, that now refers to the previous
version.
Previously null was used when a value could not be loaded. This
prevented setting a value to null using a nixDir auto-load.
This change removes the use of null as a special value when loading from
nixDir, allowing it to be used as a normal value.
This removes the manual configuration of which options are auto-loaded.
Now all options are eligible except for "nixDir" and "_module" as those
would cause inf recursions.
Additionally, instead of setting name aliases in the nixDir module, a
config option is added, enabling other modules to extend the aliases
lists.
The mock pkgs set passed `{}` as the value for unknown args; if a
package def tried to evaluate one, this can raise an error that can't be
caught. Replacing the default value with `throw ""` enables bailing out
if one of the fake args is accessed.
Many attributes can take moduleArgs when auto-loaded in order to
facilitate access to them from other files. Those same attributes could
not take moduleArgs when included directly, which was inconsistent.
With this change, all attributes that could take moduleArgs when
auto-loaded can now always do so. Auto-loading no longer needs special
cases.
This edge case was inconsistent between setting outputs directly and
auto-loading. Setting directly did not support args, so just merged
sets, thus resulting in a __functor flake output. When autoloading, a
set with a __functor attr was treated as a function and passed module
args.
To correct this inconsistency, outputs now always supports taking args,
and has the autoloading behavior.
Code that relied on previous behavior is easy to fix, as the value needs
to be converted to a function, which can then return the set with
__functor.
optFunctionTo results in a function which needs to be called when using
the option value. This is needed when the argument is not known when
building types (such as with pkgs). When the args are known (for
example, moduleArgs), this leads to more complex code than just calling
the function and resulting in the target type. optCallWith does the
latter.
Previously, devShell was inconsistent when setting it to a function.
When setting directly, a function was assumed to be a package definition
and was used to set devShells.default directly. When auto-loading, a
function was assumed to take module args, and result in config (not a
derivation).
This now enables both behaviors in either case by detecting if a
function is a package definition or if it expects module args and
handling it accordingly.