1
1
forked from extern/flakelight
Commit Graph

208 Commits

Author SHA1 Message Date
Archit Gupta
3304eb3746 Nix now requires app programs to be paths in store 2024-02-24 21:31:24 -08:00
Archit Gupta
bac4759bcb Refactor apps to use types 2024-02-24 21:31:24 -08:00
github-actions[bot]
afa2a89bae flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/d934204a0f8d9198e1e4515dd6fec76a139c87f0' (2024-02-10)
  → 'github:NixOS/nixpkgs/5863c27340ba4de8f83e7e3c023b9599c3cb3c80' (2024-02-16)
2024-02-19 12:29:44 +00:00
Archit Gupta
efcf01325b Enable faster building of formatter
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.
2024-02-19 02:35:16 -08:00
Archit Gupta
981e22f851 Fix usage of devShell packages in formatters
Formatters should have the packages from devShell.packages, though a
regression caused PATH to not be set in the formatter. This fixes that
issue.
2024-02-19 02:03:21 -08:00
Archit Gupta
db9da2b1f7 Use mkDefault for default formatters
This enables easier overriding of formatting defaults.
2024-02-19 00:12:26 -08:00
github-actions[bot]
40af04adb6 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/e92b6015881907e698782c77641aa49298330223' (2024-02-02)
  → 'github:NixOS/nixpkgs/d934204a0f8d9198e1e4515dd6fec76a139c87f0' (2024-02-10)
2024-02-12 12:29:18 +00:00
Archit Gupta
6920686f25 Include default package in devShell.inputsFrom
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.
2024-02-11 18:09:55 -08:00
Archit Gupta
a50fbcba1a Allow all of devShells config types in devShells
`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`.
2024-02-07 01:49:29 -08:00
Archit Gupta
543e3aaa4d Replace nixpkgs nullOr type with custom type
`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.
2024-02-07 01:49:29 -08:00
Archit Gupta
9fe4cb1994 Enable devShell as a function to take packages
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.
2024-02-07 01:49:29 -08:00
Archit Gupta
1fa95e0d84 Add support for configuring legacyPackages 2024-02-07 01:49:29 -08:00
github-actions[bot]
086393b47b flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ae5c332cbb5827f6b1f02572496b141021de335f' (2024-01-25)
  → 'github:NixOS/nixpkgs/e92b6015881907e698782c77641aa49298330223' (2024-02-02)
2024-02-05 12:29:24 +00:00
github-actions[bot]
29c3d7809a flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/612f97239e2cc474c13c9dafa0df378058c5ad8d' (2024-01-21)
  → 'github:NixOS/nixpkgs/ae5c332cbb5827f6b1f02572496b141021de335f' (2024-01-25)
2024-01-29 12:29:23 +00:00
github-actions[bot]
80c1182773 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/9b19f5e77dd906cb52dade0b7bd280339d2a1f3d' (2024-01-13)
  → 'github:NixOS/nixpkgs/612f97239e2cc474c13c9dafa0df378058c5ad8d' (2024-01-21)
2024-01-22 12:33:40 +00:00
Archit Gupta
a6f3658ae9 Make mocked pkgs not depend on overlay prev stdenvs
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.
2024-01-21 22:22:31 -08:00
Archit Gupta
787ce03070 Support package functions without named args 2024-01-16 11:01:32 -08:00
Archit Gupta
a90223da37 Remove use of different pkgs for calculating name
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.
2024-01-16 10:55:57 -08:00
Archit Gupta
e143290511 Fix packages depending on pkg with same name
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.
2024-01-16 10:48:48 -08:00
Archit Gupta
26a8a4454a Fix readme shell example 2024-01-15 19:06:07 -08:00
github-actions[bot]
193b6a8840 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/46ae0210ce163b3cba6c7da08840c1d63de9c701' (2024-01-06)
  → 'github:NixOS/nixpkgs/9b19f5e77dd906cb52dade0b7bd280339d2a1f3d' (2024-01-13)
2024-01-15 12:32:35 +00:00
Archit Gupta
733cebf6b1 Add option type descriptions to docs 2024-01-15 02:55:01 -08:00
Archit Gupta
606ac6c1bb Allow templates to take moduleArgs 2024-01-15 02:53:17 -08:00
Archit Gupta
1fc128d2aa Add more stdenvs to mocked pkg set 2024-01-15 02:02:48 -08:00
Archit Gupta
a4440382bb Allow nixDir auto-loads to set a value to null
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.
2024-01-15 01:07:55 -08:00
Archit Gupta
3dd1d890a3 Update nixDir documentation 2024-01-15 00:28:48 -08:00
Archit Gupta
3b7188863d Deprecate autoImport lib function
As all options are now automatically used for nixDir, modules no longer
need to set up their own autoImports.
2024-01-15 00:26:05 -08:00
Archit Gupta
4e9f53ff4e Enable all options to be auto-loaded from nixDir
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.
2024-01-15 00:07:59 -08:00
Archit Gupta
11e65b623d Fix evaluation of packages.default not using mkDerivation
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.
2024-01-14 23:52:48 -08:00
Archit Gupta
589ee5ba7a Make direct and auto-loaded configuration consistent
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.
2024-01-14 19:35:54 -08:00
Archit Gupta
bb0080c21c Fix inconsistency when setting outputs.__functor
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.
2024-01-14 19:22:46 -08:00
Archit Gupta
f2c32f5a42 Add optCallWith type for optional calling
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.
2024-01-14 19:22:46 -08:00
Archit Gupta
1d92662d82 Allow devShell to be a package def or take args
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.
2024-01-14 19:22:46 -08:00
Archit Gupta
5215a657bf Apply misc code cleanup 2024-01-14 12:59:39 -08:00
Archit Gupta
cc2f42fbdf Enable simpler config of nixos/home configurations
Instead of having to call the configuration generation functions, the
params can just be set, and the functions will be called automatically
with additional useful settings automatically set.
2024-01-14 02:19:34 -08:00
Archit Gupta
ec343ae967 Extend autoloading to include importable directories
Now if a dir is treated as an attrset, subdirs with `default.nix` will
be loaded as attrs.
2024-01-14 01:24:52 -08:00
Archit Gupta
cf3a2e5496 Remove re-application check in propagationModule
Home-manager does not actually use it's pkgs argument for packages, so
the overlays will not be applied twice.
2024-01-14 00:34:35 -08:00
Archit Gupta
1b51df0be3 Add propogationModule feature
The `propagationModule` config option provides a module that can be used
to propagate flakelight configuration into other module systems such as
NixOS or home-manager.
2024-01-13 18:04:31 -08:00
Archit Gupta
333a383ff0 Simplify mock builders that get name from attrs 2024-01-12 01:52:55 -08:00
Archit Gupta
6263b349c3 Fix text wrapping for import in core.nix 2024-01-12 01:26:49 -08:00
Archit Gupta
817f6775b6 Fix option type for formatter
Since formatters are system dependent, the formatter option must be a
function.
2024-01-12 01:26:03 -08:00
Archit Gupta
9099db6c84 Avoid evaluating packages twice
Previously, the packages outputs would be evalutated using callPackage
on the package set, but the package set already contains the package. If
another package depends on it, the dependency would be the version from
the package set. By grabbing the packages from the package set, each
package only needs to be evaluated once.
2024-01-12 00:45:22 -08:00
Archit Gupta
99d8fc8a85 Use mocked builders to get default pkg name faster
Since evaluating pkgs is expensive, this speeds up evaluation of flakes
with `packages.default` by attempting to get the name using a pkgs set
containing only mocked builders that just return the name.
2024-01-12 00:36:36 -08:00
Archit Gupta
4b9d78f35f Speed up extracting default package pname
In order to speed up evalutation of flakes setting `packages.default`,
this trys to compute the pname in multiple ways, ordered by speed. The
pname can be set manually, which is fastest. To avoid computing a new
nixpkgs and flakelight overlays, the second option just uses callPackage
from stock nixpkgs. If that fails, the prior, most accurate, method is
used which creates a new nixpkgs with all the overlays available.
2024-01-11 17:35:01 -08:00
Archit Gupta
82f9fe67c3 Improve performance of per-system attributes
Using `perSystem` to implement per-system attributes ties all the
per-system attributes together; all the `perSystem` functions must run
to determine output attrs. By generating them separately, the generation
can be done lazily.
2024-01-11 17:35:01 -08:00
Archit Gupta
bcaa85757e Add pkgsFor module arg
This enables modules to access packages given some system, outside of
per-system attributes.
2024-01-11 17:35:01 -08:00
Archit Gupta
a7e2fe5468 Set default value for flakelight input 2024-01-11 17:35:01 -08:00
Archit Gupta
0760edb005 Refactor autoloadArgs to moduleArgs
The set of args passed to modules is useful for more than just
autoloading. This renames it appropriately and makes it available
through pkgs arguments as well.
2024-01-11 17:35:01 -08:00
github-actions[bot]
afe17be81a flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/cfc3698c31b1fb9cdcf10f36c9643460264d0ca8' (2023-12-27)
  → 'github:NixOS/nixpkgs/46ae0210ce163b3cba6c7da08840c1d63de9c701' (2024-01-06)
2024-01-08 12:32:25 +00:00
github-actions[bot]
221ee8fca1 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5f64a12a728902226210bf01d25ec6cbb9d9265b' (2023-12-24)
  → 'github:NixOS/nixpkgs/cfc3698c31b1fb9cdcf10f36c9643460264d0ca8' (2023-12-27)
2024-01-01 12:30:43 +00:00