mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
Merge pull request #19 from hercules-ci/flake-parts
Flake modules core -> Flake parts
This commit is contained in:
commit
d5370c0774
20 changed files with 65 additions and 52 deletions
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# nix
|
||||
result
|
||||
result-*
|
||||
|
||||
# pre-commit-hooks.nix
|
||||
.pre-commit-config.yaml
|
||||
|
||||
# dev/README.md
|
||||
flake.lock
|
20
README.md
20
README.md
|
@ -1,9 +1,9 @@
|
|||
|
||||
# Flake Modules Core
|
||||
# Flake Parts
|
||||
|
||||
_Core of a distributed framework for writing Nix Flakes._
|
||||
|
||||
`flake-modules-core` 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.
|
||||
|
||||
# Why Modules?
|
||||
|
||||
|
@ -13,7 +13,7 @@ into modules that can be shared.
|
|||
It reduces the proliferation of custom Nix glue code, similar to what the
|
||||
module system has done for NixOS configurations.
|
||||
|
||||
Unlike NixOS, but following Flakes' spirit, `flake-modules-core` is not a
|
||||
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
|
||||
|
@ -24,21 +24,21 @@ how these are represented as module options.
|
|||
If your project does not have a flake yet:
|
||||
|
||||
```console
|
||||
nix flake init -t github:hercules-ci/flake-modules-core
|
||||
nix flake init -t github:hercules-ci/flake-parts
|
||||
```
|
||||
|
||||
Otherwise, add the input,
|
||||
|
||||
```
|
||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||
```
|
||||
|
||||
then slide `mkFlake` between your outputs function head and body,
|
||||
|
||||
```
|
||||
outputs = { self, flake-modules-core, ... }:
|
||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
||||
outputs = { self, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit self; } {
|
||||
flake = {
|
||||
# Put your original flake attributes here.
|
||||
}
|
||||
|
@ -50,3 +50,7 @@ Now you can add the remaining module attributes like in the [the template](./tem
|
|||
# Example
|
||||
|
||||
See [the template](./template/default/flake.nix).
|
||||
|
||||
# Options Reference
|
||||
|
||||
See [flake.parts](https://flake.parts/options.html)
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
# Separate `tools` flake
|
||||
|
||||
Wouldn't recommend this pattern normally, but I'm trying to keep
|
||||
deps low for `flake-modules-core` until we have split dev inputs
|
||||
deps low for `flake-parts` until we have split dev inputs
|
||||
that don't carry over to dependent lock files.
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
default = {
|
||||
path = ./template/default;
|
||||
description = ''
|
||||
A minimal flake using flake-modules-core.
|
||||
A minimal flake using flake-parts.
|
||||
'';
|
||||
};
|
||||
multi-module = {
|
||||
path = ./template/multi-module;
|
||||
description = ''
|
||||
A minimal flake using flake-modules-core.
|
||||
A minimal flake using flake-parts.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
10
lib.nix
10
lib.nix
|
@ -26,7 +26,7 @@ let
|
|||
nestedTypes.elemType = elemType;
|
||||
};
|
||||
|
||||
flake-modules-core-lib = {
|
||||
flake-parts-lib = {
|
||||
evalFlakeModule =
|
||||
{ self
|
||||
, specialArgs ? { }
|
||||
|
@ -34,12 +34,12 @@ let
|
|||
module:
|
||||
|
||||
lib.evalModules {
|
||||
specialArgs = { inherit self flake-modules-core-lib; inherit (self) inputs; } // specialArgs;
|
||||
specialArgs = { inherit self flake-parts-lib; inherit (self) inputs; } // specialArgs;
|
||||
modules = [ ./all-modules.nix module ];
|
||||
};
|
||||
|
||||
mkFlake = args: module:
|
||||
(flake-modules-core-lib.evalFlakeModule args module).config.flake;
|
||||
(flake-parts-lib.evalFlakeModule args module).config.flake;
|
||||
|
||||
# For extending options in an already declared submodule.
|
||||
# Workaround for https://github.com/NixOS/nixpkgs/issues/146882
|
||||
|
@ -61,10 +61,10 @@ let
|
|||
mkPerSystemOption =
|
||||
module:
|
||||
mkOption {
|
||||
type = flake-modules-core-lib.mkPerSystemType module;
|
||||
type = flake-parts-lib.mkPerSystemType module;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
in
|
||||
flake-modules-core-lib
|
||||
flake-parts-lib
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, self, lib, flake-modules-core-lib, ... }:
|
||||
{ config, self, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
;
|
||||
in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
literalExpression
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
;
|
||||
in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, self, lib, flake-modules-core-lib, ... }:
|
||||
{ config, self, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
;
|
||||
in
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
#
|
||||
# Provides a `pkgs` argument in `perSystem`.
|
||||
#
|
||||
# Arguably, this shouldn't be in flake-modules-core, but in nixpkgs.
|
||||
# Arguably, this shouldn't be in flake-parts, but in nixpkgs.
|
||||
# Nixpkgs could define its own module that does this, which would be
|
||||
# a more consistent UX, but for now this will do.
|
||||
#
|
||||
# The existence of this module does not mean that other flakes' logic
|
||||
# will be accepted into flake-modules-core, because it's against the
|
||||
# will be accepted into flake-parts, because it's against the
|
||||
# spirit of Flakes.
|
||||
#
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
|||
config = {
|
||||
_module.args.pkgs = lib.mkOptionDefault (
|
||||
builtins.seq
|
||||
(inputs'.nixpkgs or (throw "flake-modules-core: The flake does not have a `nixpkgs` input. Please add it, or set `perSystem._module.args.pkgs` yourself."))
|
||||
(inputs'.nixpkgs or (throw "flake-parts: The flake does not have a `nixpkgs` input. Please add it, or set `perSystem._module.args.pkgs` yourself."))
|
||||
inputs'.nixpkgs.legacyPackages
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
;
|
||||
in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, ... }:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
|
@ -7,7 +7,7 @@ let
|
|||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-modules-core-lib, self, ... }:
|
||||
{ config, lib, flake-parts-lib, self, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
genAttrs
|
||||
|
@ -6,7 +6,7 @@ let
|
|||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-modules-core-lib)
|
||||
inherit (flake-parts-lib)
|
||||
mkPerSystemType
|
||||
;
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
};
|
||||
coreOptions = optionsDoc {
|
||||
title = "Core Options";
|
||||
sourceName = "flake-modules-core";
|
||||
baseUrl = "https://github.com/hercules-ci/flake-modules-core/blob/main";
|
||||
sourceName = "flake-parts";
|
||||
baseUrl = "https://github.com/hercules-ci/flake-parts/blob/main";
|
||||
sourcePath = ../.;
|
||||
};
|
||||
buildPhase = ''
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>flake-modules-core</title>
|
||||
<title>flake-parts</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><code>flake-modules-core</code></h1>
|
||||
<h1><code>flake-parts</code></h1>
|
||||
|
||||
<p>
|
||||
Compose flakes with the (NixOS) module system.
|
||||
|
@ -30,7 +30,7 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/hercules-ci/flake-modules-core">GitHub</a>
|
||||
<a href="https://github.com/hercules-ci/flake-parts">GitHub</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
description = "Description for the project";
|
||||
|
||||
inputs = {
|
||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, flake-modules-core, ... }:
|
||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
||||
outputs = { self, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit self; } {
|
||||
imports = [
|
||||
# To import a flake module
|
||||
# 1. Add foo to inputs
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
description = "Description for the project";
|
||||
|
||||
inputs = {
|
||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, flake-modules-core, ... }:
|
||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
||||
outputs = { self, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit self; } {
|
||||
imports = [
|
||||
./hello/flake-module.nix
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue