1
1
forked from extern/flakelight
Commit Graph

66 Commits

Author SHA1 Message Date
Archit Gupta
3a364f9cdd Remove checking of meta.platforms
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.
2024-03-24 14:23:41 -07:00
Archit Gupta
610cc3b0c4 Refactor checks to use types 2024-02-24 21:31:24 -08:00
Archit Gupta
e72626b0a9 Allow apps to be scripts
This enables setting the app to arbitrary bash scripts which will be
written to a store path and used for the app's program attr.
2024-02-24 21:31:24 -08:00
Archit Gupta
41ec64361f Allow using optFunctionTo on types with submodules 2024-02-24 21:31:24 -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
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
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
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
5215a657bf Apply misc code cleanup 2024-01-14 12:59:39 -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
a7e2fe5468 Set default value for flakelight input 2024-01-11 17:35:01 -08:00
Archit Gupta
88607687cf Add fileset option type 2023-12-06 22:46:56 -08:00
Archit Gupta
ff24d5d433 Allow bundlers to be functions that take pkgs
In addition to a regular bundler of the form `x: x`, this allows setting
bundler options to a function of the form `pkgs: x: x` which is passed
the package set for the system (for example: `{ hello, ... }: x: hello`
to always return hello). This allows, in particular, an autoloaded
bundler in its own file to access the package set.

This is non-trivial as we must tell `x: x` and `pkgs: x: x` apart.

Fortunately, given some derivation `drv`, `pkgs // drv` is a valid
derivation and a set with attr names matching pkgs. When applying this
to the function, if it returns a derivation, it was of the `x: x` form,
and if it returns a function, it was of the `pkgs: x: x` form.

In order to prevent IFD when evaluating the flake if the bundler is of
form `x: x` and uses IFD, we determine the form and apply pkgs when
applying the bundler instead of during flake evaluation. This is done by
wrapping the bundler.

Of note, we cannot rely on `builtins.functionArgs`, since
`pkgs: { hello, ... }: (x: hello) pkgs` is the same as the inner
function but with args hidden.
2023-11-06 23:13:47 -08:00
Archit Gupta
fad306c589 Fix merge function for custom option types
If merge is not set for an option type, it will use the default merge
function; this was not what was intended. Updated the merge values for
options that did not set one to mergeOneOption or mergeEqualOption.
2023-10-18 20:02:24 -07:00
Archit Gupta
53f35dc91c Make mkFlake extensible with additional modules
This is intended to allow flakes implementing a flakelight module to
export a mkFlake that automatically includes its module.
2023-09-13 22:39:20 -07:00
Archit Gupta
62083df539 Add functor option for flake's __functor attribute
This allows for conveniently making flakes callable.

Setting this is expected to be uncommon in general, but having the
option is useful as flakelight module flakes can use this to reduce the
boilerplate in using them.
2023-09-13 21:02:39 -07:00
Archit Gupta
838e383c50 Export autoImportArgs to modules 2023-08-27 00:01:48 -07:00
Archit Gupta
b8d9538c58 Rename project from flakelite to flakelight 2023-08-26 22:48:57 -07:00
Archit Gupta
f6c4424f6e Reimplement framework using the module system 2023-08-26 22:39:28 -07:00
Archit Gupta
50c4ad5cff Fix devShell attributes added at wrong level 2023-07-02 11:42:23 -07:00
Archit Gupta
412add2d01 Remove automatic use of ./. as nixDir
Using ./. as nixDir can cause confusion on repos with unrelated
directories that get picked up inadvertently.
2023-06-29 22:05:23 -07:00
Archit Gupta
af3e7f7a6f Add nixpkgsConfig to allow configuring nixpkgs 2023-05-13 20:05:21 -07:00
Archit Gupta
d871fd7cbf Use src as default nixDir if ./nix does not exist 2023-04-22 13:34:03 -07:00
Archit Gupta
f4f7a8cd37 Add aliases for autoloading root module attrs 2023-04-22 13:33:19 -07:00
Archit Gupta
f9967894bb Add support for home-manager outputs 2023-04-22 11:13:33 -07:00
Archit Gupta
7940d0c53f Add inputs and inputs' to top level of pkgs overlay 2023-04-22 10:13:01 -07:00
Archit Gupta
2c6954f018 Fix default nixDir path 2023-04-22 10:12:41 -07:00
Archit Gupta
bd68bc5c44 Make flakelite a functor as a shortcut for mkFlake 2023-04-20 19:29:56 -07:00
Archit Gupta
59ccd592a3 Allow outputs to be a functor
Previously, if outputs was a functor, it would mistakenly get called by
recUpdateSets.
2023-04-20 18:45:31 -07:00
Archit Gupta
76eb12e51b Allow root module to be a function 2023-04-20 18:26:39 -07:00
Archit Gupta
c9b8d986e1 Allow formatters to be functions 2023-04-16 18:37:32 -07:00
Archit Gupta
1c8ac213b0 Split up builtinModule into multiple modules 2023-04-16 16:31:17 -07:00
Archit Gupta
9c40724207 Have devShell install git pre-commit hook 2023-04-16 13:22:21 -07:00
Archit Gupta
07e68ac51b Allow check attributes to be functions that take pkgs 2023-04-16 11:33:19 -07:00
Archit Gupta
03cdbbabdf Add shellHook attr to configure default devShell 2023-04-16 11:20:28 -07:00
Archit Gupta
7509ce4110 Add comments 2023-04-16 00:55:45 -07:00
Archit Gupta
9e3bb803c6 Add default value for flakelite input 2023-04-15 20:11:34 -07:00
Archit Gupta
53843042f2 Apply some cleanup 2023-04-15 19:08:36 -07:00
Archit Gupta
b9ee864785 Add inputs module attribute for setting default inputs 2023-04-15 18:05:20 -07:00
Archit Gupta
76c6ec7938 Call per-system attributes with callFn 2023-04-15 16:59:02 -07:00
Archit Gupta
7149d4b655 Use callFn for modules and nonSysArgs 2023-04-15 16:33:46 -07:00
Archit Gupta
55493becb8 Refactoring and naming cleanup 2023-04-15 14:11:38 -07:00
Archit Gupta
bafb3c33ec Make raw root module available under root'.raw 2023-04-15 11:21:05 -07:00
Archit Gupta
aa0a3b3c2e Change file escape char to _ 2023-04-15 11:02:06 -07:00
Archit Gupta
3136d8e860 Add singular nixosModule and template 2023-04-15 06:36:46 -07:00
Archit Gupta
e33400c88c Improve app handling
Adds app attr for default app and allows apps to be functions like
packages and devShells.
2023-04-15 06:25:35 -07:00
Archit Gupta
28d5f5a5b4 Ensure normalized root has nixDir set 2023-04-15 05:10:53 -07:00
Archit Gupta
7d6c750790 Export more lib functions for use in modules 2023-04-15 05:00:19 -07:00
Archit Gupta
bbe8e3a442 Export autoloadAttr 2023-04-15 04:41:27 -07:00