From f04f8aef6985ba1a2897647b5415dd76b144e595 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Fri, 17 Sep 2021 13:55:34 -0500 Subject: [PATCH] refac(build): #546 simplify scope and code - Refactor code so we know what's flake specific - Limit scope of this experimental feature to linux x86-64 --- flake.lock | 18 +++++++------- flake.nix | 48 +++++++++++++++++++++++++----------- src/evaluator/from-flake.nix | 30 ---------------------- 3 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 src/evaluator/from-flake.nix diff --git a/flake.lock b/flake.lock index 4aa88e35..1252751c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,23 @@ { "nodes": { - "flakeUtils": { + "nixpkgs": { "locked": { - "lastModified": 1631561581, - "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "lastModified": 1631904605, + "narHash": "sha256-+EButmvDYPSK1EOkiBndJHmAgfEXFrqQTkzA/amSGRE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cb5ca6505b964bc76aaa866634e4b8ad12da7792", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "nixos", + "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flakeUtils": "flakeUtils" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 39769dcd..8303b681 100644 --- a/flake.nix +++ b/flake.nix @@ -2,22 +2,42 @@ description = "A DevSecOps framework powered by Nix!"; inputs = { - flakeUtils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs"; }; - outputs = { flakeUtils, ... }: - (flakeUtils.lib.eachDefaultSystem - (system: - let makes = import ./default.nix { inherit system; }; + outputs = { nixpkgs, ... }: + let makes = import ./default.nix { system = "x86_64-linux"; }; + in + { + defaultPackage.x86_64-linux = makes; + + defaultApp.x86_64-linux.program = "${makes}/bin/m"; + defaultApp.x86_64-linux.type = "app"; + + lib.flakes.evaluate = + { inputs + , system + }: + let + evaluated = import ./src/evaluator/default.nix { + # TODO: Deprecate this + makesExecutionId = "123"; + makesSrc = inputs.makes.outPath; + projectSrc = inputs.self.sourceInfo.outPath; + # TODO: Make it mutable + projectSrcMutable = inputs.self.sourceInfo.outPath; + inherit system; + }; + evaluatedOutputs = nixpkgs.lib.mapAttrs' + (output: value: { + name = "makes:config:outputs:${output}"; + inherit value; + }) + evaluated.config.outputs; in - { - defaultPackage = makes; - defaultApp.program = "${makes}/bin/m"; - defaultApp.type = "app"; - })) - // { - lib = { - fromFlake = import ./src/evaluator/from-flake.nix; - }; + evaluatedOutputs // { + "makes:config:attrs" = evaluated.config.attrs; + "makes:config:cacheAsJson" = evaluated.config.cacheAsJson; + }; }; } diff --git a/src/evaluator/from-flake.nix b/src/evaluator/from-flake.nix deleted file mode 100644 index 0ff16200..00000000 --- a/src/evaluator/from-flake.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ inputs -, system -, ... -}: -let - evaluatorOutputs = import ./default.nix { - # TODO: How to compute this on Flakes? - makesExecutionId = "123"; - makesSrc = inputs.makes.outPath; - projectSrc = inputs.self.sourceInfo.outPath; - # TODO: Make it mutable - projectSrcMutable = inputs.self.sourceInfo.outPath; - inherit system; - }; - - packages = - (builtins.listToAttrs (builtins.map - (output: { - name = "makes:config:outputs:${output}"; - value = evaluatorOutputs.config.outputs.${output}; - }) - (builtins.attrNames evaluatorOutputs.config.outputs))) - // { - "makes:config:attrs" = evaluatorOutputs.config.attrs; - "makes:config:cacheAsJson" = evaluatorOutputs.config.cacheAsJson; - }; -in -{ - inherit packages; -}