restructure flake so that nixosConfigurations mostly just references the other flake outputs

This commit is contained in:
2023-01-11 08:45:41 +00:00
parent 942e302afb
commit 9588108fd5
3 changed files with 97 additions and 73 deletions

4
flake.lock generated
View File

@@ -123,7 +123,7 @@
"nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable": "nixpkgs-stable",
"nixpkgs-unpatched": "nixpkgs-unpatched", "nixpkgs-unpatched": "nixpkgs-unpatched",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"uninsane": "uninsane" "uninsane-dot-org": "uninsane-dot-org"
} }
}, },
"sops-nix": { "sops-nix": {
@@ -147,7 +147,7 @@
"type": "github" "type": "github"
} }
}, },
"uninsane": { "uninsane-dot-org": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [

View File

@@ -22,7 +22,7 @@
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
uninsane = { uninsane-dot-org = {
url = "git+https://git.uninsane.org/colin/uninsane"; url = "git+https://git.uninsane.org/colin/uninsane";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
@@ -36,7 +36,7 @@
mobile-nixos, mobile-nixos,
home-manager, home-manager,
sops-nix, sops-nix,
uninsane uninsane-dot-org
}: }:
let let
nixpkgsCompiledBy = local: nixpkgs.legacyPackages."${local}"; nixpkgsCompiledBy = local: nixpkgs.legacyPackages."${local}";
@@ -53,14 +53,13 @@
# cross compilation only happens on explicit access to `pkgs.cross` # cross compilation only happens on explicit access to `pkgs.cross`
system = target; system = target;
modules = [ modules = [
./modules self.nixosModules.default
self.nixosModules.passthru
(import ./hosts/instantiate.nix name) (import ./hosts/instantiate.nix name)
home-manager.nixosModule
sops-nix.nixosModules.sops
{ {
nixpkgs.overlays = [ nixpkgs.overlays = [
(import "${mobile-nixos}/overlay/overlay.nix") self.overlays.default
uninsane.overlay self.overlays.passthru
(next: prev: { (next: prev: {
# for local != target we by default just emulate the target while building. # for local != target we by default just emulate the target while building.
# provide a `pkgs.cross.<pkg>` alias that consumers can use instead of `pkgs.<foo>` # provide a `pkgs.cross.<pkg>` alias that consumers can use instead of `pkgs.<foo>`
@@ -68,7 +67,7 @@
# this is most beneficial for large packages with few pre-requisites -- like Linux. # this is most beneficial for large packages with few pre-requisites -- like Linux.
cross = next.crossFrom."${local}"; cross = next.crossFrom."${local}";
}) })
] ++ (builtins.attrValues self.overlays); ];
} }
]; ];
}); });
@@ -107,10 +106,11 @@
imgs = builtins.mapAttrs (name: value: value.img) hosts; imgs = builtins.mapAttrs (name: value: value.img) hosts;
overlays = rec { overlays = rec {
pkgs = (import ./pkgs/overlay.nix); default = pkgs;
stable = (next: prev: { pkgs = import ./pkgs/overlay.nix;
passthru = next: prev:
let
stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform}"; stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform}";
});
cross = (next: prev: { cross = (next: prev: {
# non-emulated packages build *from* local *for* target. # non-emulated packages build *from* local *for* target.
# for large packages like the linux kernel which are expensive to build under emulation, # for large packages like the linux kernel which are expensive to build under emulation,
@@ -118,15 +118,35 @@
crossFrom."x86_64-linux" = (prev.forceSystem "x86_64-linux" null).appendOverlays next.overlays; crossFrom."x86_64-linux" = (prev.forceSystem "x86_64-linux" null).appendOverlays next.overlays;
crossFrom."aarch64-linux" = (prev.forceSystem "aarch64-linux" null).appendOverlays next.overlays; crossFrom."aarch64-linux" = (prev.forceSystem "aarch64-linux" null).appendOverlays next.overlays;
}); });
mobile = (import "${mobile-nixos}/overlay/overlay.nix");
uninsane = uninsane-dot-org.overlay;
in
uninsane next (mobile next (cross next (stable next prev)));
};
nixosModules = rec {
default = sane;
sane = import ./modules;
passthru = { ... }: {
imports = [
home-manager.nixosModule
sops-nix.nixosModules.sops
];
};
}; };
packages = packages =
let let
allPkgsFor = sys: allPkgsFor = sys:
let pkgs = nixpkgsCompiledBy sys; in { let
nixpkgs = pkgs; pkgsBase = nixpkgsCompiledBy sys;
uninsane = uninsane.packages."${sys}"; pkgsFull = pkgsBase.appendOverlays [
} // (self.overlays.pkgs pkgs pkgs); self.overlays.passthru self.overlays.pkgs
];
in pkgsFull.sane // {
inherit (pkgsFull) sane uninsane-dot-org;
nixpkgs = pkgsBase;
};
in { in {
x86_64-linux = allPkgsFor "x86_64-linux"; x86_64-linux = allPkgsFor "x86_64-linux";
aarch64-linux = allPkgsFor "aarch64-linux"; aarch64-linux = allPkgsFor "aarch64-linux";

View File

@@ -1,4 +1,6 @@
(next: prev: rec { (next: prev:
let
sane = rec {
#### my own, non-upstreamable packages: #### my own, non-upstreamable packages:
sane-scripts = prev.callPackage ./sane-scripts { }; sane-scripts = prev.callPackage ./sane-scripts { };
feeds = prev.callPackage ./feeds { }; feeds = prev.callPackage ./feeds { };
@@ -52,5 +54,7 @@
splatmoji = prev.callPackage ./splatmoji { }; splatmoji = prev.callPackage ./splatmoji { };
# trust-dns = prev.callPackage ./trust-dns { }; # trust-dns = prev.callPackage ./trust-dns { };
# kaiteki = prev.kaiteki; # kaiteki = prev.kaiteki;
}) };
in sane // { inherit sane; }
)