From 467c760a36684da868c5cf3b52ad420ad62922a3 Mon Sep 17 00:00:00 2001 From: goatastronaut0212 Date: Mon, 9 Sep 2024 22:01:50 +0700 Subject: [PATCH 1/2] Add nix flake for NixOS package and dev shell --- flake.lock | 27 +++++++++++++++++++++ flake.nix | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..66f72d1f --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "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 00000000..7afbcb2e --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + version = "v0.8.4"; + + supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; + + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.stdenv.mkDerivation { + pname = "ibus-bamboo"; + inherit version; + + src = ./.; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.wrapGAppsHook3 + pkgs.go + ]; + + buildInputs = [ + pkgs.xorg.libXtst + ]; + + preConfigure = '' + export GOCACHE="$TMPDIR/go-cache" + sed -i "s,/usr,$out," data/bamboo.xml + ''; + + makeFlags = [ + "PREFIX=${placeholder "out"}" + ]; + }; + } + ); + + devShells = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.wrapGAppsHook3 + pkgs.go + ]; + + buildInputs = [ + pkgs.xorg.libXtst + ]; + }; + } + ); + }; +} From 1429a8a648455a9b6cec3843958d5a3df87f4606 Mon Sep 17 00:00:00 2001 From: goatastronaut0212 Date: Mon, 9 Sep 2024 22:08:26 +0700 Subject: [PATCH 2/2] Add nix flake github pipeline --- .github/workflows/release.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2232d6d4..807439c2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,6 +19,16 @@ jobs: run: | gmake t && gmake build + Build-test-nix-flake: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + - name: Build flake + run: nix build + - name: Use flake devShell + run: nix develop + Releaser: runs-on: ubuntu-latest steps: