flake: make separate cross
and emulated
package sets (so i can build non-cross systems again)
This commit is contained in:
67
flake.nix
67
flake.nix
@@ -56,6 +56,11 @@
|
|||||||
...
|
...
|
||||||
}@inputs:
|
}@inputs:
|
||||||
let
|
let
|
||||||
|
inherit (builtins) attrNames listToAttrs map mapAttrs;
|
||||||
|
mapAttrs' = f: set:
|
||||||
|
listToAttrs (map (attr: f attr set.${attr}) (attrNames set));
|
||||||
|
# mapAttrs but without the `name` argument
|
||||||
|
mapAttrValues = f: mapAttrs (_: f);
|
||||||
# rather than apply our nixpkgs patches as a flake input, do that here instead.
|
# rather than apply our nixpkgs patches as a flake input, do that here instead.
|
||||||
# this (temporarily?) resolves the bad UX wherein a subflake residing in the same git
|
# this (temporarily?) resolves the bad UX wherein a subflake residing in the same git
|
||||||
# repo as the main flake causes the main flake to have an unstable hash.
|
# repo as the main flake causes the main flake to have an unstable hash.
|
||||||
@@ -76,11 +81,6 @@
|
|||||||
nixosSystem = import ((nixpkgsCompiledBy target).path + "/nixos/lib/eval-config.nix");
|
nixosSystem = import ((nixpkgsCompiledBy target).path + "/nixos/lib/eval-config.nix");
|
||||||
in
|
in
|
||||||
(nixosSystem {
|
(nixosSystem {
|
||||||
# we use pkgs built for and *by* the target, i.e. emulation, by default.
|
|
||||||
# cross compilation only happens on explicit access to `pkgs.cross`
|
|
||||||
# system = target;
|
|
||||||
# localSystem = local;
|
|
||||||
# crossSystem = target;
|
|
||||||
modules = [
|
modules = [
|
||||||
(import ./hosts/instantiate.nix { localSystem = local; hostName = name; })
|
(import ./hosts/instantiate.nix { localSystem = local; hostName = name; })
|
||||||
self.nixosModules.default
|
self.nixosModules.default
|
||||||
@@ -91,25 +91,45 @@
|
|||||||
self.overlays.passthru
|
self.overlays.passthru
|
||||||
self.overlays.pins
|
self.overlays.pins
|
||||||
];
|
];
|
||||||
# nixpkgs.crossSystem = target;
|
|
||||||
nixpkgs.hostPlatform = target;
|
nixpkgs.hostPlatform = target;
|
||||||
nixpkgs.buildPlatform = local;
|
# nixpkgs.buildPlatform = local; # set by instantiate.nix instead
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
nixosConfigurations = {
|
nixosConfigurations =
|
||||||
servo = evalHost { name = "servo"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
let
|
||||||
desko = evalHost { name = "desko"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
hosts = {
|
||||||
lappy = evalHost { name = "lappy"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
servo = { name = "servo"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
||||||
moby = evalHost { name = "moby"; local = "aarch64-linux"; target = "aarch64-linux"; };
|
desko = { name = "desko"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
||||||
# special cross-compiled variant, to speed up deploys from an x86 box to the arm target
|
lappy = { name = "lappy"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
||||||
# note that these *do* produce different store paths, because the closure for the tools used to cross compile
|
moby = { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; };
|
||||||
# v.s. emulate differ.
|
rescue = { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
||||||
# so deploying foo-cross and then foo incurs some rebuilding.
|
};
|
||||||
moby-cross = evalHost { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; };
|
# cross-compiled builds: instead of emulating the host, build using a cross-compiler.
|
||||||
rescue = evalHost { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
# - these are faster to *build* than the emulated variants (useful when tweaking packages),
|
||||||
};
|
# - but fewer of their packages can be found in upstream caches.
|
||||||
|
cross = mapAttrValues evalHost hosts;
|
||||||
|
emulated = mapAttrValues
|
||||||
|
({name, local, target}: evalHost {
|
||||||
|
inherit name target;
|
||||||
|
local = null;
|
||||||
|
})
|
||||||
|
hosts;
|
||||||
|
prefixAttrs = prefix: attrs: mapAttrs'
|
||||||
|
(name: value: {
|
||||||
|
name = prefix + name;
|
||||||
|
inherit value;
|
||||||
|
})
|
||||||
|
attrs;
|
||||||
|
in
|
||||||
|
(prefixAttrs "cross-" cross) //
|
||||||
|
(prefixAttrs "emulated-" emulated) // {
|
||||||
|
# prefer native builds for these machines:
|
||||||
|
inherit (emulated) servo desko lappy rescue;
|
||||||
|
# prefer cross-compiled builds for these machines:
|
||||||
|
inherit (cross) moby;
|
||||||
|
};
|
||||||
|
|
||||||
# unofficial output
|
# unofficial output
|
||||||
# this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition).
|
# this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition).
|
||||||
@@ -125,9 +145,10 @@
|
|||||||
# - if fs wasn't resized automatically, then `sudo btrfs filesystem resize max /`
|
# - if fs wasn't resized automatically, then `sudo btrfs filesystem resize max /`
|
||||||
# - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS.
|
# - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS.
|
||||||
# - `nixos-rebuild --flake './#<host>' switch`
|
# - `nixos-rebuild --flake './#<host>' switch`
|
||||||
imgs = builtins.mapAttrs (_: host-dfn: host-dfn.config.system.build.img) self.nixosConfigurations;
|
imgs = mapAttrValues (host: host.config.system.build.img) self.nixosConfigurations;
|
||||||
|
|
||||||
host-pkgs = builtins.mapAttrs (_: host-dfn: host-dfn.config.system.build.pkgs) self.nixosConfigurations;
|
# unofficial output
|
||||||
|
host-pkgs = mapAttrValues (host: host.config.system.build.pkgs) self.nixosConfigurations;
|
||||||
|
|
||||||
overlays = rec {
|
overlays = rec {
|
||||||
default = pkgs;
|
default = pkgs;
|
||||||
@@ -170,8 +191,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# extract only our own packages from the full set
|
# extract only our own packages from the full set
|
||||||
packages = builtins.mapAttrs
|
packages = mapAttrValues
|
||||||
(_: full: full.sane // { inherit (full) sane uninsane-dot-org; })
|
(full: full.sane // { inherit (full) sane uninsane-dot-org; })
|
||||||
self.legacyPackages;
|
self.legacyPackages;
|
||||||
|
|
||||||
apps."x86_64-linux" =
|
apps."x86_64-linux" =
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
{ hostName, localSystem }:
|
{ hostName, localSystem }:
|
||||||
|
|
||||||
# module args
|
# module args
|
||||||
{ config, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = hostName;
|
networking.hostName = hostName;
|
||||||
|
nixpkgs.buildPlatform = lib.mkIf (localSystem != null) localSystem;
|
||||||
|
|
||||||
# nixpkgs.overlays = [
|
# nixpkgs.overlays = [
|
||||||
# (next: prev: {
|
# (next: prev: {
|
||||||
|
Reference in New Issue
Block a user