mirror of
https://git.madhouse-project.org/actions/nix.git
synced 2024-11-23 20:19:16 +01:00
Add a nix/develop action
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
parent
680f954a87
commit
3935dfdac3
5 changed files with 106 additions and 0 deletions
32
.forgejo/workflows/nix-develop.yaml
Normal file
32
.forgejo/workflows/nix-develop.yaml
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
name: test nix/develop
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
nix/develop:
|
||||
runs-on: nixos-flakes
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: run a command within a dev environment
|
||||
uses: ./develop
|
||||
with:
|
||||
flake: ./develop/test
|
||||
package: "hello"
|
||||
run: |
|
||||
hello
|
||||
|
||||
- name: run multiple commands within a dev environment
|
||||
uses: ./develop
|
||||
with:
|
||||
flake: ./develop/test
|
||||
package: "hello"
|
||||
run: |
|
||||
gcc --version
|
||||
hello
|
||||
if [ -n "${CI}" ]; then
|
||||
echo "I'm running in CI!"
|
||||
fi
|
25
develop/action.yml
Normal file
25
develop/action.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
name: nix-develop
|
||||
author: Gergely Nagy
|
||||
description: "Run commands within a Nix development environment"
|
||||
inputs:
|
||||
flake:
|
||||
description: "The flake to use for the development environment"
|
||||
default: "."
|
||||
required: true
|
||||
package:
|
||||
description: "The package to use for the development environment"
|
||||
required: false
|
||||
run:
|
||||
description: "Commands to run within the development environment"
|
||||
required: true
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- id: nix-develop
|
||||
shell: bash
|
||||
run: $GITHUB_ACTION_PATH/bin/nix-develop
|
||||
env:
|
||||
INPUT_FLAKE: ${{ inputs.flake }}
|
||||
INPUT_PACKAGE: ${{ inputs.package }}
|
||||
INPUT_RUN: ${{ inputs.run }}
|
8
develop/bin/nix-develop
Executable file
8
develop/bin/nix-develop
Executable file
|
@ -0,0 +1,8 @@
|
|||
#! /usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$workdir"' EXIT
|
||||
echo "${INPUT_RUN}" >"${workdir}/run.sh"
|
||||
|
||||
nix develop "${INPUT_FLAKE}#${INPUT_PACKAGE}" -c bash "${workdir}/run.sh"
|
27
develop/test/flake.lock
Normal file
27
develop/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
|
||||
}
|
14
develop/test/flake.nix
Normal file
14
develop/test/flake.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
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;
|
||||
devShells.x86_64-linux.hello = pkgs.mkShell {
|
||||
buildInputs = [ self.packages.x86_64-linux.hello ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue