name: 'Build NixOS WSL tarball' on: [push, pull_request, release] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: # Nix Flakes doesn't work on shallow clones fetch-depth: 0 - name: Install nix uses: cachix/install-nix-action@v12 with: install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install # Configure Nix to enable flakes extra_nix_config: | experimental-features = nix-command flakes - name: Run checks run: | nix flake check - name: Build tarball run: | nix build '.#nixosConfigurations.mysystem.config.system.build.tarball' - name: Upload tarball uses: actions/upload-artifact@v2 with: name: rootfs path: result/tarball/nixos-wsl-x86_64-linux.tar.gz - name: Build installer run: | nix build '.#nixosConfigurations.mysystem.config.system.build.installer' - name: Upload installer uses: actions/upload-artifact@v2 with: name: installer path: result/tarball/nixos-wsl-installer.tar.gz release: if: startsWith(github.ref, 'refs/tags/') needs: build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - uses: actions/download-artifact@v2 with: name: rootfs - uses: actions/download-artifact@v2 with: name: installer - name: Generate checksums run: | for x in *.tar.gz; do sha256sum $x > ${x}.sha256 done - name: Attach to release uses: softprops/action-gh-release@v1 with: files: | nixos-wsl-x86_64-linux.tar.gz nixos-wsl-x86_64-linux.tar.gz.sha256 nixos-wsl-installer.tar.gz nixos-wsl-installer.tar.gz.sha256 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}