Skip to content

Commit

Permalink
general: pass self to ./lib & ./hosts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
David Arnold committed Mar 16, 2021
1 parent f53b6a4 commit de6e009
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
10 changes: 4 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

extern = import ./extern { inherit inputs; };

pkgs' = os.mkPkgs { inherit self; };
pkgs' = os.mkPkgs;

outputs =
let
Expand All @@ -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";
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ let
];

networking = { inherit hostName; };

_module.args = {
inherit self;
};
};
in
dev.os.devosSystem {
Expand Down
8 changes: 4 additions & 4 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
args@{ nixos, pkgs, ... }:
args@{ nixos, pkgs, self, ... }:
let inherit (nixos) lib; in
lib.makeExtensible (self:
lib.makeExtensible (final:
let callLibs = file: import file
({
inherit lib;

dev = self;
dev = final;
} // args);
in
with self;
with final;
{
inherit callLibs;

Expand Down
3 changes: 1 addition & 2 deletions lib/devos/mkHomeActivation.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib, ... }:
{ lib, self, ... }:

{ self }:
let hmConfigs =
lib.mapAttrs
(_: config: config.config.home-manager.users)
Expand Down
4 changes: 2 additions & 2 deletions lib/devos/mkPackages.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, dev, ... }:
{ lib, dev, self, ... }:

{ self, pkgs }:
{ pkgs }:
let
inherit (self) overlay overlays;
packagesNames = lib.attrNames (overlay null null)
Expand Down
3 changes: 1 addition & 2 deletions lib/devos/mkPkgs.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib, dev, nixos, ... }:
{ lib, dev, nixos, self, ... }:

{ self }:
let inherit (self) inputs;
in
(inputs.utils.lib.eachDefaultSystem
Expand Down
2 changes: 1 addition & 1 deletion shell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit de6e009

Please sign in to comment.