mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
commit
80717d1161
21 changed files with 24 additions and 67 deletions
|
@ -1,4 +1,3 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
./modules/apps.nix
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
when.dayOfMonth = 1;
|
||||
};
|
||||
|
||||
perSystem = { config, self', inputs', pkgs, ... }: {
|
||||
perSystem = { config, pkgs, ... }: {
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = [
|
||||
|
@ -42,7 +42,7 @@
|
|||
# for repl exploration / debug
|
||||
config.config = config;
|
||||
options.mySystem = lib.mkOption { default = config.allSystems.${builtins.currentSystem}; };
|
||||
config.effects = withSystem "x86_64-linux" ({ config, pkgs, hci-effects, ... }: {
|
||||
config.effects = withSystem "x86_64-linux" ({ pkgs, hci-effects, ... }: {
|
||||
tests = {
|
||||
template = pkgs.callPackage ./tests/template.nix { inherit hci-effects; };
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
|
||||
};
|
||||
|
||||
outputs = { self, ... }:
|
||||
outputs = { ... }:
|
||||
{
|
||||
# The dev tooling is in ./flake-module.nix
|
||||
# See comment at `inputs` above.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
toplevel@{ config, lib, flake-parts-lib, getSystemIgnoreWarning, ... }:
|
||||
toplevel@{ lib, flake-parts-lib, getSystemIgnoreWarning, ... }:
|
||||
let
|
||||
inherit (flake-parts-lib)
|
||||
mkPerSystemOption;
|
||||
|
@ -37,7 +37,7 @@ in
|
|||
};
|
||||
};
|
||||
config = {
|
||||
_module.args.final = lib.mkDefault (pkgs.extend (toplevel.config.flake.overlays.default));
|
||||
_module.args.final = lib.mkDefault (pkgs.extend toplevel.config.flake.overlays.default);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{ config, self, lib, flake-parts-lib, ... }:
|
||||
{ self, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
mapAttrs
|
||||
mkOption
|
||||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
nixpkgs-lib.url = "github:NixOS/nixpkgs/nixos-unstable?dir=lib";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs-lib, ... }: {
|
||||
outputs = { nixpkgs-lib, ... }: {
|
||||
lib = import ./lib.nix { inherit (nixpkgs-lib) lib; };
|
||||
templates = {
|
||||
default = {
|
||||
|
|
23
lib.nix
23
lib.nix
|
@ -28,27 +28,6 @@ let
|
|||
then maybeFlake._type == "flake"
|
||||
else maybeFlake ? inputs && maybeFlake ? outputs && maybeFlake ? sourceInfo;
|
||||
|
||||
# Polyfill functionTo to make sure it has type merging.
|
||||
# Remove 2022-12
|
||||
functionTo =
|
||||
let sample = types.functionTo lib.types.str;
|
||||
in
|
||||
if sample.functor.wrapped._type or null == "option-type"
|
||||
then types.functionTo
|
||||
else
|
||||
elemType: lib.mkOptionType {
|
||||
name = "functionTo";
|
||||
description = "function that evaluates to a(n) ${elemType.description}";
|
||||
check = lib.isFunction;
|
||||
merge = loc: defs:
|
||||
fnArgs: (lib.mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
|
||||
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]);
|
||||
getSubModules = elemType.getSubModules;
|
||||
substSubModules = m: functionTo (elemType.substSubModules m);
|
||||
functor = (lib.defaultFunctor "functionTo") // { type = functionTo; wrapped = elemType; };
|
||||
nestedTypes.elemType = elemType;
|
||||
};
|
||||
|
||||
# Polyfill https://github.com/NixOS/nixpkgs/pull/163617
|
||||
deferredModuleWith = lib.deferredModuleWith or (
|
||||
attrs@{ staticModules ? [ ] }: mkOptionType {
|
||||
|
@ -216,7 +195,7 @@ let
|
|||
} // optionalAttrs (toType != null) {
|
||||
type = toType;
|
||||
});
|
||||
config = (mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt);
|
||||
config = mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt;
|
||||
};
|
||||
|
||||
# Helper function for importing while preserving module location. To be added
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
@ -17,11 +17,6 @@ let
|
|||
getExe = x:
|
||||
"${lib.getBin x}/bin/${x.meta.mainProgram or (throw ''Package ${x.name or ""} does not have meta.mainProgram set, so I don't know how to find the main executable. You can set meta.mainProgram, or pass the full path to executable, e.g. program = "''${pkg}/bin/foo"'')}";
|
||||
|
||||
getBin = x:
|
||||
if !x?outputSpecified || !x.outputSpecified
|
||||
then x.bin or x.out or x
|
||||
else x;
|
||||
|
||||
appType = lib.types.submodule {
|
||||
options = {
|
||||
type = mkOption {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
|
|
@ -10,9 +10,6 @@ let
|
|||
inherit (flake-parts-lib)
|
||||
mkPerSystemOption
|
||||
;
|
||||
inherit (builtins)
|
||||
removeAttrs
|
||||
;
|
||||
|
||||
mkDebugConfig = { config, options, extendModules }: config // {
|
||||
inherit config;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
{ config, lib, ... }:
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
mapAttrs
|
||||
mkOption
|
||||
optionalAttrs
|
||||
types
|
||||
;
|
||||
in
|
||||
|
|
|
@ -24,7 +24,7 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
perSystem = mkPerSystemOption ({ config, ... }: {
|
||||
perSystem = mkPerSystemOption {
|
||||
_file = ./formatter.nix;
|
||||
options = {
|
||||
formatter = mkOption {
|
||||
|
@ -35,7 +35,7 @@ in
|
|||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
config = {
|
||||
flake.formatter =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, withSystem, ... }:
|
||||
{ withSystem, ... }:
|
||||
{
|
||||
config = {
|
||||
_module.args = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{ config, self, lib, flake-parts-lib, ... }:
|
||||
{ self, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
filterAttrs
|
||||
mapAttrs
|
||||
mkOption
|
||||
optionalAttrs
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
@ -16,7 +16,7 @@ in
|
|||
# also update description when done
|
||||
type = types.lazyAttrsOf (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 = lib.mapAttrs (k: f: final: prev: f final prev);
|
||||
apply = lib.mapAttrs (_k: f: final: prev: f final prev);
|
||||
default = { };
|
||||
example = lib.literalExpression or lib.literalExample ''
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, flake-parts-lib, ... }:
|
||||
{ lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
|
|
|
@ -7,10 +7,6 @@ let
|
|||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
mkSubmoduleOptions
|
||||
mkPerSystemOption
|
||||
;
|
||||
|
||||
transpositionModule = {
|
||||
options = {
|
||||
|
@ -67,7 +63,7 @@ in
|
|||
(attrName: attrConfig: flake.${attrName}.${system})
|
||||
config.transposition;
|
||||
|
||||
perSystem = { ... }: {
|
||||
perSystem = {
|
||||
options =
|
||||
mapAttrs
|
||||
(k: v: lib.mkOption { })
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{ config, lib, flake-parts-lib, self, getSystem, ... }:
|
||||
{ lib, flake-parts-lib, getSystem, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
genAttrs
|
||||
mapAttrs
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
@ -12,7 +10,7 @@ let
|
|||
in
|
||||
{
|
||||
options = {
|
||||
perSystem = mkPerSystemOption ({ config, options, system, specialArgs, ... }: {
|
||||
perSystem = mkPerSystemOption ({ config, options, specialArgs, ... }: {
|
||||
_file = ./perSystem.nix;
|
||||
options = {
|
||||
allModuleArgs = mkOption {
|
||||
|
|
Loading…
Reference in a new issue