1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Merge pull request #4 from hercules-ci/more-attrs

Add darwinModules, nixosModules, overlay
This commit is contained in:
Robert Hensing 2021-11-23 12:51:38 +01:00 committed by GitHub
commit 0d9aec2b72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 0 deletions

View file

@ -2,9 +2,12 @@
{
imports = [
./modules/checks.nix
./modules/darwinModules.nix
./modules/devShell.nix
./modules/flake.nix
./modules/legacyPackages.nix
./modules/nixosModules.nix
./modules/overlay.nix
./modules/packages.nix
./modules/perSystem.nix
];

27
modules/darwinModules.nix Normal file
View file

@ -0,0 +1,27 @@
{ config, self, lib, flake-modules-core-lib, ... }:
let
inherit (lib)
filterAttrs
mapAttrs
mkOption
optionalAttrs
types
;
inherit (flake-modules-core-lib)
mkSubmoduleOptions
;
in
{
options = {
flake = mkSubmoduleOptions {
darwinModules = mkOption {
type = types.lazyAttrsOf types.unspecified;
default = { };
apply = mapAttrs (k: v: { _file = "${toString self.outPath}/flake.nix#darwinModules.${k}"; imports = [ v ]; });
description = ''
Nix-darwin modules.
'';
};
};
};
}

View file

@ -36,6 +36,10 @@ in
options = {
devShell = mkOption {
type = types.package;
# We don't have a way to unset devShell in the flake without computing
# the root of each allSystems module, so to improve laziness, the best
# choice seems to be to require a devShell and give the opportunity
# to unset it manually.
default = throw "The default devShell was not configured for system ${system}. Please set it, or if you don't want to use the devShell attribute, set flake.devShell = lib.mkForce {};";
description = ''
A derivation that nix develop bases its environment on.

27
modules/nixosModules.nix Normal file
View file

@ -0,0 +1,27 @@
{ config, self, lib, flake-modules-core-lib, ... }:
let
inherit (lib)
filterAttrs
mapAttrs
mkOption
optionalAttrs
types
;
inherit (flake-modules-core-lib)
mkSubmoduleOptions
;
in
{
options = {
flake = mkSubmoduleOptions {
nixosModules = mkOption {
type = types.lazyAttrsOf types.unspecified;
default = { };
apply = mapAttrs (k: v: { _file = "${toString self.outPath}/flake.nix#nixosModules.${k}"; imports = [ v ]; });
description = ''
NixOS modules.
'';
};
};
};
}

32
modules/overlay.nix Normal file
View file

@ -0,0 +1,32 @@
{ config, lib, flake-modules-core-lib, ... }:
let
inherit (lib)
mkOption
types
;
inherit (flake-modules-core-lib)
mkSubmoduleOptions
;
in
{
options = {
flake = mkSubmoduleOptions {
overlay = mkOption {
# uniq should be ordered: https://github.com/NixOS/nixpkgs/issues/147052
# also update description when done
type = types.uniq (types.functionTo (types.functionTo (types.lazyAttrsOf types.unspecified)));
# This eta expansion exists for the sole purpose of making nix flake check happy.
apply = f: final: prev: f final prev;
default = _: _: { };
defaultText = lib.literalExpression or lib.literalExample ''final: prev: {}'';
description = ''
An overlay.
Note that this option's type is not mergeable. While overlays can be
composed, the order of composition is significant, but the module
system does not guarantee deterministic definition ordering.
'';
};
};
};
}