mirror of
https://git.madhouse-project.org/actions/nix.git
synced 2024-11-23 20:19:16 +01:00
Add a nix/build action
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
parent
c7e4d24cd2
commit
680f954a87
5 changed files with 116 additions and 0 deletions
36
.forgejo/workflows/nix-build.yaml
Normal file
36
.forgejo/workflows/nix-build.yaml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
name: test nix/build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
nix/build:
|
||||||
|
runs-on: nixos-flakes
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: build the local test package
|
||||||
|
id: build-local
|
||||||
|
uses: ./build
|
||||||
|
with:
|
||||||
|
flake: ./build/test
|
||||||
|
package: "hello"
|
||||||
|
logs: true
|
||||||
|
|
||||||
|
- name: print the output path
|
||||||
|
run: |
|
||||||
|
echo ${{ steps.build-local.outputs.output-path }}
|
||||||
|
|
||||||
|
- name: build a package from nixpkgs
|
||||||
|
id: build-nixpkgs
|
||||||
|
uses: ./build
|
||||||
|
with:
|
||||||
|
flake: nixpkgs
|
||||||
|
package: "hello"
|
||||||
|
logs: true
|
||||||
|
|
||||||
|
- name: print the output path
|
||||||
|
run: |
|
||||||
|
echo ${{ steps.build-nixpkgs.outputs.output-path }}
|
30
build/action.yml
Normal file
30
build/action.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
name: nix-build
|
||||||
|
author: Gergely Nagy
|
||||||
|
description: "Build packages with Nix"
|
||||||
|
inputs:
|
||||||
|
flake:
|
||||||
|
description: "The flake to build packages from"
|
||||||
|
default: "."
|
||||||
|
required: true
|
||||||
|
package:
|
||||||
|
description: "The package to build from a flake"
|
||||||
|
required: false
|
||||||
|
logs:
|
||||||
|
description: "Enable showing the full build logs"
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
outputs:
|
||||||
|
output-path:
|
||||||
|
description: "The resulting output paths"
|
||||||
|
value: "${{ steps.nix-build.outputs.output-path }}"
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- id: nix-build
|
||||||
|
shell: bash
|
||||||
|
run: $GITHUB_ACTION_PATH/bin/nix-build
|
||||||
|
env:
|
||||||
|
INPUT_FLAKE: ${{ inputs.flake }}
|
||||||
|
INPUT_PACKAGE: ${{ inputs.package }}
|
||||||
|
INPUT_LOGS: ${{ inputs.logs }}
|
12
build/bin/nix-build
Executable file
12
build/bin/nix-build
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
LOGS=""
|
||||||
|
case "${INPUT_LOGS}" in
|
||||||
|
[yY][eE][sS]|[tT][rR][uU][eE]|[oO][nN]|1)
|
||||||
|
LOGS=-L
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
nix build ${LOGS} "${INPUT_FLAKE}#${INPUT_PACKAGE}"
|
||||||
|
echo "output-path=$(readlink result)" >>"${GITHUB_OUTPUT}"
|
27
build/test/flake.lock
Normal file
27
build/test/flake.lock
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1685566663,
|
||||||
|
"narHash": "sha256-btHN1czJ6rzteeCuE/PNrdssqYD2nIA4w48miQAFloM=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "4ecab3273592f27479a583fb6d975d4aba3486fe",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "23.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
11
build/test/flake.nix
Normal file
11
build/test/flake.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/23.05";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
in {
|
||||||
|
packages.x86_64-linux.hello = pkgs.hello;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue