name: "Build and Cache"
on:
  pull_request:
  push:
jobs:
  sakopc:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: cachix/install-nix-action@v27
      with:
        nix_path: nixpkgs=channel:nixos-unstable
    - uses: DeterminateSystems/magic-nix-cache-action@main
    - uses: cachix/cachix-action@v14
      with:
        name: sako-nixos-cache
        # If you chose signing key for write access
        signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
        # If you chose API tokens for write access OR if you have a private cache
        authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
    # - run: nix run nixpkgs#nixos-rebuild -- --flake .#sakopc build
    - run: nix profile install nixpkgs#nix-fast-build 
    - run: nix-fast-build --skip-cached --no-nom --flake .#nixosConfigurations.sakopc.config.system.build.toplevel
    - run: nix-shell --run "echo All done!"
  sakotop:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: cachix/install-nix-action@v27
      with:
        nix_path: nixpkgs=channel:nixos-unstable
    - uses: DeterminateSystems/magic-nix-cache-action@main
    - uses: cachix/cachix-action@v14
      with:
        name: sako-nixos-cache
        # If you chose signing key for write access
        signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
        # If you chose API tokens for write access OR if you have a private cache
        authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
    # - run: nix run nixpkgs#nixos-rebuild -- --flake .#sakotop build
    # - run: nix run github:Mic92/nix-fast-build -- --no-nom --skip-cached --flake .#nixosConfigurations.sakotop.config.system.build.toplevel
    - run: nix profile install nixpkgs#nix-fast-build 
    - run: nix-fast-build --skip-cached --no-nom --flake .#nixosConfigurations.sakotop.config.system.build.toplevel
    - run: nix-shell --run "echo All done!"
  sakowsl:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: cachix/install-nix-action@v27
      with:
        nix_path: nixpkgs=channel:nixos-unstable
    - uses: DeterminateSystems/magic-nix-cache-action@main
    - uses: cachix/cachix-action@v14
      with:
        name: sako-nixos-cache
        # If you chose signing key for write access
        signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
        # If you chose API tokens for write access OR if you have a private cache
        authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
    # - run: nix run nixpkgs#nixos-rebuild -- --flake .#sakowsl build
    # - run: nix run github:Mic92/nix-fast-build -- --no-nom --skip-cached --flake .#nixosConfigurations.sakowsl.config.system.build.toplevel
    - run: nix profile install nixpkgs#nix-fast-build 
    - run: nix-fast-build --skip-cached --no-nom --flake .#nixosConfigurations.sakowsl.config.system.build.toplevel
    - run: nix-shell --run "echo All done!"