Merge #161
161: Multi-arch support for hosts(nixosConfigurations) r=nrdxp a=Pacman99 fixes #72 also related, #125 This allows users to set `nixpkgs.system` to any architecture exported by the nixpkgs flake and nixpkgs.pkgs will be set to that system. I also added `multiPkgs` as a special arg and made `nixpkgs.pkgs` a default. So if someone wanted to do crossSystem builds or anything else with pkgs, that is also an option(eg. mobile-nixos!!). Co-authored-by: Pacman99 <pachum99@gmail.com>
This commit is contained in:
commit
c050027171
5 changed files with 77 additions and 74 deletions
39
flake.nix
39
flake.nix
|
@ -36,18 +36,16 @@
|
|||
|
||||
extern = import ./extern { inherit inputs; };
|
||||
|
||||
pkgs' = os.mkPkgs;
|
||||
multiPkgs = os.mkPkgs;
|
||||
|
||||
outputs =
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = pkgs'.${system};
|
||||
in
|
||||
{
|
||||
outputs = {
|
||||
nixosConfigurations =
|
||||
import ./hosts (nixos.lib.recursiveUpdate inputs {
|
||||
inherit pkgs system extern;
|
||||
inherit (pkgs) lib;
|
||||
inherit multiPkgs extern;
|
||||
defaultSystem = "x86_64-linux";
|
||||
lib = nixos.lib.extend (final: prev: {
|
||||
dev = self.lib;
|
||||
});
|
||||
});
|
||||
|
||||
nixosModules =
|
||||
|
@ -57,27 +55,28 @@
|
|||
overlay = import ./pkgs;
|
||||
overlays = lib.pathsToImportedAttrs (lib.pathsIn ./overlays);
|
||||
|
||||
lib = import ./lib { inherit nixos pkgs self inputs; };
|
||||
lib = import ./lib { inherit nixos self inputs; };
|
||||
|
||||
templates.flk.path = ./.;
|
||||
templates.flk.description = "flk template";
|
||||
defaultTemplate = self.templates.flk;
|
||||
|
||||
deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
|
||||
|
||||
checks =
|
||||
let
|
||||
tests = import ./tests { inherit self pkgs; };
|
||||
deployChecks = builtins.mapAttrs
|
||||
(system: deployLib: deployLib.deployChecks self.deploy)
|
||||
deploy.lib;
|
||||
in
|
||||
nixos.lib.recursiveUpdate tests deployChecks;
|
||||
};
|
||||
|
||||
systemOutputs = utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = pkgs'.${system}; in
|
||||
let pkgs = multiPkgs.${system}; in
|
||||
{
|
||||
checks =
|
||||
let
|
||||
tests = nixos.lib.optionalAttrs (system == "x86_64-linux")
|
||||
(import ./tests { inherit self pkgs; });
|
||||
deployHosts = nixos.lib.filterAttrs
|
||||
(n: _: self.nixosConfigurations.${n}.config.nixpkgs.system == system) self.deploy.nodes;
|
||||
deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; };
|
||||
in
|
||||
nixos.lib.recursiveUpdate tests deployChecks;
|
||||
|
||||
packages = utils.lib.flattenTreeSystem system
|
||||
(os.mkPackages { inherit pkgs; });
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ that you intend to use on your machine.
|
|||
Additionally, this is the perfect place to import anything you might need from
|
||||
the [nixos-hardware][nixos-hardware] repository.
|
||||
|
||||
> ##### _Note:_
|
||||
> Set `nixpkgs.system` to the architecture of this host, default is "x86_64-linux".
|
||||
> Keep in mind that not all packages are available for all architectures.
|
||||
|
||||
## Example
|
||||
|
||||
hosts/librem.nix:
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
, lib
|
||||
, nixos
|
||||
, override
|
||||
, pkgs
|
||||
, multiPkgs
|
||||
, self
|
||||
, system
|
||||
, defaultSystem
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
|
@ -27,7 +27,7 @@ let
|
|||
modules;
|
||||
};
|
||||
|
||||
global = {
|
||||
global = { config, ... }: {
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
|
@ -39,7 +39,7 @@ let
|
|||
"home-manager=${home}"
|
||||
];
|
||||
|
||||
nixpkgs = { inherit pkgs; };
|
||||
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
|
||||
|
||||
nix.registry = {
|
||||
devos.flake = self;
|
||||
|
@ -79,7 +79,8 @@ let
|
|||
};
|
||||
in
|
||||
dev.os.devosSystem {
|
||||
inherit system specialArgs;
|
||||
inherit specialArgs;
|
||||
system = defaultSystem;
|
||||
modules = modules // { inherit local lib; };
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
args@{ nixos, pkgs, self, ... }:
|
||||
args@{ nixos, self, ... }:
|
||||
let inherit (nixos) lib; in
|
||||
lib.makeExtensible (final:
|
||||
let callLibs = file: import file
|
||||
|
|
|
@ -59,7 +59,6 @@ let
|
|||
nixosTesting.makeTest calledTest;
|
||||
in
|
||||
{
|
||||
x86_64-linux = {
|
||||
profilesTest = mkTest {
|
||||
name = "profiles";
|
||||
|
||||
|
@ -99,5 +98,5 @@ in
|
|||
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue