mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
flake-modules-core -> flake-parts
This commit is contained in:
parent
98bc2676c4
commit
3beb704537
19 changed files with 52 additions and 52 deletions
16
README.md
16
README.md
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
# Flake Modules Core
|
# Flake Parts
|
||||||
|
|
||||||
_Core of a distributed framework for writing Nix Flakes._
|
_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?
|
# 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
|
It reduces the proliferation of custom Nix glue code, similar to what the
|
||||||
module system has done for NixOS configurations.
|
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
|
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
|
a single module that other repositories can build upon, while ensuring a
|
||||||
baseline level of compatibility: which core attribute make up a flake and
|
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:
|
If your project does not have a flake yet:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
nix flake init -t github:hercules-ci/flake-modules-core
|
nix flake init -t github:hercules-ci/flake-parts
|
||||||
```
|
```
|
||||||
|
|
||||||
Otherwise, add the input,
|
Otherwise, add the input,
|
||||||
|
|
||||||
```
|
```
|
||||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
```
|
```
|
||||||
|
|
||||||
then slide `mkFlake` between your outputs function head and body,
|
then slide `mkFlake` between your outputs function head and body,
|
||||||
|
|
||||||
```
|
```
|
||||||
outputs = { self, flake-modules-core, ... }:
|
outputs = { self, flake-parts, ... }:
|
||||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
flake-parts.lib.mkFlake { inherit self; } {
|
||||||
flake = {
|
flake = {
|
||||||
# Put your original flake attributes here.
|
# Put your original flake attributes here.
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
# Separate `tools` flake
|
# Separate `tools` flake
|
||||||
|
|
||||||
Wouldn't recommend this pattern normally, but I'm trying to keep
|
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.
|
that don't carry over to dependent lock files.
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
default = {
|
default = {
|
||||||
path = ./template/default;
|
path = ./template/default;
|
||||||
description = ''
|
description = ''
|
||||||
A minimal flake using flake-modules-core.
|
A minimal flake using flake-parts.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
multi-module = {
|
multi-module = {
|
||||||
path = ./template/multi-module;
|
path = ./template/multi-module;
|
||||||
description = ''
|
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;
|
nestedTypes.elemType = elemType;
|
||||||
};
|
};
|
||||||
|
|
||||||
flake-modules-core-lib = {
|
flake-parts-lib = {
|
||||||
evalFlakeModule =
|
evalFlakeModule =
|
||||||
{ self
|
{ self
|
||||||
, specialArgs ? { }
|
, specialArgs ? { }
|
||||||
|
@ -34,12 +34,12 @@ let
|
||||||
module:
|
module:
|
||||||
|
|
||||||
lib.evalModules {
|
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 ];
|
modules = [ ./all-modules.nix module ];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkFlake = args: 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.
|
# For extending options in an already declared submodule.
|
||||||
# Workaround for https://github.com/NixOS/nixpkgs/issues/146882
|
# Workaround for https://github.com/NixOS/nixpkgs/issues/146882
|
||||||
|
@ -61,10 +61,10 @@ let
|
||||||
mkPerSystemOption =
|
mkPerSystemOption =
|
||||||
module:
|
module:
|
||||||
mkOption {
|
mkOption {
|
||||||
type = flake-modules-core-lib.mkPerSystemType module;
|
type = flake-parts-lib.mkPerSystemType module;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
flake-modules-core-lib
|
flake-parts-lib
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, self, lib, flake-modules-core-lib, ... }:
|
{ config, self, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
literalExpression
|
literalExpression
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, self, lib, flake-modules-core-lib, ... }:
|
{ config, self, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
#
|
#
|
||||||
# Provides a `pkgs` argument in `perSystem`.
|
# 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
|
# Nixpkgs could define its own module that does this, which would be
|
||||||
# a more consistent UX, but for now this will do.
|
# a more consistent UX, but for now this will do.
|
||||||
#
|
#
|
||||||
# The existence of this module does not mean that other flakes' logic
|
# 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.
|
# spirit of Flakes.
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
config = {
|
config = {
|
||||||
_module.args.pkgs = lib.mkOptionDefault (
|
_module.args.pkgs = lib.mkOptionDefault (
|
||||||
builtins.seq
|
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
|
inputs'.nixpkgs.legacyPackages
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, ... }:
|
{ config, lib, flake-parts-lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
|
@ -7,7 +7,7 @@ let
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, flake-modules-core-lib, self, ... }:
|
{ config, lib, flake-parts-lib, self, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
genAttrs
|
genAttrs
|
||||||
|
@ -6,7 +6,7 @@ let
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (flake-modules-core-lib)
|
inherit (flake-parts-lib)
|
||||||
mkPerSystemType
|
mkPerSystemType
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@
|
||||||
};
|
};
|
||||||
coreOptions = optionsDoc {
|
coreOptions = optionsDoc {
|
||||||
title = "Core Options";
|
title = "Core Options";
|
||||||
sourceName = "flake-modules-core";
|
sourceName = "flake-parts";
|
||||||
baseUrl = "https://github.com/hercules-ci/flake-modules-core/blob/main";
|
baseUrl = "https://github.com/hercules-ci/flake-parts/blob/main";
|
||||||
sourcePath = ../.;
|
sourcePath = ../.;
|
||||||
};
|
};
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>flake-modules-core</title>
|
<title>flake-parts</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1><code>flake-modules-core</code></h1>
|
<h1><code>flake-parts</code></h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Compose flakes with the (NixOS) module system.
|
Compose flakes with the (NixOS) module system.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
description = "Description for the project";
|
description = "Description for the project";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, flake-modules-core, ... }:
|
outputs = { self, flake-parts, ... }:
|
||||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
flake-parts.lib.mkFlake { inherit self; } {
|
||||||
imports = [
|
imports = [
|
||||||
# To import a flake module
|
# To import a flake module
|
||||||
# 1. Add foo to inputs
|
# 1. Add foo to inputs
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
description = "Description for the project";
|
description = "Description for the project";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
|
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, flake-modules-core, ... }:
|
outputs = { self, flake-parts, ... }:
|
||||||
flake-modules-core.lib.mkFlake { inherit self; } {
|
flake-parts.lib.mkFlake { inherit self; } {
|
||||||
imports = [
|
imports = [
|
||||||
./hello/flake-module.nix
|
./hello/flake-module.nix
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue