pkgs-lib: don't system space functions

have each function take pkgs as an argument, so a nixpkgs isn't created
just for pkgs-lib and they support more systems
This commit is contained in:
Pacman99 2021-04-25 16:36:48 -07:00
parent ba01aa7db7
commit 3986cc441b
4 changed files with 34 additions and 35 deletions

View file

@ -40,7 +40,7 @@
pkgs-lib = import ./pkgs-lib {
lib = nixpkgs.lib // self;
inherit nixpkgs deploy devshell;
inherit deploy devshell;
};
inherit (attrs)

View file

@ -1,13 +1,6 @@
{ lib, nixpkgs, deploy, devshell }:
lib.genAttrs
lib.defaultSystems
(system:
let
pkgs = import nixpkgs { inherit system; };
in
{ lib, deploy, devshell }:
{
tests = import ./tests { inherit lib deploy nixpkgs pkgs system; };
shell = import ./shell { inherit lib devshell deploy nixpkgs system; };
tests = import ./tests { inherit lib deploy; };
shell = import ./shell { inherit lib devshell deploy; };
}
)

View file

@ -1,27 +1,30 @@
{ lib, nixpkgs, devshell, deploy, system }:
{ lib, devshell, deploy }:
{ pkgs }:
let
overlays = [
devshell.overlay
(final: prev: {
deploy-rs =
deploy.packages.${prev.system}.deploy-rs;
})
];
pkgs = import nixpkgs { inherit system overlays; config = { }; };
pkgs' = import pkgs.path {
inherit (pkgs) system;
inherit overlays;
};
flk = pkgs.callPackage ./flk.nix { };
flk = pkgs'.callPackage ./flk.nix { };
installPkgs = (lib.nixosSystem {
inherit system;
inherit (pkgs') system;
modules = [ ];
}).config.system.build;
in
pkgs.devshell.mkShell {
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
pkgs'.devshell.mkShell {
imports = [ (pkgs'.devshell.importTOML ./devshell.toml) ];
packages = with installPkgs; [
nixos-install
@ -33,13 +36,13 @@ pkgs.devshell.mkShell {
pre-commit.text = lib.fileContents ./pre-commit.sh;
};
commands = with pkgs; [
commands = with pkgs'; [
{ package = flk; }
{
name = "nix";
help = pkgs.nixFlakes.meta.description;
help = pkgs'.nixFlakes.meta.description;
command = ''
${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes ca-references" "${"\${@}"}"
${pkgs'.nixFlakes}/bin/nix --experimental-features "nix-command flakes ca-references" "${"\${@}"}"
'';
}
]

View file

@ -1,25 +1,28 @@
{ lib, nixpkgs, pkgs, deploy, system }:
{ lib, deploy }:
let
mkChecks = { hosts, nodes, homes ? { } }:
mkChecks = { pkgs, hosts, nodes, homes ? { } }:
let
deployHosts = lib.filterAttrs
(n: _: hosts.${n}.config.nixpkgs.system == system)
(n: _: hosts.${n}.config.nixpkgs.system == pkgs.system)
nodes;
deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; };
deployChecks = deploy.lib.${pkgs.system}.deployChecks { nodes = deployHosts; };
tests =
lib.optionalAttrs (deployHosts != { })
{
profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))});
profilesTest = profilesTest {
inherit pkgs;
host = hosts.${(builtins.head (builtins.attrNames deployHosts))};
};
} // lib.mapAttrs (n: v: v.activationPackage) homes;
in
lib.recursiveUpdate tests deployChecks;
mkTest = host:
mkTest = { pkgs, host }:
let
nixosTesting =
(import "${nixpkgs}/nixos/lib/testing-python.nix" {
inherit system;
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
inherit (pkgs) system;
inherit (host.config.lib) specialArgs;
inherit pkgs;
extraConfigurations = [
@ -40,15 +43,15 @@ let
in
nixosTesting.makeTest calledTest;
profilesTest = host: mkTest host {
profilesTest = args@{ host, ... }: mkTest args {
name = "profiles";
machine = { suites, ... }: {
imports = suites.allProfiles ++ suites.allUsers;
imports = suites.allProfiles;
};
testScript = ''
machine.systemctl("is-system-running --wait")
${host.config.networking.hostName}.systemctl("is-system-running --wait")
'';
};
in