# https://github.com/thiagokokada/nix-configs
name: build-home-manager-and-cache
on:
  push:
  pull_request:
  workflow_dispatch:
jobs:
  build-linux:
    runs-on: ubuntu-latest
    steps:
      - uses: easimon/maximize-build-space@v7
        with:
          overprovision-lvm: true
          remove-android: true
          remove-codeql: true
          remove-docker-images: true
          remove-dotnet: true
          remove-haskell: true
          root-reserve-mb: 512
          swap-size-mb: 1024
      - uses: actions/checkout@v3
      - uses: DeterminateSystems/nix-installer-action@v4
        with:
          github-token: ${{ secrets.GH_TOKEN }}
          extra-conf: |
            auto-optimise-store = true
            experimental-features = nix-command flakes
            substituters = https://cache.nixos.org?priority=7 https://cache.garnix.io?priority=6 https://nix-community.cachix.org?priority=5 https://ezkea.cachix.org https://nixpkgs-wayland.cachix.org https://ludovico-home-manager.cachix.org https://cache.nixos.org/
            trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA= ludovico-home-manager.cachix.org-1:0C6ekMczzOf71RZpFtdxgE1sbALZaAqHclFavdwPZUU=
            trusted-users = root runner
      - uses: DeterminateSystems/magic-nix-cache-action@main
      - uses: cachix/cachix-action@v12
        with:
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          name: ludovico-home-manager
      - name: Set default git branch (to reduce log spam)
        run: git config --global init.defaultBranch master
      - name: Validate Flakes
        run: nix flake check
      - name: 'Build Home-Manager configs for: ludovico'
        run: |-
          nix build --print-build-logs '.#homeConfigurations.ludovico.activationPackage'
