Skip to content

Commit

Permalink
Rework lib
Browse files Browse the repository at this point in the history
Signed-off-by: magic_rb <[email protected]>
  • Loading branch information
MagicRB committed Dec 26, 2024
1 parent 0ca294d commit 88b2366
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/dag.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

{ lib }:
{ lib, ... }:
import (builtins.fetchurl {
url = "https://raw.githubusercontent.com/nix-community/home-manager/45abf3d38a2b51c00c347cab6950f3734e023bba/modules/lib/dag.nix";
sha256 = "sha256-NN9iKanf86D1MH9Nx8nsQj9T2+Poy9XeW9pLcZIyFHU=";
Expand Down
55 changes: 24 additions & 31 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
lib:
let
inherit (lib) types;
this = {
makeSystem = import ./make-system.nix {
nglib = this;
overlay = import ../overlay;
lib.fix (
nglib:
let
overlay = import ../overlay;
args = {
inherit lib nglib overlay;
};
dag = import ./dag.nix { inherit lib; };
generators = import ./generators.nix { inherit lib; };
in
{
dag = import ./dag.nix args;
generators = import ./generators.nix args;
mkDefaultRec = lib.mapAttrsRecursive (_: v: lib.mkDefault v);
mkApply = fun: x: {
original = x;
Expand All @@ -18,31 +20,31 @@ let
description:
lib.mkOption {
inherit description;
type = types.attrsOf (
types.submodule {
type = lib.types.attrsOf (
lib.types.submodule {
options = {
data = lib.mkOption {
description = ''
Script fragment which to run.
'';
type = types.str;
type = lib.types.str;
};
before = lib.mkOption {
description = ''
Script before dependencies. See <literal>/lib/dag.nix</literal>.
'';
type = with types; listOf str;
type = lib.types.listOf lib.types.str;
};
after = lib.mkOption {
description = ''
Script after dependencies. See <literal>/lib/dag.nix</literal>
'';
type = with types; listOf str;
type = lib.types.listOf lib.types.str;
};
};
}
);
apply = this.dag.dagTopoSort;
apply = nglib.dag.dagTopoSort;
default = { };
};

Expand All @@ -64,27 +66,18 @@ let
)}
'';

nottmpfiles = import ./nottmpfiles {
inherit lib;
nglib = this;
};
nottmpfiles = import ./nottmpfiles args;

maybeChangeUserAndGroup =
user: group: script:
if user != null then
"chpst -u ${user}${lib.optionalString (group != null) ":${group}"} ${script}"
else
script;
};
in
this
// {
inherit
(import ./options.nix {
inherit lib;
nglib = this;
})
mkUserOption
mkGroupOption
;
}

inherit (import ./options.nix args) mkUserOption mkGroupOption;

makeSystem = import ./make-system.nix { inherit lib nglib overlay; };

}
)
2 changes: 1 addition & 1 deletion lib/generators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

{ lib }:
{ lib, ... }:
let
inherit (lib)
isAttrs
Expand Down
2 changes: 1 addition & 1 deletion lib/make-system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# These arguments are provided by the overarching NixNG repository and are not user confugurable.
{ nglib, overlay }:
{ nglib, overlay, ... }:
# These arguments are user configurable
{
nixpkgs,
Expand Down

0 comments on commit 88b2366

Please sign in to comment.