Types and flakes
This commit is contained in:
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
- [Installation](./installation/index.md)
|
- [Installation](./installation/index.md)
|
||||||
- [Nix basics](./nixbasics/index.md)
|
- [Nix basics](./nixbasics/index.md)
|
||||||
- [Types](./nixbasics/types.md)
|
|
||||||
- [Functions](./nixbasics/functions.md)
|
|
||||||
- [Flakes](./nixbasics/flakes.md)
|
- [Flakes](./nixbasics/flakes.md)
|
||||||
|
- [Types](./nixbasics/types.md)
|
||||||
- [Configuration](./configuration/index.md)
|
- [Configuration](./configuration/index.md)
|
||||||
- [Drivers](./configuration/drivers.md)
|
- [Drivers](./configuration/drivers.md)
|
||||||
- [GUI](./configuration/GUI.md)
|
- [GUI](./configuration/GUI.md)
|
||||||
|
@ -125,5 +125,5 @@ After fixing a good setup, please setup a remote for git, so that you are able t
|
|||||||
|
|
||||||
# Further reading
|
# Further reading
|
||||||
With this you have an installed system, with a user, but not much more.
|
With this you have an installed system, with a user, but not much more.
|
||||||
How to configure the system, to add users, software, drivers and such, will be covered in [Configuration](../configuration/index.md).
|
How to configure the system, software, drivers and such, will be covered in [Configuration](../configuration/index.md).
|
||||||
But, you might need to understand some aspects of the nix language in order to fully understand how to do configuration, so that will be covered in [Nix basics](../nixbasics/index.md).
|
But, you might need to understand some aspects of the nix language, and how the rebuilding with flakes works, in order to fully understand how to do configuration, so that will be covered in [Nix basics](../nixbasics/index.md).
|
||||||
|
@ -11,3 +11,24 @@ nix.settings.experimental-features = "nix-command flakes";
|
|||||||
```
|
```
|
||||||
|
|
||||||
This enables `nix-command` and `flakes`, where nix-command is needed for flakes.
|
This enables `nix-command` and `flakes`, where nix-command is needed for flakes.
|
||||||
|
|
||||||
|
## Systems
|
||||||
|
Flakes also handles systems a bit a bit different.
|
||||||
|
Below is the auto generated flake file for a system.
|
||||||
|
When running `nixos-rebuild switch --flake .#nixos -L`, the `nixos` parts comes from this file.
|
||||||
|
If `nixosConfiguration.nixostwo` existed, then you could run that instead to build that system.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
outputs = inputs@{ self, nixpkgs, ... }: {
|
||||||
|
# NOTE: 'nixos' is the default hostname
|
||||||
|
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
|
||||||
|
inherit pkgs;
|
||||||
|
modules = [ ./configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# Functions
|
|
@ -1 +1,4 @@
|
|||||||
# Nix basics
|
# Nix basics
|
||||||
|
|
||||||
|
The basics of Nix will be covered here.
|
||||||
|
Flakes are covered in [Flakes](./flakes.md), and the types are covered in [Types](./types.md)
|
||||||
|
@ -13,8 +13,6 @@ There are several types that can be used withing Nix, most of them are as one wo
|
|||||||
- Function
|
- Function
|
||||||
- External
|
- External
|
||||||
|
|
||||||
Functions will be covered in [Functions](./functions.md).
|
|
||||||
|
|
||||||
## Attribute set
|
## Attribute set
|
||||||
|
|
||||||
One of the core
|
One of the core
|
||||||
@ -82,5 +80,23 @@ They are written with spaces as separators, as can be seen in:
|
|||||||
foo = [ 123 "abc" { bar = false; } ];
|
foo = [ 123 "abc" { bar = false; } ];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
Functions in nix only take one argument, however, they can be a set.
|
||||||
|
What they return however, can be a function themselves, so that is how one says there are multiple arguments.
|
||||||
|
You are also able to clump a set into one argument, while still expanding parts of it, while hiding the rest with `...`.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
f = x: !x; # negate x
|
||||||
|
g = x: y: x + y # add x and y
|
||||||
|
h = { x, y}: x + y # add x and y from a set
|
||||||
|
i = w@{ x, y, ...}: x + y + w.z # add x, y and z from the same set
|
||||||
|
j = { x, y, ...}@w: x + y + w.z # add x, y and z from the same set
|
||||||
|
```
|
||||||
|
|
||||||
|
You are also able to set default values to arguments, if they weren't supplied.
|
||||||
|
```nix
|
||||||
|
foo = {a, b ? 23}: a + b # add a and b, where b is 23 by default
|
||||||
|
```
|
||||||
|
|
||||||
[^global]: [Nix Reference Manual: Path](https://nix.dev/manual/nix/2.26/language/syntax#path-literal)
|
[^global]: [Nix Reference Manual: Path](https://nix.dev/manual/nix/2.26/language/syntax#path-literal)
|
||||||
[^strict?]: [Nix Reference Manual: List](https://nix.dev/manual/nix/2.26/language/syntax#list-literal)
|
[^strict?]: [Nix Reference Manual: List](https://nix.dev/manual/nix/2.26/language/syntax#list-literal)
|
||||||
|
Reference in New Issue
Block a user