nixos-t2-iso: init

This commit is contained in:
kekrby 2022-08-25 18:45:47 +03:00
commit 18b206807a
6 changed files with 146 additions and 0 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 kekrby
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9
README.md Normal file
View file

@ -0,0 +1,9 @@
## NixOS Iso for T2 Macs
You can use this flake to build a NixOS iso that can be used with T2 Macs.
This repo provides two isos:
* `t2-iso-minimal`
* `t2-iso-gnome`
It is reccommended to use `t2-iso-minimal` for installing NixOS. `t2-iso-gnome` can be used to preview what the system will look after the installation.

43
flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"nixos-hardware": {
"locked": {
"lastModified": 1661440621,
"narHash": "sha256-BcokGMf6v8sj42jU7/dSLb5iwwkcqG4guRhBihKqpxc=",
"owner": "kekrby",
"repo": "nixos-hardware",
"rev": "761380586df33b1d2f31c56784c1ce9aff767afe",
"type": "github"
},
"original": {
"owner": "kekrby",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1661239211,
"narHash": "sha256-pNJzBlSNpWEiFJZnLF2oETYq8cGWx1DJPW33aMtG6n8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e804cd8a27f835a402b22e086e36e797716ef8b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

27
flake.nix Normal file
View file

@ -0,0 +1,27 @@
{
description = "A flake for NixOS iso's that work on T2 Macs";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:kekrby/nixos-hardware";
};
outputs = { self, nixpkgs, nixos-hardware }:
let
system = "x86_64-linux";
inherit (nixpkgs) lib;
mergeMap = fn: list: lib.lists.foldr (a: b: a // b) {} (map fn list);
in
mergeMap (config: {
${lib.strings.removeSuffix ".nix" (builtins.baseNameOf config)} = (lib.nixosSystem {
inherit system;
modules = [ config ];
specialArgs = {
inherit nixos-hardware;
};
}).config.system.build.isoImage;
}) (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (key: value: if value == "regular" then ./nix/${key} else null) (builtins.readDir ./nix)));
}

25
nix/t2-iso-gnome.nix Normal file
View file

@ -0,0 +1,25 @@
{ pkgs, lib, nixos-hardware, modulesPath, ... }:
{
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-graphical-gnome.nix"
"${modulesPath}/installer/cd-dvd/channel.nix"
nixos-hardware.nixosModules.apple-t2
];
# Audio works better with PipeWire
hardware.pulseaudio.enable = lib.mkForce false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
pulse.enable = true;
alsa.enable = true;
};
# ZFS is broken and prevents building without this
nixpkgs.config.allowBroken = true;
environment.systemPackages = with pkgs; [
vim
];
}

21
nix/t2-iso-minimal.nix Normal file
View file

@ -0,0 +1,21 @@
{ pkgs, nixos-hardware, modulesPath, ... }:
{
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
"${modulesPath}/installer/cd-dvd/channel.nix"
nixos-hardware.nixosModules.apple-t2
];
# ZFS is broken and prevents building without this
nixpkgs.config.allowBroken = true;
# NetworkManager is preferred because wpa_supplicant does not work well (though wpa_cli seems to work fine for some reason)
# wpa_supplicant is enabled by a module imported by the installation CD module so it is turned off so that it does not conflict with NetworkManager
networking.networkmanager.enable = true;
networking.wireless.enable = false;
environment.systemPackages = with pkgs; [
vim
];
}