From 048b886435f7ad694c2163c57c0fef81b8e89cf8 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Mon, 31 May 2021 11:58:17 -0700 Subject: [PATCH] use self.inputs instead of inputs --- src/mkFlake/default.nix | 10 +++++----- src/mkFlake/evalArgs.nix | 13 +++---------- src/modules.nix | 10 +++++----- tests/fullFlake/default.nix | 9 ++++----- tests/fullFlake/modules/customBuilds.nix | 1 - 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/mkFlake/default.nix b/src/mkFlake/default.nix index 03dc213..12b5932 100644 --- a/src/mkFlake/default.nix +++ b/src/mkFlake/default.nix @@ -3,7 +3,7 @@ let inherit (builtins) mapAttrs attrNames attrValues head isFunction; in -_: { self, inputs, ... } @ args: +_: { self, ... } @ args: let config = lib.mkFlake.evalArgs { @@ -20,7 +20,7 @@ let modules = cfg.home.modules ++ cfg.home.externalModules; }) (globalDefaults { - inherit self inputs; + inherit self; }) ]; @@ -41,7 +41,8 @@ let in lib.systemFlake (lib.mergeAny { - inherit self inputs hosts; + inherit self hosts; + inherit (self) inputs; inherit (cfg) channelsConfig supportedSystems; channels = mapAttrs @@ -84,8 +85,7 @@ lib.systemFlake (lib.mergeAny # since we can't detect overlays owned by self # we have to filter out ones exported by the inputs # optimally we would want a solution for NixOS/nix#4740 - inherit inputs; - inherit (self) pkgs; + inherit (self) pkgs inputs; }; outputsBuilder = channels: diff --git a/src/mkFlake/evalArgs.nix b/src/mkFlake/evalArgs.nix index 9dbb3c9..b8af1ca 100644 --- a/src/mkFlake/evalArgs.nix +++ b/src/mkFlake/evalArgs.nix @@ -5,7 +5,7 @@ let argOpts = with lib; { config, ... }: let cfg = config; - inherit (config) self; + inherit (args) self; maybeImport = obj: if (builtins.isPath obj || builtins.isString obj) && lib.hasSuffix ".nix" obj then @@ -47,8 +47,8 @@ let options = with types; { input = mkOption { type = flakeType; - default = cfg.inputs.${name}; - defaultText = "inputs."; + default = self.inputs.${name}; + defaultText = "self.inputs."; description = '' nixpkgs flake input to use for this channel ''; @@ -239,13 +239,6 @@ let type = flakeType; description = "The flake to create the devos outputs for"; }; - inputs = mkOption { - type = attrsOf flakeType; - description = '' - inputs for this flake - used to set channel defaults and create registry - ''; - }; supportedSystems = mkOption { type = listOf str; default = lib.defaultSystems; diff --git a/src/modules.nix b/src/modules.nix index 16bbd6f..c2d27ad 100644 --- a/src/modules.nix +++ b/src/modules.nix @@ -13,7 +13,7 @@ }; }; - globalDefaults = { self, inputs }: + globalDefaults = { self }: let experimentalFeatures = [ "flakes" @@ -28,8 +28,8 @@ nix.nixPath = [ "nixpkgs=${channel.input}" "nixos-config=${self}/lib/compat/nixos" - ] ++ lib.optionals (inputs ? home) [ - "home-manager=${inputs.home}" + ] ++ lib.optionals (self.inputs ? home) [ + "home-manager=${self.inputs.home}" ]; nix.registry = { @@ -54,7 +54,7 @@ system.configurationRevision = lib.mkIf (self ? rev) self.rev; }; - isoConfig = { self, inputs, fullHostConfig }: + isoConfig = { self, fullHostConfig }: { config, modulesPath, ... }@args: { imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" ]; @@ -63,7 +63,7 @@ # so convert each to list which can be coerced to string disabledModules = map lib.singleton (args.suites.allProfiles or [ ]); - nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs; + nix.registry = lib.mapAttrs (n: v: { flake = v; }) self.inputs; isoImage.isoBaseName = "nixos-" + config.networking.hostName; isoImage.contents = [{ diff --git a/tests/fullFlake/default.nix b/tests/fullFlake/default.nix index 91b0287..aadd830 100644 --- a/tests/fullFlake/default.nix +++ b/tests/fullFlake/default.nix @@ -4,11 +4,10 @@ let self = self // { outPath = toString ./.; - }; - - inputs = { - nixos = pkgs.input; - latest = pkgs.input; + inputs = { + nixos = pkgs.input; + latest = pkgs.input; + }; }; channelsConfig = { allowUnfree = true; }; diff --git a/tests/fullFlake/modules/customBuilds.nix b/tests/fullFlake/modules/customBuilds.nix index 875d23a..e343c80 100644 --- a/tests/fullFlake/modules/customBuilds.nix +++ b/tests/fullFlake/modules/customBuilds.nix @@ -10,7 +10,6 @@ in system.build = { iso = (mkBuild (diggaLib.modules.isoConfig { inherit self; - inherit (self) inputs; fullHostConfig = config; })).config.system.build.isoImage;