From f6ff3579b77ae10f8f1c84fe70d7a14cccdeabe4 Mon Sep 17 00:00:00 2001 From: Arne Weiss Date: Sun, 26 May 2024 16:33:15 +0200 Subject: [PATCH] test nix build --- .gitea/workflows/demo.yaml | 4 ++++ .gitignore | 1 + default.nix | 23 +++++++++++++++++++++++ flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 10 ++++++++++ 5 files changed, 64 insertions(+) create mode 100644 .gitignore create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index e29a7ee..4e4db08 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -5,6 +5,8 @@ on: [push] jobs: Explore-Gitea-Actions: runs-on: ubuntu-latest + container: + image: lnl7/nix:2.3.16 steps: - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" @@ -13,6 +15,8 @@ jobs: uses: actions/checkout@v3 - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: Build with Nix + run: nix build - name: List files in the repository run: | ls ${{ gitea.workspace }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..2610018 --- /dev/null +++ b/default.nix @@ -0,0 +1,23 @@ +{ stdenv, stress-ng, coreutils }: + +stdenv.mkDerivation { + name = "cpu-intensive-task"; + src = ./.; + + buildInputs = [ stress-ng coreutils ]; + + buildPhase = '' + echo "Starting CPU intensive task..." + + # Utilize all CPU cores for 2 minutes + stress-ng --cpu 0 --timeout 120s + + echo "Task completed!" + ''; + + installPhase = '' + mkdir -p $out + echo "Task completed!" > $out/result.txt + ''; +} + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..145f73a --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1716733162, + "narHash": "sha256-nMR45AytYy7pLp4UEM8UAaHwg9yttMfhBKXEGbSUKfc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5997f570487284e8f6cb06a50ebfd33867e81a9f", + "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..bdbc35f --- /dev/null +++ b/flake.nix @@ -0,0 +1,10 @@ +{ + description = "A simple Nix flake to utilize all CPU cores for a few minutes"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + + outputs = { self, nixpkgs }: { + packages.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.callPackage ./default.nix {}; + }; +} +