From fd8e80f8822b5c72d9dd49c76a4573000601e703 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 27 May 2026 10:50:31 +0300 Subject: [PATCH 1/5] feat: add Nix flake for package distribution --- flake.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d3a3fba --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "Lightweight, headless implementation of the KDE Connect protocol in Go"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages.default = pkgs.buildGoModule { + pname = "kcd"; + version = self.shortRev or "dirty"; + + src = ./.; + + vendorHash = ""; # Go's go.sum handles integrity + + subPackages = [ "cmd/kcd" ]; + + CGO_ENABLED = 0; + + ldflags = [ + "-s" "-w" + "-X main.version=${self.shortRev or "dirty"}" + ]; + + meta = with pkgs.lib; { + description = "Headless KDE Connect daemon written in Go"; + homepage = "https://github.com/bethropolis/kcd"; + license = licenses.mit; + maintainers = [ ]; + platforms = platforms.linux; + }; + }; + + apps.default = flake-utils.lib.mkApp { + drv = self.packages.${system}.default; + }; + } + ); +} From 7f84aec08bb88ac2891a400a8fe8f6c7aa5c8ee6 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 27 May 2026 11:37:20 +0300 Subject: [PATCH 2/5] ci: add Nix flake verification workflow for PRs --- .github/workflows/nix-verify.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/nix-verify.yml diff --git a/.github/workflows/nix-verify.yml b/.github/workflows/nix-verify.yml new file mode 100644 index 0000000..e474933 --- /dev/null +++ b/.github/workflows/nix-verify.yml @@ -0,0 +1,29 @@ +name: Nix Flake Verify + +on: + pull_request: + branches: [ "main" ] + paths: + - 'flake.nix' + - 'flake.lock' + +jobs: + nix-verify: + name: Build & Check Flake + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Nix + uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Flake schema check + run: nix flake check --no-build + + - name: Build package + run: nix build From 7162359d2204c94af4712c7e84c0462889f77dd5 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 27 May 2026 11:46:55 +0300 Subject: [PATCH 3/5] fix: use env.CGO_ENABLED to avoid nixpkgs assertion --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d3a3fba..4192f47 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ subPackages = [ "cmd/kcd" ]; - CGO_ENABLED = 0; + env.CGO_ENABLED = "0"; ldflags = [ "-s" "-w" From 0f776abad0319a50e995ae03d4cdedba6cd3d011 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 27 May 2026 12:02:13 +0300 Subject: [PATCH 4/5] fix: set vendorHash to actual Go module hash --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4192f47..ab1e40e 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,8 @@ src = ./.; - vendorHash = ""; # Go's go.sum handles integrity + # Update when go.sum changes: nix build 2>&1 | grep 'got:' | awk '{print $2}' + vendorHash = "sha256-rnI60JzB8vtFC4iIVoHGi9um7f0mV7jbIJTNVu8ytVY="; subPackages = [ "cmd/kcd" ]; From 199d3f88bcea248edcf2a0e3321283b656b11d79 Mon Sep 17 00:00:00 2001 From: bethropolis <66518866+bethropolis@users.noreply.github.com> Date: Wed, 27 May 2026 12:11:26 +0300 Subject: [PATCH 5/5] ci: merge Nix flake verification into release workflow --- .github/workflows/nix-verify.yml | 29 ----------------------------- .github/workflows/release.yml | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/nix-verify.yml diff --git a/.github/workflows/nix-verify.yml b/.github/workflows/nix-verify.yml deleted file mode 100644 index e474933..0000000 --- a/.github/workflows/nix-verify.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Nix Flake Verify - -on: - pull_request: - branches: [ "main" ] - paths: - - 'flake.nix' - - 'flake.lock' - -jobs: - nix-verify: - name: Build & Check Flake - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Nix - uses: cachix/install-nix-action@v31 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Flake schema check - run: nix flake check --no-build - - - name: Build package - run: nix build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b690b9..673faaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,6 +50,20 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Install Nix + if: hashFiles('flake.nix') != '' + uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Flake schema check + if: hashFiles('flake.nix') != '' + run: nix flake check --no-build + + - name: Nix build package + if: hashFiles('flake.nix') != '' + run: nix build + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: