Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,84 @@ jobs:
git -C tap add "${TAP_FILE_PATH}"
git -C tap commit -m "chore(formula): rift ${{ steps.pkg.outputs.version }} (universal) - sha256 ${{ steps.pkg.outputs.sha256 }}"
git -C tap push origin HEAD

update-nix:
runs-on: ubuntu-latest
needs: build-and-publish
permissions:
contents: write
outputs:
commit_sha: ${{ steps.commit.outputs.sha }}
no_commit_sha: ${{ steps.no_commit.outputs.sha }}
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install Nix
uses: nixbuild/nix-quick-install-action@v34

- name: Find universal binary release asset
id: find_asset
run: |
ASSETS=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} --jq '.assets[].name')
BINARY=$(echo "$ASSETS" | grep -i "universal" | head -1)
if [ -z "$BINARY" ]; then
echo "No universal binary found in release assets"
exit 1
fi
echo "binary=${BINARY}" >> "$GITHUB_OUTPUT"
echo "Found binary: ${BINARY}"
env:
GH_TOKEN: ${{ github.token }}

- name: Download and calculate hash
id: hash
run: |
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.find_asset.outputs.binary }}"
echo "Downloading from: ${DOWNLOAD_URL}"

HASH=$(nix-prefetch-url --type sha256 --unpack "${DOWNLOAD_URL}")
echo "hash=${HASH}" >> "$GITHUB_OUTPUT"
echo "Calculated hash: ${HASH}"

- name: Update package.nix
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
BINARY="${{ steps.find_asset.outputs.binary }}"
HASH="${{ steps.hash.outputs.hash }}"

sed -i "s|version = \"[^\"]*\"|version = \"${VERSION}\"|g" nix/package.nix
sed -i "s|url = \"https://github.com/acsandmann/rift/releases/download/v[^/]*/[^\"]*\"|url = \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/${BINARY}\"|g" nix/package.nix
sed -i "s|sha256 = \"[^\"]*\"|sha256 = \"${HASH}\"|g" nix/package.nix

- name: Check for changes
id: check_changes
run: |
if git diff --quiet nix/package.nix; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
nix flake update
fi

- name: Commit package updates
if: steps.check_changes.outputs.has_changes == 'true'
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add nix/package.nix flake.lock
git commit -m "chore(nix): update rift-bin package after release ${{ github.ref_name }}"
COMMIT_SHA=$(git rev-parse HEAD)
echo "sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
git push origin HEAD:main

- name: Output commit SHA (no changes case)
if: steps.check_changes.outputs.has_changes == 'false'
id: no_commit
run: |
COMMIT_SHA=$(git rev-parse HEAD)
echo "sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rift-wm"
version = "0.1.0"
version = "0.2.8-beta"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Nix convention to match GitHub release, or Git tag?

edition = "2024"
build = "build.rs"

Expand Down
151 changes: 151 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
description = "rift - a tiling window manager for macOS that focuses on performance and usability";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
};

outputs =
inputs@{
flake-parts,
devshell,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"x86_64-darwin"
];
imports = [
devshell.flakeModule
(import ./nix/package.nix inputs)
./nix/module.nix
];
perSystem =
{ ... }:
{
devshells.default = {
motd = "";
};
};
}
// {
overlays.default = import ./nix/overlay.nix inputs;
};
}
76 changes: 76 additions & 0 deletions nix/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{ self, ... }:

{
flake.darwinModules.default =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.rift;

toml = pkgs.formats.toml { };

configFile =
if cfg.config == null then
null
else if lib.isPath cfg.config || lib.isString cfg.config then
cfg.config
else
toml.generate "rift.toml" cfg.config;
in
{
options.services.rift = {
enable = lib.mkEnableOption "Enable rift window manager service";

package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.system}.default;
description = "rift (not rift-cli) package to use";
};

config = lib.mkOption {
type =
with lib.types;
oneOf [
str
path
toml.type
null
];
description = "Configuration settings for rift. Also accepts paths (string or path type) to a config file.";
default = ../rift.default.toml;
};
};

config = lib.mkIf cfg.enable {
launchd.user.agents.rift = {
command = "${cfg.package}/bin/rift${
if configFile == null then "" else " --config " + lib.escapeShellArg configFile
}";

serviceConfig = {
Label = "git.acsandmann.rift";
EnvironmentVariables = {
RUST_LOG = "error,warn,info";
# todo improve
PATH = "/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
};
RunAtLoad = true;
KeepAlive = {
SuccessfulExit = false;
Crashed = true;
};
# todo add _{user} to log file name
StandardOutPath = "/tmp/rift.out.log";
StandardErrorPath = "/tmp/rift.err.log";
ProcessType = "Interactive";
LimitLoadToSessionType = "Aqua";
Nice = -20;
};
};
};
};
}
13 changes: 13 additions & 0 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
inputs: final: prev:
let
system = final.system;
packageModule = (import ./package.nix inputs).perSystem {
inherit (final) lib;
pkgs = final;
inherit system;
};
in
{
rift = packageModule.packages.rift;
rift-bin = packageModule.packages.rift-bin;
}
Loading