summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix82
-rw-r--r--lib/machines.nix46
-rw-r--r--lib/nixosModules.nix17
3 files changed, 82 insertions, 63 deletions
diff --git a/lib/default.nix b/lib/default.nix
index a5f3e17..430d6ec 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -1,75 +1,31 @@
-{ sources ? import ../npins
-, pkgs ? import sources.nixpkgs {}
+{ pkgs
+, sources
+, ...
}:
let
inherit (pkgs) lib;
-
- eval = configuration:
+in
+{
+ eval = config:
let
self =
lib.evalModules {
modules = [
- configuration
- {
- options = {
- machines = lib.mkOption {
- type = lib.types.attrsOf lib.types.raw;
- default = {};
- };
- outputs = lib.mkOption {
- type = lib.types.attrsOf lib.types.raw;
- default = {};
- };
- };
- config = {
- outputs.machines = lib.mapAttrs (name: configuration:
- nixos configuration
- ) self.config.machines;
- };
- }
+ config
+ ./machines.nix
+ ./nixosModules.nix
];
- specialArgs.self = self;
+ specialArgs = {
+ inherit
+ self
+ sources
+ pkgs
+ ;
+ inherit (pkgs)
+ lib
+ ;
+ };
};
-
- # nixos = config: lib.evalModules {
- # modules = [
- # config
- # {
- # # XXX Otherwise building manual fails
- # documentation.enable = false;
-
- # boot.loader.grub.device = "nodev";
- # fileSystems."/".device = "tmpfs";
- # nixpkgs.localSystem = "x86_64-linux";
- # }
- # ];
- # specialArgs.self = self;
- # };
-
- nixos = config: import (sources.nixpkgs + "/nixos/lib/eval-config.nix") {
- modules = [
- config
- {
- # XXX Otherwise building manual fails
- documentation.enable = false;
-
- boot.loader.grub.device = "nodev";
- fileSystems."/".device = "tmpfs";
- nixpkgs.localSystem = {
- system = "x86_64-linux";
- };
- }
- ];
- specialArgs.self = self;
-
- # The system is inherited from the current pkgs above.
- # Set it to null, to remove the "legacy" entrypoint's non-hermetic default.
- system = null;
- };
in
self;
-
-in
-{
- inherit eval;
}
diff --git a/lib/machines.nix b/lib/machines.nix
new file mode 100644
index 0000000..d652fcf
--- /dev/null
+++ b/lib/machines.nix
@@ -0,0 +1,46 @@
+{ lib
+, pkgs
+, self
+, sources
+, ...
+}:
+let
+ nixos = config: import (sources.nixpkgs + "/nixos/lib/eval-config.nix") {
+ modules = [
+ config
+ {
+ documentation.enable = false;
+ boot.loader.grub.device = "nodev";
+ fileSystems."/".device = "tmpfs";
+ nixpkgs.localSystem = {
+ system = "x86_64-linux";
+ };
+ }
+ ];
+ specialArgs = {
+ inherit
+ pkgs
+ self
+ sources
+ ;
+ };
+ system = null;
+ };
+in
+{
+ options = {
+ machines = lib.mkOption {
+ type = lib.types.attrsOf lib.types.raw;
+ default = {};
+ };
+ outputs.machines = lib.mkOption {
+ type = lib.types.attrsOf lib.types.raw;
+ default = {};
+ };
+ };
+ config = {
+ outputs.machines = lib.mapAttrs (name: configuration:
+ nixos configuration
+ ) self.config.machines;
+ };
+}
diff --git a/lib/nixosModules.nix b/lib/nixosModules.nix
new file mode 100644
index 0000000..ac9d124
--- /dev/null
+++ b/lib/nixosModules.nix
@@ -0,0 +1,17 @@
+{ lib
+, pkgs
+, self
+, sources
+, ...
+}:
+{
+ options = {
+ nixosModules = lib.mkOption {
+ type = lib.types.attrsOf lib.types.deferredModule;
+ };
+ outputs.nixosModules = lib.mkOption {
+ type = lib.types.attrsOf lib.types.deferredModule;
+ };
+ };
+ config.outputs.nixosModules = self.config.nixosModules;
+}