From 452dcf99bb52c180223bdf388f8a68c8eb7907ff Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Thu, 18 Dec 2025 11:25:46 +1000 Subject: [PATCH] module: sys.nix --- nib/default.nix | 39 ++++----------------------------------- nib/sys.nix | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 nib/sys.nix diff --git a/nib/default.nix b/nib/default.nix index 8a0df53..a6448a6 100644 --- a/nib/default.nix +++ b/nib/default.nix @@ -1,52 +1,21 @@ {systems, ...}: let # TODO: move this to a new module mkMod' = args: mod: import mod args; - mkMod = mkMod' {inherit nib;}; + mkMod = mkMod' {inherit systems nib;}; std = mkMod ./std; types = mkMod ./types; parse = mkMod ./parse; panic = mkMod ./panic.nix; + sys = mkMod ./sys.nix; nib = std.mergeAttrsList [ # submodule content is accessible first by submodule name # then by the name of the content (ie self.submodule.myFunc) {inherit std types panic parse;} - # submodule is included directly to this module (ie self.myFunc) - - # this module - { - # === External Functions === - withPkgs = repo: config: system: - import repo { - inherit system; - } - // config; - - mkSys = input: let - # function taking a system as argument - pkgsFor = input.pkgs; - in { - inherit pkgsFor; - forAllSystems = f: - std.genAttrs systems ( - system: f system (pkgsFor system) - ); - }; - - mkUSys = input: let - # functions taking a system as argument - pkgsFor = input.pkgs; - upkgsFor = input.upkgs; - in { - inherit pkgsFor upkgsFor; - forAllSystems = f: - std.genAttrs systems ( - system: f system (pkgsFor system) (upkgsFor system) - ); - }; - } + # submodule content accessible directly (ie self.myFunc) + sys ]; in nib diff --git a/nib/sys.nix b/nib/sys.nix new file mode 100644 index 0000000..b487663 --- /dev/null +++ b/nib/sys.nix @@ -0,0 +1,37 @@ +{ + systems, + nib, + ... +}: let + std = nib.std; +in { + # === External Functions === + withPkgs = repo: config: system: + import repo { + inherit system; + } + // config; + + mkSys = input: let + # function taking a system as argument + pkgsFor = input.pkgs; + in { + inherit pkgsFor; + forAllSystems = f: + std.genAttrs systems ( + system: f system (pkgsFor system) + ); + }; + + mkUSys = input: let + # functions taking a system as argument + pkgsFor = input.pkgs; + upkgsFor = input.upkgs; + in { + inherit pkgsFor upkgsFor; + forAllSystems = f: + std.genAttrs systems ( + system: f system (pkgsFor system) (upkgsFor system) + ); + }; +}