Skip to content

Commit

Permalink
flake: only use and export home if input exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Pacman99 committed Apr 1, 2021
1 parent 87b5f98 commit 480e024
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
11 changes: 5 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,10 @@
inherit multiPkgs suites extern;
};

homeConfigurations = os.mkHomeConfigurations;

nixosModules =
let moduleList = import ./modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

homeModules =
let moduleList = import ./users/modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

overlay = import ./pkgs;
overlays = lib.pathsToImportedAttrs (lib.pathsIn ./overlays);

Expand All @@ -72,6 +66,11 @@
templates.flk.path = ./.;
templates.flk.description = "flk template";
defaultTemplate = self.templates.flk;
} // nixos.lib.optionalAttrs (inputs ? home) {
homeConfigurations = os.mkHomeConfigurations;
homeModules =
let moduleList = import ./users/modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList;

} // nixos.lib.optionalAttrs (inputs ? deploy) {
deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
Expand Down
5 changes: 3 additions & 2 deletions lib/devos/devosSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ lib.nixosSystem (args // {
];
})).config;
in
moduleList ++ [{
moduleList ++ [({ options, ... }: {
system.build = {
iso = isoConfig.system.build.isoImage;
} // lib.optionalAttrs (options ? home-manager) {
homes = hmConfig.home-manager.users;
};
}];
})];
})
60 changes: 31 additions & 29 deletions lib/devos/mkHosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,41 @@ let
modules;
};

global = { config, ... }: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
};

hardware.enableRedistributableFirmware = lib.mkDefault true;
global = { config, options, ... }: lib.mkMerge [
{
hardware.enableRedistributableFirmware = lib.mkDefault true;

nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${inputs.home}"
];
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
] ++ lib.optional (inputs ? home) "home-manager=${inputs.home}";

nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};

nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = inputs.override;
};

nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';
nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = inputs.override;
};

system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';

system.configurationRevision = lib.mkIf (self ? rev) self.rev;
}
(lib.optionalAttrs (options ? home-manager) {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
};
})
];

# Everything in `./modules/list.nix`.
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
Expand Down
4 changes: 2 additions & 2 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ in
'';
};

homeTest = self.homeConfigurations."nixos@NixOS".home.activationPackage;

libTests = pkgs.runCommandNoCC "devos-lib-tests"
{
buildInputs = [
Expand Down Expand Up @@ -70,5 +68,7 @@ in
touch $out
'';
} // pkgs.lib.optionalAttrs (self ? homeConfigurations) {
homeTest = self.homeConfigurations."nixos@NixOS".home.activationPackage;
}

0 comments on commit 480e024

Please sign in to comment.