improve home-manager and deploy-rs integration

move both to be setup in template
only set home-manager options if they exist
This commit is contained in:
Pacman99 2021-05-02 10:35:29 -07:00 committed by David Arnold
parent 7bf605d08c
commit b8f7cdbe63
6 changed files with 36 additions and 27 deletions

View file

@ -79,7 +79,7 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"narHash": "sha256-jG9Y7IiZkB+xKuqsVr2wr0zfV2TNziIIRmv0MHqzis0=", "narHash": "sha256-/htTDxf3/n8lcL7Gnoi3+uamuY/KnlSMWDQ76dzQpac=",
"path": "./lib", "path": "./lib",
"type": "path" "type": "path"
}, },

View file

@ -79,6 +79,10 @@
}; };
}; };
homeConfigurations = devos.lib.mkHomeConfigurations self.nixosConfigurations;
deploy.nodes = devos.lib.mkDeployNodes self.nixosConfigurations { };
#defaultTemplate = self.templates.flk; #defaultTemplate = self.templates.flk;
templates.flk.path = ./.; templates.flk.path = ./.;
templates.flk.description = "flk template"; templates.flk.description = "flk template";

View file

@ -19,18 +19,19 @@
strings = import ./strings.nix { lib = combinedLib; }; strings = import ./strings.nix { lib = combinedLib; };
modules = import ./modules.nix { lib = combinedLib; }; modules = import ./modules.nix { lib = combinedLib; };
importers = import ./importers.nix { lib = combinedLib; }; importers = import ./importers.nix { lib = combinedLib; };
generators = import ./generators.nix { lib = combinedLib; };
mkFlake = { generators = import ./generators.nix {
__functor = import ./mkFlake {
lib = combinedLib; lib = combinedLib;
inherit deploy; inherit deploy;
}; };
mkFlake = {
__functor = import ./mkFlake { lib = combinedLib; };
evalArgs = import ./mkFlake/evalArgs.nix { lib = combinedLib; }; evalArgs = import ./mkFlake/evalArgs.nix { lib = combinedLib; };
}; };
pkgs-lib = import ./pkgs-lib { pkgs-lib = import ./pkgs-lib {
lib = nixpkgs.lib // self; lib = combinedLib;
inherit deploy devshell; inherit deploy devshell;
}; };

View file

@ -1,4 +1,4 @@
{ lib }: { lib, deploy }:
{ {
mkHomeConfigurations = nixosConfigurations: mkHomeConfigurations = nixosConfigurations:
with lib; with lib;
@ -12,7 +12,7 @@
in in
foldl recursiveUpdate { } (attrValues hmConfigs); foldl recursiveUpdate { } (attrValues hmConfigs);
mkDeployNodes = mkDeployNodes = hosts: extraConfig:
/** /**
Synopsis: mkNodes _nixosConfigurations_ Synopsis: mkNodes _nixosConfigurations_
@ -20,14 +20,18 @@
where _nixosConfigurations_ are `nodes`. where _nixosConfigurations_ are `nodes`.
**/ **/
deploy: lib.mapAttrs (_: config: { lib.mapAttrs
(_: config: lib.recursiveUpdate
{
hostname = config.config.networking.hostName; hostname = config.config.networking.hostName;
profiles.system = { profiles.system = {
user = "root"; user = "root";
path = deploy.lib.x86_64-linux.activate.nixos config; path = deploy.lib.x86_64-linux.activate.nixos config;
}; };
}); }
extraConfig)
hosts;
mkSuites = { suites, profiles }: mkSuites = { suites, profiles }:
let let

View file

@ -1,4 +1,4 @@
{ lib, deploy }: { lib }:
let let
inherit (builtins) mapAttrs attrNames attrValues head isFunction; inherit (builtins) mapAttrs attrNames attrValues head isFunction;
in in
@ -71,9 +71,6 @@ lib.systemFlake (lib.mergeAny
nixosModules = lib.exporter.modulesFromList cfg.nixos.hostDefaults.modules; nixosModules = lib.exporter.modulesFromList cfg.nixos.hostDefaults.modules;
homeModules = lib.exporter.modulesFromList cfg.home.modules; homeModules = lib.exporter.modulesFromList cfg.home.modules;
homeConfigurations = lib.mkHomeConfigurations self.nixosConfigurations;
deploy.nodes = lib.mkDeployNodes deploy self.nixosConfigurations;
overlays = lib.exporter.overlaysFromChannelsExporter { overlays = lib.exporter.overlaysFromChannelsExporter {
# since we can't detect overlays owned by self # since we can't detect overlays owned by self

View file

@ -1,6 +1,8 @@
{ lib }: { lib }:
{ {
hmDefaults = { suites, modules }: { hmDefaults = { suites, modules }:
{ options, ... }: {
config = lib.optionalAttrs (options ? home-manager) {
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
@ -9,6 +11,7 @@
sharedModules = modules; sharedModules = modules;
}; };
}; };
};
globalDefaults = { self, inputs }: globalDefaults = { self, inputs }:
let let