introduce a justfile to handle builds
- justfile: init - flake: add devShell with just - direnv: enable devShell - gh-actions: move github actions command from "raw" nix commands to `just` build-* - gh-actions: remove all jobs that are not strictly necessary - gh-actions: remove all dependencies
This commit is contained in:
parent
8099d9adcc
commit
8870fdf8a5
|
@ -16,50 +16,12 @@ on:
|
|||
|
||||
env:
|
||||
NIXPKGS_RISCV_GHC_BOOTSTRAP_ISSUE: https://github.com/nixos/nixpkgs/issues/231537
|
||||
UPDATE_LOCKFILE: 1
|
||||
nix-build-cmd: nix build --print-build-logs --show-trace --max-jobs 1 --cores 0
|
||||
|
||||
jobs:
|
||||
nix-flake-update:
|
||||
build-iso:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: Updating the flake lockfile
|
||||
run: |
|
||||
nix flake update
|
||||
|
||||
cache-build-deps:
|
||||
runs-on: ubuntu-latest
|
||||
needs: nix-flake-update
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_drvs: [ fractal ]
|
||||
linux_arches: [ aarch64, riscv64, x86_64 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
with:
|
||||
extra-conf: "extra-platforms = aarch64-linux riscv64-linux x86_64-linux"
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Caching build for ${{ build_drvs }}
|
||||
run: |
|
||||
if [[ '${{ matrix.linux_arches }}' != 'riscv64' ]]; then
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 ${{ env.nix-build-cmd }} --impure nixpkgs#${{ build_drvs }}
|
||||
else
|
||||
echo "RISC-V job for ${{ github.job }} skipped until $NIXPKGS_RISCV_GHC_BOOTSTRAP_ISSUE is resolved."
|
||||
fi
|
||||
|
||||
|
||||
iso:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ nixos, hm-linux ]
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
@ -74,6 +36,7 @@ jobs:
|
|||
with:
|
||||
extra-conf: "extra-platforms = aarch64-linux riscv64-linux x86_64-linux"
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: taiki-e/install-action@just
|
||||
|
||||
- name: Setting up QEMU
|
||||
run: |
|
||||
|
@ -84,14 +47,13 @@ jobs:
|
|||
- name: Building NixOS ISO for ${{ matrix.linux_arches }}
|
||||
run: |
|
||||
if [[ '${{ matrix.linux_arches }}' != 'riscv64' ]]; then
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 ${{ env.nix-build-cmd }} --impure .#isos.${{ matrix.linux_arches }}
|
||||
just actual-arch=${{ matrix.linux_arches }} build-iso
|
||||
else
|
||||
echo "RISC-V job for ${{ github.job }} skipped until $NIXPKGS_RISCV_GHC_BOOTSTRAP_ISSUE is resolved."
|
||||
fi
|
||||
|
||||
nixos:
|
||||
build-nixos-system:
|
||||
runs-on: ubuntu-latest
|
||||
needs: hm-linux
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
@ -106,6 +68,7 @@ jobs:
|
|||
with:
|
||||
extra-conf: "extra-platforms = aarch64-linux riscv64-linux x86_64-linux"
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: taiki-e/install-action@just
|
||||
|
||||
- name: Setting up QEMU
|
||||
run: |
|
||||
|
@ -116,14 +79,13 @@ jobs:
|
|||
- name: Building NixOS configuration for ${{ matrix.machines }}
|
||||
run: |
|
||||
if [[ "$(nix eval --raw .#nixosConfigurations.${{ matrix.machines }}.pkgs.stdenv.system)" != 'riscv64-linux' ]]; then
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 ${{ env.nix-build-cmd }} --impure .#machines.${{ matrix.machines }}
|
||||
just actual-arch=emulated nixos-machine-hostname=${{ matrix.machines }} build-nixos-system
|
||||
else
|
||||
echo "RISC-V job for ${{ github.job }} skipped until $NIXPKGS_RISCV_GHC_BOOTSTRAP_ISSUE is resolved."
|
||||
fi
|
||||
|
||||
hm-linux:
|
||||
build-home-manager-linux:
|
||||
runs-on: ubuntu-latest
|
||||
needs: cache-build-deps
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
@ -139,6 +101,7 @@ jobs:
|
|||
with:
|
||||
extra-conf: "extra-platforms = aarch64-linux riscv64-linux x86_64-linux"
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: taiki-e/install-action@just
|
||||
|
||||
- name: Setting up QEMU
|
||||
run: |
|
||||
|
@ -149,14 +112,13 @@ jobs:
|
|||
- name: Building home-manager configuration for ${{ matrix.homeOf }}
|
||||
run: |
|
||||
if [[ '${{ matrix.linux_arches }}' != 'riscv64' ]]; then
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 ${{ env.nix-build-cmd }} --impure .#homeOf.${{ matrix.linux_arches }}-linux.${{ matrix.homeOf }}
|
||||
just actual-arch=${{ matrix.linux_arches }} hm-user=${{ matrix.homeOf }} build-home-manager
|
||||
else
|
||||
echo "RISC-V job for ${{ github.job }} skipped until $NIXPKGS_RISCV_GHC_BOOTSTRAP_ISSUE is resolved."
|
||||
fi
|
||||
|
||||
hm-darwin:
|
||||
build-home-manager-darwin:
|
||||
runs-on: macos-latest
|
||||
needs: nix-flake-update
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
@ -169,6 +131,7 @@ jobs:
|
|||
- uses: actions/checkout@main
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: taiki-e/install-action@just
|
||||
|
||||
- name: Building home-manager configuration for ${{ matrix.homeOf }}
|
||||
run: |
|
||||
|
@ -180,4 +143,4 @@ jobs:
|
|||
echo "well well well, look what we have... Darwin on $(uname -m)"
|
||||
exit 1
|
||||
fi
|
||||
${{ env.nix-build-cmd }} .#homeOf."${system_attr}".${{ matrix.homeOf }}
|
||||
just hm-user=${{ matrix.homeOf }} build-home-manager
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -238,5 +238,17 @@
|
|||
homeOf = forEachSupportedSystem ({ pkgs, ... }: {
|
||||
pratham = buildHomeOf pkgs.system "pratham";
|
||||
});
|
||||
|
||||
devShells = forEachSupportedSystem ({ pkgs, ... }: {
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [ just ];
|
||||
|
||||
env = {
|
||||
UPDATE_LOCKFILE = 0;
|
||||
USE_NOM_INSTEAD = 1;
|
||||
DO_DRY_RUN = 1;
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env just --justfile
|
||||
set shell := [ "bash", "-cu"]
|
||||
|
||||
actual-os := if os() == "macos" { "darwin" } else { os() }
|
||||
actual-arch := env_var_or_default("EMULATED_SYSTEM", arch())
|
||||
|
||||
hm-user := env_var_or_default("HM_USER", "pratham")
|
||||
nixos-machine-hostname := env_var_or_default("NIXOS_MACHINE_HOSTNAME", "")
|
||||
|
||||
update-lockfile := env_var_or_default("UPDATE_LOCKFILE", "0")
|
||||
use-nom-instead := env_var_or_default("USE_NOM_INSTEAD", "0")
|
||||
do-dry-run := env_var_or_default("DO_DRY_RUN", "0")
|
||||
building-for-foreign-arch := if actual-arch == arch() { "0" } else { "1" }
|
||||
|
||||
nix-cmd := if use-nom-instead == "1" { "nom" } else { "nix" }
|
||||
common-build-args := " --print-build-logs --show-trace --max-jobs 1 --cores 0"
|
||||
dry-run-args := if do-dry-run == "1" { " --dry-run" } else { "" }
|
||||
foreign-arch-env-var := if building-for-foreign-arch == "0" { "" } else { "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 " }
|
||||
foreign-arch-args := if building-for-foreign-arch == "0" { "" } else { " --impure" }
|
||||
nix-build-cmd := foreign-arch-env-var + nix-cmd + " build" + common-build-args + foreign-arch-args + dry-run-args
|
||||
|
||||
lockfile-update-cmd := if update-lockfile == "0" { "" } else { "nix flake update" }
|
||||
|
||||
[private]
|
||||
default:
|
||||
@just --list --unsorted
|
||||
|
||||
[private]
|
||||
nix-flake-update:
|
||||
{{ lockfile-update-cmd }}
|
||||
|
||||
[unix]
|
||||
build-home-manager: nix-flake-update
|
||||
{{ nix-build-cmd }} .#legacyPackages.{{ actual-arch }}-{{ actual-os }}.homeConfigurations.{{ hm-user }}.activationPackage
|
||||
|
||||
[linux]
|
||||
build-nixos-system: nix-flake-update
|
||||
{{ nix-build-cmd }} .#nixosConfigurations.{{ nixos-machine-hostname }}.config.system.build.toplevel
|
||||
|
||||
[linux]
|
||||
build-iso: nix-flake-update
|
||||
{{ nix-build-cmd }} .#nixosConfigurations.iso-{{ actual-arch }}.config.system.build.isoImage
|
Loading…
Reference in New Issue