flake: refactor packages to fit expectations

This commit is contained in:
Cassie Cheung 2025-02-07 11:48:15 +08:00
parent a71dc85e76
commit 81f28602aa
No known key found for this signature in database
4 changed files with 52 additions and 31 deletions

View file

@ -47,8 +47,8 @@ jobs:
env: env:
GC_DONT_GC: 1 GC_DONT_GC: 1
run: | run: |
for output in $(nix flake show --json | nix run nixpkgs#jq -- -r 'keys[]'); do for output in $(nix flake show --json | nix run nixpkgs#jq -- -r '.packages."x86_64-linux" | keys[]'); do
nix build .#$output --accept-flake-config nix build .#packages.x86_64-linux.${output} --accept-flake-config
if [ $(du -B1M result/iso/*.iso | cut -f1) -gt 2000 ]; then if [ $(du -B1M result/iso/*.iso | cut -f1) -gt 2000 ]; then
split -d result/iso/*.iso -b 2000M nixos-$output.iso.part- split -d result/iso/*.iso -b 2000M nixos-$output.iso.part-
else else

View file

@ -12,22 +12,29 @@
extra-trusted-public-keys = [ "cache.soopy.moe-1:0RZVsQeR+GOh0VQI9rvnHz55nVXkFardDqfm4+afjPo=" ]; extra-trusted-public-keys = [ "cache.soopy.moe-1:0RZVsQeR+GOh0VQI9rvnHz55nVXkFardDqfm4+afjPo=" ];
}; };
outputs = { self, nixpkgs, nixos-hardware }: outputs =
{
self,
nixpkgs,
nixos-hardware,
}:
let let
system = "x86_64-linux";
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
mergeMap = fn: list: lib.lists.foldr (a: b: a // b) {} (map fn list); system = "x86_64-linux";
isos = [
"gnome"
"minimal"
];
in in
mergeMap (config: { {
${lib.strings.removeSuffix ".nix" (builtins.baseNameOf config)} = (lib.nixosSystem { formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
inherit system; packages.${system} = lib.genAttrs isos (
iso:
modules = [ config ]; (lib.nixosSystem {
modules = [ (self + "/nix/t2-iso-${iso}.nix") ];
specialArgs = { specialArgs = { inherit nixos-hardware; };
inherit nixos-hardware; }).config.system.build.isoImage
);
}; };
}).config.system.build.isoImage;
}) (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (key: value: if value == "regular" && lib.strings.hasInfix "iso" key then ./nix/${key} else null) (builtins.readDir ./nix)));
} }

View file

@ -1,4 +1,9 @@
{ pkgs, modulesPath, nixos-hardware, ... }: {
pkgs,
modulesPath,
nixos-hardware,
...
}:
{ {
imports = [ imports = [
@ -14,16 +19,20 @@
"t2linux.cachix.org-1:P733c5Gt1qTcxsm+Bae0renWnT8OLs0u9+yfaK2Bejw=" "t2linux.cachix.org-1:P733c5Gt1qTcxsm+Bae0renWnT8OLs0u9+yfaK2Bejw="
]; ];
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git git
python3 python3
dmg2img dmg2img
(pkgs.callPackage ./pkgs/firmware-script.nix {}) (pkgs.callPackage ./pkgs/firmware-script.nix { })
]; ];
# ZFS is (sometimes) broken and prevents building without this # ZFS is (sometimes) broken and prevents building without this
nixpkgs.config.allowBroken = true; nixpkgs.config.allowBroken = true;
nixpkgs.hostPlatform = "x86_64-linux"; # t2 is x86_64-linux only
} }

View file

@ -1,4 +1,9 @@
{ stdenvNoCC, fetchurl, lib }: stdenvNoCC.mkDerivation (final: { {
stdenvNoCC,
fetchurl,
lib,
}:
stdenvNoCC.mkDerivation (final: {
pname = "get-apple-firmware"; pname = "get-apple-firmware";
version = "fe8c338e6cf1238a390984ba06544833ab8792d3"; version = "fe8c338e6cf1238a390984ba06544833ab8792d3";
src = fetchurl { src = fetchurl {