1
1
forked from extern/flakelight

Fix documentation issues

This commit is contained in:
Archit Gupta 2023-12-04 23:44:54 -08:00
parent cca0b23070
commit df7e569958

View File

@ -179,7 +179,7 @@ To add a `example.test` output to your flake you could do the following:
} }
``` ```
With the above, `nix eval .#example.test` will ouput "hello". With the above, `nix eval .#example.test` will output "hello".
This can be used to configure any output, for example directly setting an This can be used to configure any output, for example directly setting an
overlay (though this can be configured with the `overlays` option): overlay (though this can be configured with the `overlays` option):
@ -215,7 +215,7 @@ following:
} }
``` ```
The above, with default systems, will generate `example.x86-64_linux.test` and The above, with default systems, will generate `example.x86_64-linux.test` and
`example.aarch64-linux.test` attributes. `example.aarch64-linux.test` attributes.
### nixpkgs.config ### nixpkgs.config
@ -308,6 +308,8 @@ To set the default package, you can set the options as follows:
The above will export `packages.${system}.default` attributes, add `pkg1` to The above will export `packages.${system}.default` attributes, add `pkg1` to
`overlays.default`, and export `checks.${system}.packages-default`. `overlays.default`, and export `checks.${system}.packages-default`.
You can also instead just directly set `packages.default`.
To set multiple packages, you can set the options as follows: To set multiple packages, you can set the options as follows:
```nix ```nix
@ -322,27 +324,24 @@ To set multiple packages, you can set the options as follows:
src = ./.; src = ./.;
installPhase = "make DESTDIR=$out install"; installPhase = "make DESTDIR=$out install";
}; };
pkg2 = { stdenv, pkg1, pkg3 }: { pkg2 = { stdenv, pkg1, pkg3 }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "hello-world"; name = "hello-world";
src = ./pkg2; src = ./pkg2;
nativeBuildInputs = [ pkg1 pkg3 ]; nativeBuildInputs = [ pkg1 pkg3 ];
installPhase = "make DESTDIR=$out install"; installPhase = "make DESTDIR=$out install";
}; };
pkg3 = { stdenv }: { pkg3 = { stdenv }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "hello-world"; name = "hello-world";
src = ./pkg3; src = ./pkg3;
installPhase = "make DESTDIR=$out install"; installPhase = "make DESTDIR=$out install";
}; };
};
}; };
}; };
} }
``` ```
You can also instead just directly set `packages.default`
The above will export `packages.${system}.default`, `packages.${system}.pkg2`, The above will export `packages.${system}.default`, `packages.${system}.pkg2`,
`packages.${system}.pkg3` attributes, add `pkg1`, `pkg2`, and `pkg3` to `packages.${system}.pkg3` attributes, add `pkg1`, `pkg2`, and `pkg3` to
`overlays.default`, and export corresponding build checks. `overlays.default`, and export corresponding build checks.
@ -553,7 +552,7 @@ Alternatively, the above can be written as:
### templates ### templates
The `template` and `templates` options allow you to set `templates.${system}` The `template` and `templates` options allow you to set `templates`
outputs. outputs.
`templates` is an attribute set to template values. `templates` is an attribute set to template values.
@ -575,12 +574,29 @@ For example:
} }
``` ```
### formatters ### formatter
The `formatter` option allows you to set `formatter.${system}` outputs. It can The `formatter` option allows you to set `formatter.${system}` outputs. It can
be set to a function that takes packages and returns the package to use. This be set to a function that takes packages and returns the package to use. This
overrides the `formatters` functionality described below though, so for overrides the `formatters` functionality described below though, so for
configuring formatters for a file type, you likely want to use `formatters`. configuring formatters for a file type, you likely want to use `formatters`
instead.
For example, to use a custom formatting command:
```nix
{
inputs.flakelight.url = "github:accelbread/flakelight";
outputs = { flakelight, ... }:
flakelight ./. {
formatter = pkgs: pkgs.writeShellScriptBin "format-script" ''
# Perform formatting (`nix fmt` calls the script with `.` as arg)
'';
};
}
```
### formatters
The `formatters` option allows you to configure formatting tools that will be The `formatters` option allows you to configure formatting tools that will be
used by `nix fmt`. If formatters are set, Flakelight will export used by `nix fmt`. If formatters are set, Flakelight will export
@ -620,8 +636,11 @@ For example, to set Rust and Zig formatters:
The `bundler` and `bundlers` options allow you to set `bundlers.${system}` The `bundler` and `bundlers` options allow you to set `bundlers.${system}`
outputs. outputs.
`bundlers` is an attribute set of bundler functions or a function that takes Each bundler value can be either a bundler function or a function that takes the
packages and returns an attribute set of bundler functions. package set and returns a bundler function.
`bundlers` is an attribute set of bundler values or a function that takes
packages and returns an attribute set of bundler values.
`bundler` sets `bundlers.default`. `bundler` sets `bundlers.default`.
@ -645,12 +664,19 @@ As another example, a bundler that always returns `hello`:
outputs = { flakelight, ... }: outputs = { flakelight, ... }:
flakelight ./. { flakelight ./. {
bundlers = { hello, ... }: { bundlers = { hello, ... }: {
default = x: hello; hello = x: hello;
}; };
}; };
} }
``` ```
To write the above using autoloads, can use the following:
```nix
# nix/bundlers/hello.nix
{ hello, ... }: x: hello;
```
### nixosConfigurations and homeConfigurations ### nixosConfigurations and homeConfigurations
The `nixosConfigurations` and `homeConfigurations` attributes let you set The `nixosConfigurations` and `homeConfigurations` attributes let you set