feat(flake): modular structure with flake-file and flake-parts
This commit is contained in:
parent
4a576b32ff
commit
366e75c9d1
5 changed files with 149 additions and 8 deletions
19
flake/default.nix
Normal file
19
flake/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Flake
|
||||
|
||||
/**
|
||||
Entry point of NixOS configuration
|
||||
|
||||
- Defines external sources and locking their commit, which gives up __purity__.
|
||||
- Declares ready-to-use configurations (e.g. development shells, packages, etc.)
|
||||
|
||||
Essentially, `flake.nix` is like `Cargo.toml` in Rust or `package.json` in Node.js, but for an entire operating system.
|
||||
*/
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [ inputs.flake-file.flakeModules.default ];
|
||||
|
||||
systems = inputs.nixpkgs.lib.systems.flakeExposed;
|
||||
|
||||
flake-file.inputs = import ./inputs;
|
||||
flake-file.outputs = "inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ./flake";
|
||||
flake-file.description = "A very basic flake";
|
||||
30
flake/inputs/core.nix
Normal file
30
flake/inputs/core.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Core Inputs
|
||||
|
||||
/**
|
||||
Essential inputs that form
|
||||
the foundation of the NixOS configuration
|
||||
*/
|
||||
{
|
||||
/**
|
||||
The Core of NixOS, providing packages and modules.
|
||||
Points to `nixos-unstable` branch for latest features an updates
|
||||
*/
|
||||
nixpkgs = {
|
||||
url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
/**
|
||||
A modular flake framework that simplifies flake organizing
|
||||
and reduces boilerplate code.
|
||||
*/
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
|
||||
/**
|
||||
Like flake-parts, but for flake inputs
|
||||
*/
|
||||
flake-file = {
|
||||
url = "github:vic/flake-file";
|
||||
};
|
||||
}
|
||||
17
flake/inputs/default.nix
Normal file
17
flake/inputs/default.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Flake inputs
|
||||
|
||||
/**
|
||||
Declares configuration’s dependencies. Inputs
|
||||
are sorted by their purpose and functionality.
|
||||
See sub chapters to learn which inputs are intended for.
|
||||
|
||||
> [!WARNING]
|
||||
> Because nix doesn’t support splitting flake inputs into several files,
|
||||
> `flake.nix` is generated via [flake-file](https://github.com/vic/flake-file). Then adding new input,
|
||||
> remember running `nix run .#write-flake` to apply changes!
|
||||
>
|
||||
> In next chapters, you'll see attributes of type `flake.inputs.<class>.<input>`.
|
||||
> Then accessing inputs in repl, remove <class>, so instead of calling e.g. `flake.inputs.core.nixpkgs`,
|
||||
> you call `flake.inputs.nixpkgs`.
|
||||
*/
|
||||
import ./core.nix
|
||||
Loading…
Add table
Add a link
Reference in a new issue