From 18b206807a91017d909d9df5950cdebe6a77b0e7 Mon Sep 17 00:00:00 2001 From: kekrby Date: Thu, 25 Aug 2022 18:45:47 +0300 Subject: [PATCH] nixos-t2-iso: init --- LICENSE | 21 +++++++++++++++++++++ README.md | 9 +++++++++ flake.lock | 43 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 27 ++++++++++++++++++++++++++ nix/t2-iso-gnome.nix | 25 ++++++++++++++++++++++++ nix/t2-iso-minimal.nix | 21 +++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/t2-iso-gnome.nix create mode 100644 nix/t2-iso-minimal.nix diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eba1320 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..65b995c --- /dev/null +++ b/README.md @@ -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. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8fefef0 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fdb5882 --- /dev/null +++ b/flake.nix @@ -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))); +} diff --git a/nix/t2-iso-gnome.nix b/nix/t2-iso-gnome.nix new file mode 100644 index 0000000..ace4caa --- /dev/null +++ b/nix/t2-iso-gnome.nix @@ -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 + ]; +} diff --git a/nix/t2-iso-minimal.nix b/nix/t2-iso-minimal.nix new file mode 100644 index 0000000..e4fb91d --- /dev/null +++ b/nix/t2-iso-minimal.nix @@ -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 + ]; +}