diff --git a/eval-config.nix b/eval-config.nix new file mode 100644 index 00000000..aa199061 --- /dev/null +++ b/eval-config.nix @@ -0,0 +1,41 @@ +{ lib, system ? builtins.currentSystem or "x86_64-darwin" }: + +{ modules +, inputs +, baseModules ? import ./modules/module-list.nix +, specialArgs ? {} +}@args: + +let + inputsModule = { + _file = ./eval-config.nix; + config = { + _module.args.inputs = inputs; + }; + }; + + pkgsModule = { config, inputs, ... }: { + _file = ./eval-config.nix; + config = { + _module.args.pkgs = import inputs.nixpkgs config.nixpkgs; + nixpkgs.system = system; + }; + }; + + eval = lib.evalModules (builtins.removeAttrs args ["inputs"] // { + modules = modules ++ [ inputsModule pkgsModule ] ++ baseModules; + args = { inherit baseModules modules; }; + specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs; + }); + + # Was moved in nixpkgs #82751, so both need to be handled here until 20.03 is deprecated. + # https://github.com/NixOS/nixpkgs/commits/dcdd232939232d04c1132b4cc242dd3dac44be8c + _module = eval._module or eval.config._module; +in + +{ + inherit (_module.args) pkgs; + inherit (eval) options config; + + system = eval.config.system.build.toplevel; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..8871e132 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1602411953, + "narHash": "sha256-gbupmxRpoQZqL5NBQCJN2GI5G7XDEHHHYKhVwEj5+Ps=", + "owner": "LnL7", + "repo": "nixpkgs", + "rev": "f780534ea2d0c12e62607ff254b6b45f46653f7a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..204898c5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + # WARNING this is very much still experimental. + description = "A collection of darwin modules"; + + outputs = { self, nixpkgs }: { + + lib = { + # TODO handle multiple architectures. + evalConfig = import ./eval-config.nix { inherit (nixpkgs) lib; }; + + darwinSystem = { modules, inputs ? {}, ... }@args: self.lib.evalConfig (args // { + inputs = { inherit nixpkgs; darwin = self; } // inputs; + modules = modules ++ [ + ]; + }); + }; + + darwinModules.lnl = import ./modules/examples/lnl.nix; + darwinModules.simple = import ./modules/examples/simple.nix; + darwinModules.ofborg = import ./modules/examples/ofborg.nix; + darwinModules.hydra = import ./modules/examples/hydra.nix; + + checks.x86_64-darwin.simple = (self.lib.darwinSystem { + modules = [ self.darwinModules.simple ]; + }).system; + + }; +}