Lite System configuration

Having moved away from Ansible to configuring my macOS environment with nix-darwin and Home Manager, I found myself wanting to DRY up the Flake entrypoint to my many hosts.

What I came across was Lite System from Lite Ye. With it, one can simplify their Nix configuration across Linux and macOS with support for NixOS, nix-darwin, and Home Manager.

In my lite-system-example repository, you’ll find a minimal configuration that builds a working system via GitHub Actions.

I include the emacs-overlay to make building specific versions of Emacs and supporting packages easier, and have an ARM build for local use and an X86 build for GitHub’s macOS runners.

{
  outputs = inputs @ { flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } ({ inputs, ... }: {
      imports = [
        inputs.lite-system.flakeModule
      ];

      config.lite-system = {
        nixpkgs = {
          overlays = [ inputs.emacs-overlay.overlays.emacs ];
        };

        systemModule = ./system;
        homeModule = ./home;
        hostModuleDir = ./host;

        hosts = {
          aarch64-darwin = {
            system = "aarch64-darwin";
          };

          x86-darwin = {
            system = "x86_64-darwin";
          };
        };
      };
    });

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    lite-system.url = "github:yelite/lite-system";

    # https://github.com/lnl7/nix-darwin
    nix-darwin = {
      url = "github:lnl7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # https://github.com/nix-community/home-manager
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # https://github.com/nix-community/emacs-overlay
    emacs-overlay = {
      url = "github:nix-community/emacs-overlay/ead33b53bddac6d9e4e01d1e80e6dc1d8d30d2a3";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

}

With the configuration above, we have a flake output for a Darwin configuration that includes our host configuration, our system configuration, and our home configuration.

In the GitHub workflow, we’re able to build the configuration to verify nothing’s broken.

name: Test

on:
  pull_request:
  push:

jobs:
  darwin:
    runs-on: macos-latest
    steps:

    - uses: actions/checkout@v3

    - uses: cachix/install-nix-action@v22
      with:
        github_access_token: ${{ secrets.GITHUB_TOKEN }}

    - run: nix run nix-darwin -- --show-trace --flake "${PWD}#x86-darwin" build