Skip to content

Commit

Permalink
actions: add separate validate flakes step
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Sep 20, 2023
1 parent 64b1f0b commit 7ce34c4
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-and-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
Expand All @@ -24,8 +25,6 @@ jobs:
name: thiagokokada-nix-configs
- name: Set default git branch (to reduce log spam)
run: git config --global init.defaultBranch master
- name: Check if all `.nix` files are formatted correctly
run: nix run '.#formatCheck'
- name: 'Build Home-Manager configs for: home-linux, steamdeck'
run: |-
nix build --print-build-logs '.#homeConfigurations.home-linux.activationPackage'
Expand All @@ -42,7 +41,8 @@ jobs:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update-flakes-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ jobs:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update-flakes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixos-unstable
- name: Set default git branch (to reduce log spam)
run: git config --global init.defaultBranch master
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/validate-flakes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
extra-platforms = aarch64-linux
nix_path: nixpkgs=channel:nixos-unstable
- name: Setup aarch64-linux
run: |
DEBIAN_FRONTEND=noninteractive
sudo apt-get update -q -y
sudo apt-get install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_TOKEN }}
extraPullNames: nix-community
name: thiagokokada-nix-configs
- name: Set default git branch (to reduce log spam)
run: git config --global init.defaultBranch master
- name: Check if all `.nix` files are formatted correctly
run: nix run '.#formatCheck'
- name: Validate Flakes
run: nix flake check
name: validate-flakes
"on":
- push
- workflow_dispatch
6 changes: 2 additions & 4 deletions actions/build-and-cache.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ with constants;
steps = with steps; [
maximimizeBuildSpaceStep
checkoutStep
installNixActionStep
(installNixActionStep { })
cachixActionStep
setDefaultGitBranchStep
checkNixStep
# validateFlakesStep
(buildHomeManagerConfigurations { })
(buildNixOSConfigurations { })
];
Expand All @@ -25,7 +23,7 @@ with constants;
inherit (constants.macos) runs-on;
steps = with steps; [
checkoutStep
installNixActionStep
(installNixActionStep { })
cachixActionStep
setDefaultGitBranchStep
(buildHomeManagerConfigurations { hostnames = home-manager.darwin.hostnames; })
Expand Down
17 changes: 14 additions & 3 deletions actions/steps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ with constants;
checkoutStep = {
uses = actions.checkout;
};
installNixActionStep = {
installNixActionStep = { extraNixConfig ? "" }: {
uses = actions.install-nix-action;
"with" = {
# Need to define a channel, otherwise it wiill use bash from environment
# Need to define a channel, otherwise it will use bash from environment
nix_path = "nixpkgs=channel:nixos-unstable";
# Should avoid GitHub API rate limit
extra_nix_config = "access-tokens = github.com=\${{ secrets.GITHUB_TOKEN }}";
extra_nix_config = builtins.concatStringsSep "\n" [
"access-tokens = github.com=\${{ secrets.GITHUB_TOKEN }}"
extraNixConfig
];
};
};
cachixActionStep = {
Expand Down Expand Up @@ -104,4 +107,12 @@ with constants;
diffIds));
};
};
setupAarch64 = {
name = "Setup aarch64-linux";
run = ''
DEBIAN_FRONTEND=noninteractive
sudo apt-get update -q -y
sudo apt-get install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static
'';
};
}
2 changes: 1 addition & 1 deletion actions/update-flakes-darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with constants;
"if" = "\${{ github.event.workflow_run.conclusion == 'success' }}";
steps = with steps; [
checkoutStep
installNixActionStep
(installNixActionStep { })
cachixActionStep
setDefaultGitBranchStep
(buildHomeManagerConfigurations { hostnames = home-manager.darwin.hostnames; })
Expand Down
2 changes: 1 addition & 1 deletion actions/update-flakes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ with constants;
steps = with steps; [
maximimizeBuildSpaceStep
checkoutStep
installNixActionStep
(installNixActionStep { })
setDefaultGitBranchStep
cachixActionStep
# (buildNixOSConfigurations { hostnames = [ (first nixos.hostnames) ]; extraNixFlags = [ "-o /tmp/nixos_old" ]; })
Expand Down
27 changes: 27 additions & 0 deletions actions/validate-flakes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
let
steps = import ./steps.nix;
constants = import ./constants.nix;
in
with constants;
{
name = "validate-flakes";
on = [ "push" "workflow_dispatch" ];
jobs = {
build-linux = {
inherit (ubuntu) runs-on;
steps = with steps; [
checkoutStep
(installNixActionStep {
extraNixConfig = ''
extra-platforms = aarch64-linux
'';
})
setupAarch64
cachixActionStep
setDefaultGitBranchStep
checkNixStep
validateFlakesStep
];
};
};
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"build-and-cache"
"update-flakes"
"update-flakes-darwin"
"validate-flakes"
])
]); # END recursiveMergeAttrs
}

0 comments on commit 7ce34c4

Please sign in to comment.