diff --git a/README.md b/README.md index e390ea24..b2dcc1e8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,12 @@ _Core of a distributed framework for writing Nix Flakes._ -`flake-parts` provides the options that represent standard flake attributes and establishes a way of working with `system`. Opinionated features are provided by an ecosystem of modules that you can import. +`flake-parts` provides the options that represent standard flake attributes +and establishes a way of working with `system`. +Opinionated features are provided by an ecosystem of modules that you can import. + +`flake-parts` _itself_ has the goal to be a minimal mirror of the Nix flake schema. +Used by itself, it is very lightweight. # Why Modules? @@ -16,8 +21,20 @@ module system has done for NixOS configurations. Unlike NixOS, but following Flakes' spirit, `flake-parts` is not a monorepo with the implied goal of absorbing all of open source, but rather a single module that other repositories can build upon, while ensuring a -baseline level of compatibility: which core attribute make up a flake and -how these are represented as module options. +baseline level of compatibility: the core attributes that constitute a flake. + +# Features + + - Split your `flake.nix` into focused units, each in their own file. + + - Take care of [system](./system.md). + + - Allow users of your library flake to easily integrate your generated flake outputs + into their flake. + + - Reuse project logic written by others + + # Getting Started diff --git a/dev/flake-module.nix b/dev/flake-module.nix index a621da92..95fdb639 100644 --- a/dev/flake-module.nix +++ b/dev/flake-module.nix @@ -16,6 +16,7 @@ pkgs.hci pkgs.netlify-cli pkgs.pandoc + pkgs.mdbook ]; shellHook = '' ${config.pre-commit.installationScript} diff --git a/dev/flake.lock b/dev/flake.lock index 60bc8b02..edcf2df9 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -69,6 +69,21 @@ "type": "github" } }, + "haskell-flake": { + "locked": { + "lastModified": 1668167720, + "narHash": "sha256-5wDTR6xt9BB3BjgKR+YOjOkZgMyDXKaX79g42sStzDU=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "4fc511d93a55fedf815c1647ad146c26d7a2054e", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, "hercules-ci-agent": { "inputs": { "flake-parts": "flake-parts_2", @@ -244,6 +259,7 @@ }, "root": { "inputs": { + "haskell-flake": "haskell-flake", "hercules-ci-effects": "hercules-ci-effects", "nixpkgs": "nixpkgs_3", "pre-commit-hooks-nix": "pre-commit-hooks-nix_2" diff --git a/dev/flake.nix b/dev/flake.nix index 3344f423..05c29906 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -12,6 +12,8 @@ pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs"; hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects"; + + haskell-flake.url = "github:srid/haskell-flake"; }; outputs = { self, ... }: diff --git a/site/.gitignore b/site/.gitignore new file mode 100644 index 00000000..7585238e --- /dev/null +++ b/site/.gitignore @@ -0,0 +1 @@ +book diff --git a/site/book.toml b/site/book.toml new file mode 100644 index 00000000..fbede22f --- /dev/null +++ b/site/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Robert Hensing", "Various module authors"] +language = "en" +multilingual = false +src = "src" +title = "flake-parts" diff --git a/site/flake-module.nix b/site/flake-module.nix index 617ccd89..6e99b562 100644 --- a/site/flake-module.nix +++ b/site/flake-module.nix @@ -8,6 +8,7 @@ imports = [ inputs.pre-commit-hooks-nix.flakeModule inputs.hercules-ci-effects.flakeModule + inputs.haskell-flake.flakeModule ]; }; opts = eval.options; @@ -31,9 +32,9 @@ then opt // { visible = false; } else opt // { inherit declarations; }; - optionsDoc = { sourceName, baseUrl, sourcePath, title }: pkgs.runCommand "${sourceName}-doc" + optionsDoc = { sourceName, baseUrl, sourcePath, title }: pkgs.runCommand "option-doc-${sourceName}" { - nativeBuildInputs = [ pkgs.libxslt.bin ]; + nativeBuildInputs = [ pkgs.libxslt.bin pkgs.pandoc ]; inputDoc = (pkgs.nixosOptionsDoc { options = opts; documentType = "none"; @@ -46,75 +47,84 @@ inherit title; } '' xsltproc --stringparam title "$title" \ - -o $out ${./options.xsl} \ + -o options.db.xml ${./options.xsl} \ "$inputDoc" + mkdir $out + pandoc --verbose --from docbook --to html options.db.xml >$out/options.md; ''; + + repos = { + flake-parts = { + title = "Core Options"; + sourceName = "flake-parts"; + baseUrl = "https://github.com/hercules-ci/flake-parts/blob/main"; + sourcePath = ../.; + }; + pre-commit-hooks-nix = { + title = "pre-commit-hooks.nix"; + sourceName = "pre-commit-hooks.nix"; + baseUrl = "https://github.com/hercules-ci/pre-commit-hooks.nix/blob/flakeModule"; + sourcePath = inputs.pre-commit-hooks-nix; + }; + hercules-ci-effects = { + title = "hercules-ci-effects"; + sourceName = "hercules-ci-effects"; + baseUrl = "https://github.com/hercules-ci/hercules-ci-effects/blob/master"; + sourcePath = inputs.hercules-ci-effects; + }; + haskell-flake = { + title = "haskell-flake"; + sourceName = "haskell-flake"; + baseUrl = "https://github.com/srid/haskell-flake/blob/master"; + sourcePath = inputs.haskell-flake; + }; + }; + + generatedDocs = lib.mapAttrs (k: optionsDoc) repos; + generatedDocs' = lib.mapAttrs' (name: value: { name = "generated-docs-${name}"; inherit value; }) generatedDocs; + in { - packages = { - siteContent = pkgs.stdenvNoCC.mkDerivation { name = "site"; - nativeBuildInputs = [ pkgs.pandoc pkgs.libxslt.bin ]; - src = lib.cleanSourceWith { - filter = path: type: - path == ./. - || baseNameOf path == "index.html"; - src = ./.; - }; - coreOptions = optionsDoc { - title = "Core Options"; - sourceName = "flake-parts"; - baseUrl = "https://github.com/hercules-ci/flake-parts/blob/main"; - sourcePath = ../.; - }; - # TODO make this a dynamic input - pre_commit_hooks_nixOptions = optionsDoc { - title = "pre-commit-hooks.nix"; - sourceName = "pre-commit-hooks.nix"; - baseUrl = "https://github.com/hercules-ci/pre-commit-hooks.nix/blob/flakeModule"; - sourcePath = inputs.pre-commit-hooks-nix; - }; - # TODO make this a dynamic input - hercules_ci_effectsOptions = optionsDoc { - title = "hercules-ci-effects"; - sourceName = "hercules-ci-effects"; - baseUrl = "https://github.com/hercules-ci/hercules-ci-effects/blob/master"; - sourcePath = inputs.hercules-ci-effects; - }; - # pandoc - htmlBefore = '' - -
-flake-parts
- Compose flakes with the (NixOS) module system. -
- -- Testimonials: -
- -- yeah.. powerful stuff -- -
- I cannot tell you how freeing the flake-modules concept is- -
- fucking hell
- I feel like a hipster using it too -
- Learn more: -
- -- GitHub -
- - - -- ChangeLog -
- -- Integrations: -
-github:hercules-ci/hercules-ci-effects
github:hercules-ci/pre-commit-hooks.nix/flakeModule
- For a general introduction to modules, you can read Writing Modules in the NixOS manual, though it goes into NixOS specifics quite quickly. Instead of services.<name>.*
, etc, we have our own options.
-
- Writing modules in a distributed ecosystem can be a bit different. If you're inclined to write to some other module's options, consider whether those will be loaded and whether your integration idea is always desirable. If it's not always desirable, consider splitting it off into an extra module, e.g. flakeModules.someOther
. Otherwise check if it's loaded: lib.optionalAttrs (options?some.other.option)
. You can ask @roberth
on GitHub.
-