diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..75451b8 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix index 2508a54..5105c3f 100644 --- a/flake.nix +++ b/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"; + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ./flake; + inputs = { + flake-file.url = "github:vic/flake-file"; + flake-parts.url = "github:hercules-ci/flake-parts"; 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; - - }; } diff --git a/flake/default.nix b/flake/default.nix new file mode 100644 index 0000000..36cf8ef --- /dev/null +++ b/flake/default.nix @@ -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"; diff --git a/flake/inputs/core.nix b/flake/inputs/core.nix new file mode 100644 index 0000000..dc36458 --- /dev/null +++ b/flake/inputs/core.nix @@ -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"; + }; +} diff --git a/flake/inputs/default.nix b/flake/inputs/default.nix new file mode 100644 index 0000000..e0d09f9 --- /dev/null +++ b/flake/inputs/default.nix @@ -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..`. + > Then accessing inputs in repl, remove , so instead of calling e.g. `flake.inputs.core.nixpkgs`, + > you call `flake.inputs.nixpkgs`. +*/ +import ./core.nix