Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if options exist before setting them #226

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/devos/devosSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ lib.nixosSystem (args // {
];
})).config;
in
moduleList ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
};
}];
moduleList ++ [
({options, ... }: {
system.build = {
iso = isoConfig.system.build.isoImage;
homes = lib.optionalAttrs (options ? home-manager) hmConfig.home-manager.users;
};
})
];
})
82 changes: 47 additions & 35 deletions lib/devos/mkHosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,55 @@ let
modules;
};

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

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

hardware.enableRedistributableFirmware = lib.mkDefault true;

nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${inputs.home}"
global = { config, options, pkgs, ... }:
with lib; lib.mkMerge [
(optionalAttrs (options ? home-manager) {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
};
})
(optionalAttrs (options ? hardware.enableRedistributableFirmware) {
hardware.enableRedistributableFirmware = lib.mkDefault true;
})
(optionalAttrs (options ? users.mutableUsers) {
users.mutableUsers = lib.mkDefault false;
})
(optionalAttrs (options ? nix.nixPath) {
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${inputs.home}"
];
})
(optionalAttrs (options ? nix.registry) {
nix.registry = {
devos.flake = self;
nixos.flake = nixos;
override.flake = inputs.override;
};
})
(optionalAttrs (options ? nix.package) {
nix.package = pkgs.nixFlakes;
})
(optionalAttrs (options ? nix.extraOptions) {
nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';
})
(optionalAttrs (options ? nixpkgs.pkgs) {
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
})
(optionalAttrs (options ? system.configurationRevision) {
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
})
];

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

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

nix.package = pkgs.nixFlakes;

nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';

system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};

# Everything in `./modules/list.nix`.
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };

Expand Down