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
77
flake.lock
generated
Normal file
77
flake.lock
generated
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-file": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1773554778,
|
||||||
|
"narHash": "sha256-keH0VNsci9e0Uwt3Msp/N+pltaP8Lb6lt09Q3WvDPw4=",
|
||||||
|
"owner": "vic",
|
||||||
|
"repo": "flake-file",
|
||||||
|
"rev": "f4780a86bd4c756475d839b286f8a40aabdbc802",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "vic",
|
||||||
|
"repo": "flake-file",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772408722,
|
||||||
|
"narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1773389992,
|
||||||
|
"narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c06b4ae3d6599a672a6210b7021d699c351eebda",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772328832,
|
||||||
|
"narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-file": "flake-file",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
14
flake.nix
14
flake.nix
|
|
@ -1,15 +1,13 @@
|
||||||
|
# DO-NOT-EDIT. This file was auto-generated using github:vic/flake-file.
|
||||||
|
# Use `nix run .#write-flake` to regenerate it.
|
||||||
{
|
{
|
||||||
description = "A very basic flake";
|
description = "A very basic flake";
|
||||||
|
|
||||||
|
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ./flake;
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
|
flake-file.url = "github:vic/flake-file";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: {
|
|
||||||
|
|
||||||
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
|
||||||
|
|
||||||
packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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