From 908991eb6831548d4b0bbd629b55279ed8abccfd Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Mon, 25 Sep 2023 22:54:26 +0200 Subject: [PATCH] CI: Run a nix task --- .forgejo/workflows/ci.yaml | 7 +++++-- .gitignore | 1 + flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ hello.c | 4 ++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hello.c diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 09393c1..73ca77e 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -1,10 +1,13 @@ on: push jobs: Publish: - runs-on: docker + runs-on: flakes-action steps: - uses: actions/checkout@v3 name: Checkout - name: Build run: | - echo "Hello World!" + nix build + - name: Run + run: | + ./result/bin/hello diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cd791b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9b3e0c5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1695673361, + "narHash": "sha256-Y8TzvhN7zBKooJrIQ0FjKZSZ0iuistIURCx89C4DPXE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0fbc32585c7617c1fb7b7acbb1db9f13d54c3d04", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d6d3de6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "A flake for building Hello World"; + + inputs.nixpkgs.url = github:NixOS/nixpkgs; + + outputs = { self, nixpkgs }: { + defaultPackage.x86_64-linux = + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation { + name = "hello"; + src = self; + buildPhase = "cc -o hello ./hello.c"; + installPhase = "mkdir -p $out/bin; install -t $out/bin hello"; + }; + defaultPackage.aarch64-darwin = + with import nixpkgs { system = "aarch64-darwin"; }; + stdenv.mkDerivation { + name = "hello"; + src = self; + buildPhase = "cc -o hello ./hello.c"; + installPhase = "mkdir -p $out/bin; install -t $out/bin hello"; + }; + }; +} diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..36d5f14 --- /dev/null +++ b/hello.c @@ -0,0 +1,4 @@ +int main(void) { + printf("Hello World\n"); + return 0; +}