From 0173d29843c5f272a11bbec9ea56f938f759471c Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 16 Mar 2021 12:44:58 -0500 Subject: [PATCH] general: pass `self` to `./lib` & `./hosts` It is generally useful to acess the top level flake from library functions or hosts. This not only simplifies the mental model and code but also provides additional context and not least a handle to the repo source code in the nix store. closes #169 --- flake.nix | 10 ++++------ hosts/default.nix | 4 ++++ lib/default.nix | 2 +- lib/devos/mkHomeActivation.nix | 3 +-- lib/devos/mkPackages.nix | 4 ++-- lib/devos/mkPkgs.nix | 3 +-- shell/default.nix | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index ad3993691..e1ff3c4a8 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ extern = import ./extern { inherit inputs; }; - pkgs' = os.mkPkgs { inherit self; }; + pkgs' = os.mkPkgs; outputs = let @@ -57,7 +57,7 @@ overlay = import ./pkgs; overlays = lib.pathsToImportedAttrs (lib.pathsIn ./overlays); - lib = import ./lib { inherit nixos pkgs; }; + lib = import ./lib { inherit nixos pkgs self; }; templates.flk.path = ./.; templates.flk.description = "flk template"; @@ -79,16 +79,14 @@ let pkgs = pkgs'.${system}; in { packages = utils.lib.flattenTreeSystem system - (os.mkPackages { - inherit self pkgs; - }); + (os.mkPackages { inherit pkgs; }); devShell = import ./shell { inherit self system; }; legacyPackages.hmActivationPackages = - os.mkHomeActivation { inherit self; }; + os.mkHomeActivation; } ); in diff --git a/hosts/default.nix b/hosts/default.nix index 3ff999ccd..ef2f559ea 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -72,6 +72,10 @@ let ]; networking = { inherit hostName; }; + + _module.args = { + inherit self; + }; }; in dev.os.devosSystem { diff --git a/lib/default.nix b/lib/default.nix index cda082e3e..7f422f9fc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,4 @@ -args@{ nixos, pkgs, ... }: +args@{ nixos, pkgs, self, ... }: let inherit (nixos) lib; in lib.makeExtensible (self: let callLibs = file: import file diff --git a/lib/devos/mkHomeActivation.nix b/lib/devos/mkHomeActivation.nix index c88082400..6b7176a3a 100644 --- a/lib/devos/mkHomeActivation.nix +++ b/lib/devos/mkHomeActivation.nix @@ -1,6 +1,5 @@ -{ lib, ... }: +{ lib, self, ... }: -{ self }: let hmConfigs = lib.mapAttrs (_: config: config.config.home-manager.users) diff --git a/lib/devos/mkPackages.nix b/lib/devos/mkPackages.nix index 44209f006..a876ea0b7 100644 --- a/lib/devos/mkPackages.nix +++ b/lib/devos/mkPackages.nix @@ -1,6 +1,6 @@ -{ lib, dev, ... }: +{ lib, dev, self, ... }: -{ self, pkgs }: +{ pkgs }: let inherit (self) overlay overlays; packagesNames = lib.attrNames (overlay null null) diff --git a/lib/devos/mkPkgs.nix b/lib/devos/mkPkgs.nix index f9e53e71a..9b76e6df5 100644 --- a/lib/devos/mkPkgs.nix +++ b/lib/devos/mkPkgs.nix @@ -1,6 +1,5 @@ -{ lib, dev, nixos, ... }: +{ lib, dev, nixos, self, ... }: -{ self }: let inherit (self) inputs; in (inputs.utils.lib.eachDefaultSystem diff --git a/shell/default.nix b/shell/default.nix index d6b488339..0d1da5142 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -2,7 +2,7 @@ , system ? builtins.currentSystem }: let - pkgs = (self.lib.os.mkPkgs { inherit self; }).${system}; + pkgs = (self.lib.os.mkPkgs).${system}; inherit (pkgs) lib;