From 6536b2ed89cf4de21a0e5c91f76eb74196ccca1b Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Fri, 7 Nov 2025 14:32:39 -0300 Subject: [PATCH 01/10] feat: init nix modules --- flake.lock | 151 ++++++++++++++++++++++++++++ flake.nix | 39 ++++++++ nix/module.nix | 258 ++++++++++++++++++++++++++++++++++++++++++++++++ nix/package.nix | 59 +++++++++++ 4 files changed, 507 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/module.nix create mode 100644 nix/package.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..99382d8a --- /dev/null +++ b/flake.lock @@ -0,0 +1,151 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1762536088, + "narHash": "sha256-wuyhKeT5Vhk2xcEYySolJc9fRY9M9VoOOlYBizyQkXs=", + "owner": "ipetkov", + "repo": "crane", + "rev": "c43a1f1ad9ff376107106b2c1173da9c88ae07ea", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devshell": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1762521437, + "narHash": "sha256-RXN+lcx4DEn3ZS+LqEJSUu/HH+dwGvy0syN7hTo/Chg=", + "owner": "numtide", + "repo": "devshell", + "rev": "07bacc9531f5f4df6657c0a02a806443685f384a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1762497870, + "narHash": "sha256-SACLPSL49UcFOcLelROFp5BtI0QOeEiEZnVy0k0esr8=", + "owner": "nix-community", + "repo": "fenix", + "rev": "a11e8c4055f55df13ea6e29997ecdaf170f910a9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1762440070, + "narHash": "sha256-xxdepIcb39UJ94+YydGP221rjnpkDZUlykKuF54PsqI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "26d05891e14c88eb4a5d5bee659c0db5afb609d8", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1762156382, + "narHash": "sha256-Yg7Ag7ov5+36jEFC1DaZh/12SEXo6OO3/8rqADRxiqs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7241bcbb4f099a66aafca120d37c65e8dda32717", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1762363567, + "narHash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "devshell": "devshell", + "fenix": "fenix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1762438844, + "narHash": "sha256-ApIKJf6CcMsV2nYBXhGF95BmZMO/QXPhgfSnkA/rVUo=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "4bf516ee5a960c1e2eee9fedd9b1c9e976a19c86", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..a3030075 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + 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 = ""; + }; + }; + }; +} diff --git a/nix/module.nix b/nix/module.nix new file mode 100644 index 00000000..a1a6653e --- /dev/null +++ b/nix/module.nix @@ -0,0 +1,258 @@ +{ 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 = { + settings = { + animate = true; + animation_duration = 0.3; + animation_fps = 100.0; + animation_easing = "ease_in_out"; + + focus_follows_mouse = true; + mouse_follows_focus = true; + mouse_hides_on_focus = true; + + auto_focus_blacklist = [ ]; + + run_on_start = [ ]; + + hot_reload = true; + + layout = { + mode = "traditional"; + + stack = { + stack_offset = 40.0; + default_orientation = "perpendicular"; + }; + + gaps = { + outer = { + top = 0; + left = 0; + bottom = 0; + right = 0; + }; + + inner = { + horizontal = 0; + vertical = 0; + }; + }; + }; + + ui = { + menu_bar = { + enabled = false; + show_empty = false; + }; + + stack_line = { + enabled = false; + horiz_placement = "top"; + vert_placement = "left"; + thickness = 0.0; + spacing = 0.0; + }; + + mission_control = { + enabled = false; + fade_enabled = false; + fade_duration_ms = 180.0; + }; + }; + + gestures = { + enabled = false; + invert_horizontal_swipe = false; + swipe_vertical_tolerance = 0.4; + skip_empty = true; + fingers = 3; + distance_pct = 0.08; + haptics_enabled = true; + haptic_pattern = "level_change"; + }; + + window_snapping = { + drag_swap_fraction = 0.3; + }; + }; + + virtual_workspaces = { + enabled = true; + default_workspace_count = 4; + auto_assign_windows = true; + preserve_focus_per_workspace = true; + workspace_auto_back_and_forth = false; + + workspace_names = [ + "first" + "second" + ]; + + app_rules = [ ]; + }; + + modifier_combinations = { + comb1 = "Alt + Shift"; + }; + + keys = { + "Alt + Z" = "toggle_space_activated"; + + "Alt + H" = { + move_focus = "left"; + }; + "Alt + J" = { + move_focus = "down"; + }; + "Alt + K" = { + move_focus = "up"; + }; + "Alt + L" = { + move_focus = "right"; + }; + + "comb1 + H" = { + move_node = "left"; + }; + "comb1 + J" = { + move_node = "down"; + }; + "comb1 + K" = { + move_node = "up"; + }; + "comb1 + L" = { + move_node = "right"; + }; + + "Alt + 0" = { + switch_to_workspace = 0; + }; + "Alt + 1" = { + switch_to_workspace = 1; + }; + "Alt + 2" = { + switch_to_workspace = 2; + }; + "Alt + 3" = { + switch_to_workspace = 3; + }; + + "comb1 + 0" = { + move_window_to_workspace = 0; + }; + "comb1 + 1" = { + move_window_to_workspace = 1; + }; + "comb1 + 2" = { + move_window_to_workspace = 2; + }; + "comb1 + 3" = { + move_window_to_workspace = 3; + }; + + "Alt + Tab" = "switch_to_last_workspace"; + + "Alt + Shift + Left" = { + join_window = "left"; + }; + "Alt + Shift + Right" = { + join_window = "right"; + }; + "Alt + Shift + Up" = { + join_window = "up"; + }; + "Alt + Shift + Down" = { + join_window = "down"; + }; + "Alt + Comma" = "toggle_stack"; + "Alt + Slash" = "toggle_orientation"; + "Alt + Ctrl + E" = "unjoin_windows"; + + "Alt + Shift + Space" = "toggle_window_floating"; + "Alt + F" = "toggle_fullscreen"; + "Alt + Shift + F" = "toggle_fullscreen_within_gaps"; + "comb1 + Ctrl + Space" = "toggle_focus_floating"; + + "Alt + Shift + Equal" = "resize_window_grow"; + "Alt + Shift + Minus" = "resize_window_shrink"; + + "Alt + Shift + D" = "debug"; + + "Alt + Ctrl + S" = "serialize"; + "Alt + Ctrl + Q" = "save_and_exit"; + }; + }; + }; + }; + + 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; + }; + }; + }; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..dceb7f8b --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,59 @@ +{ + crane, + fenix, + ... +}: +{ + perSystem = + { + pkgs, + lib, + system, + ... + }: + let + toolchain = fenix.packages.${system}.stable.toolchain; + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + root = ../.; + + args = { + src = lib.fileset.toSource { + inherit root; + fileset = lib.fileset.unions [ + (craneLib.fileset.commonCargoSources root) + (lib.fileset.fileFilter (file: file.hasExt "plist") root) + ]; + }; + strictDeps = true; + doCheck = false; + + nativeBuildInputs = [ ]; + buildInputs = [ ]; + }; + + bin = craneLib.buildPackage ( + args + // { + cargoArtifacts = craneLib.buildDepsOnly args; + } + ); + in + { + checks.agent-engine = bin; + + packages.default = bin; + + devshells.default = { + packages = [ + toolchain + ]; + commands = [ + { + help = ""; + name = "hot"; + command = "${pkgs.watchexec}/bin/watchexec -e rs -w src -w Cargo.toml -w Cargo.lock -r ${toolchain}/bin/cargo run -- $@"; + } + ]; + }; + }; +} From a8d6338dc352c87a4258e423c97d31ca258326f2 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Fri, 7 Nov 2025 15:17:01 -0300 Subject: [PATCH 02/10] feat: add nix overlay --- flake.nix | 2 ++ nix/overlay.nix | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 nix/overlay.nix diff --git a/flake.nix b/flake.nix index a3030075..51823675 100644 --- a/flake.nix +++ b/flake.nix @@ -35,5 +35,7 @@ motd = ""; }; }; + } // { + overlays.default = import ./nix/overlay.nix inputs; }; } diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 00000000..a2d8f8f7 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,12 @@ +inputs: final: prev: +let + system = final.system; + packageModule = (import ./package.nix inputs).perSystem { + inherit (final) lib; + pkgs = final; + inherit system; + }; +in +{ + rift = packageModule.packages.default; +} From 8b9f693f05f84c35e9f0b8aa348ae864685dda89 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Fri, 7 Nov 2025 15:24:38 -0300 Subject: [PATCH 03/10] chore: bump version to match github releases --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e555bbb..346a78a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1248,7 +1248,7 @@ checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "rift-wm" -version = "0.1.0" +version = "0.1.2-beta" dependencies = [ "anyhow", "ascii_tree", diff --git a/Cargo.toml b/Cargo.toml index d2192727..0724ca91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rift-wm" -version = "0.1.0" +version = "0.1.2-beta" edition = "2024" build = "build.rs" From b1d07cc3613b8663105cc24c2b879d87fb630f6d Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Fri, 7 Nov 2025 15:25:10 -0300 Subject: [PATCH 04/10] fix: use default config that's already on repo --- nix/module.nix | 184 +------------------------------------------------ 1 file changed, 1 insertion(+), 183 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index a1a6653e..82072ccf 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -41,189 +41,7 @@ null ]; description = "Configuration settings for rift. Also accepts paths (string or path type) to a config file."; - default = { - settings = { - animate = true; - animation_duration = 0.3; - animation_fps = 100.0; - animation_easing = "ease_in_out"; - - focus_follows_mouse = true; - mouse_follows_focus = true; - mouse_hides_on_focus = true; - - auto_focus_blacklist = [ ]; - - run_on_start = [ ]; - - hot_reload = true; - - layout = { - mode = "traditional"; - - stack = { - stack_offset = 40.0; - default_orientation = "perpendicular"; - }; - - gaps = { - outer = { - top = 0; - left = 0; - bottom = 0; - right = 0; - }; - - inner = { - horizontal = 0; - vertical = 0; - }; - }; - }; - - ui = { - menu_bar = { - enabled = false; - show_empty = false; - }; - - stack_line = { - enabled = false; - horiz_placement = "top"; - vert_placement = "left"; - thickness = 0.0; - spacing = 0.0; - }; - - mission_control = { - enabled = false; - fade_enabled = false; - fade_duration_ms = 180.0; - }; - }; - - gestures = { - enabled = false; - invert_horizontal_swipe = false; - swipe_vertical_tolerance = 0.4; - skip_empty = true; - fingers = 3; - distance_pct = 0.08; - haptics_enabled = true; - haptic_pattern = "level_change"; - }; - - window_snapping = { - drag_swap_fraction = 0.3; - }; - }; - - virtual_workspaces = { - enabled = true; - default_workspace_count = 4; - auto_assign_windows = true; - preserve_focus_per_workspace = true; - workspace_auto_back_and_forth = false; - - workspace_names = [ - "first" - "second" - ]; - - app_rules = [ ]; - }; - - modifier_combinations = { - comb1 = "Alt + Shift"; - }; - - keys = { - "Alt + Z" = "toggle_space_activated"; - - "Alt + H" = { - move_focus = "left"; - }; - "Alt + J" = { - move_focus = "down"; - }; - "Alt + K" = { - move_focus = "up"; - }; - "Alt + L" = { - move_focus = "right"; - }; - - "comb1 + H" = { - move_node = "left"; - }; - "comb1 + J" = { - move_node = "down"; - }; - "comb1 + K" = { - move_node = "up"; - }; - "comb1 + L" = { - move_node = "right"; - }; - - "Alt + 0" = { - switch_to_workspace = 0; - }; - "Alt + 1" = { - switch_to_workspace = 1; - }; - "Alt + 2" = { - switch_to_workspace = 2; - }; - "Alt + 3" = { - switch_to_workspace = 3; - }; - - "comb1 + 0" = { - move_window_to_workspace = 0; - }; - "comb1 + 1" = { - move_window_to_workspace = 1; - }; - "comb1 + 2" = { - move_window_to_workspace = 2; - }; - "comb1 + 3" = { - move_window_to_workspace = 3; - }; - - "Alt + Tab" = "switch_to_last_workspace"; - - "Alt + Shift + Left" = { - join_window = "left"; - }; - "Alt + Shift + Right" = { - join_window = "right"; - }; - "Alt + Shift + Up" = { - join_window = "up"; - }; - "Alt + Shift + Down" = { - join_window = "down"; - }; - "Alt + Comma" = "toggle_stack"; - "Alt + Slash" = "toggle_orientation"; - "Alt + Ctrl + E" = "unjoin_windows"; - - "Alt + Shift + Space" = "toggle_window_floating"; - "Alt + F" = "toggle_fullscreen"; - "Alt + Shift + F" = "toggle_fullscreen_within_gaps"; - "comb1 + Ctrl + Space" = "toggle_focus_floating"; - - "Alt + Shift + Equal" = "resize_window_grow"; - "Alt + Shift + Minus" = "resize_window_shrink"; - - "Alt + Shift + D" = "debug"; - - "Alt + Ctrl + S" = "serialize"; - "Alt + Ctrl + Q" = "save_and_exit"; - }; - }; + default = ../rift.default.toml; }; }; From 682ccada9a0f03ee9be1ae582ac2ace70b2d5660 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Sat, 8 Nov 2025 18:08:09 -0300 Subject: [PATCH 05/10] feat: add nix release workflow --- .github/workflows/release-nix-build.yml | 126 ++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .github/workflows/release-nix-build.yml diff --git a/.github/workflows/release-nix-build.yml b/.github/workflows/release-nix-build.yml new file mode 100644 index 00000000..29a8e843 --- /dev/null +++ b/.github/workflows/release-nix-build.yml @@ -0,0 +1,126 @@ +name: Release - Nix Build & Binary Cache + +on: + release: + types: [published] + +concurrency: + group: build-rift-nix + cancel-in-progress: false + +jobs: + update-flake: + runs-on: ubuntu-latest + 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: Update flake inputs + run: | + nix flake update + + - name: Check for changes + id: check_changes + run: | + if git diff --quiet flake.lock; then + echo "has_changes=false" >> "$GITHUB_OUTPUT" + else + echo "has_changes=true" >> "$GITHUB_OUTPUT" + fi + + - name: Commit flake lock 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 flake.lock + git commit -m "chore(nix): update flake inputs 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" + + build-nix: + needs: [update-flake] + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - system: aarch64-darwin + runner: macos-15 + - system: x86_64-darwin + runner: macos-15-intel + steps: + - name: Determine commit SHA + id: get_sha + run: | + # Use commit SHA from update-flake if available, otherwise use main + COMMIT_SHA="${{ needs.update-flake.outputs.commit_sha }}" + if [ -z "$COMMIT_SHA" ]; then + COMMIT_SHA="${{ needs.update-flake.outputs.no_commit_sha }}" + fi + echo "sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT" + + - name: Checkout exact commit from update-flake + uses: actions/checkout@v5 + with: + ref: ${{ steps.get_sha.outputs.sha }} + fetch-depth: 0 + + - uses: nixbuild/nix-quick-install-action@v34 + with: + nix_conf: | + substituters = https://cache.nixos.org/ https://nix-community.cachix.org https://cache.garnix.io + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= + cores = 0 + + # To use a binary cache, uncomment and configure: + # - Create a Cachix account at https://cachix.org + # - Create a new binary cache in your Cachix account dashboard + # - Generate an auth token from your Cachix profile settings + # - Add the following secrets to your GitHub repository: + # * CACHIX_CACHE_NAME: your-cache-name + # * CACHIX_AUTH_TOKEN: your-auth-token + # - Uncomment the Cachix setup step below + + # Uncomment this section to enable Cachix binary cache pushing + # - uses: cachix/cachix-action@v15 + # with: + # name: ${{ secrets.CACHIX_CACHE_NAME }} + # authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + # skipPush: true + - uses: DeterminateSystems/magic-nix-cache-action@main # keep this, it speeds up builds. + + - name: Build rift for ${{ matrix.system }} + run: | + nix build .#default -L + + # Uncomment this section to enable Cachix binary cache pushing + # - name: Push to Cachix + # run: | + # # Get the store path + # STORE_PATH=$(nix eval --raw .#packages.${{ matrix.system }}.default.outPath 2>/dev/null || nix eval --raw .#default.outPath) + # PIN_NAME="rift-${{ matrix.system }}" + # echo "Pushing to Cachix: $STORE_PATH" + + # nix path-info --recursive "$STORE_PATH" | cachix push ${{ secrets.CACHIX_CACHE_NAME }} + + # cachix pin ${{ secrets.CACHIX_CACHE_NAME }} "$PIN_NAME" "$STORE_PATH" --keep-revisions 3 From 22ebc87d402bb81a7de3e1a79123b8edd9fc7495 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Sat, 8 Nov 2025 18:39:40 -0300 Subject: [PATCH 06/10] feat: add `rift-bin` package, no need for cache --- .github/workflows/release-nix-build.yml | 117 ++++++++---------------- flake.nix | 3 +- nix/package.nix | 23 ++++- 3 files changed, 62 insertions(+), 81 deletions(-) diff --git a/.github/workflows/release-nix-build.yml b/.github/workflows/release-nix-build.yml index 29a8e843..5cafe47b 100644 --- a/.github/workflows/release-nix-build.yml +++ b/.github/workflows/release-nix-build.yml @@ -1,15 +1,15 @@ -name: Release - Nix Build & Binary Cache +name: Release - Update Nix Package on: release: types: [published] concurrency: - group: build-rift-nix + group: update-nix-rift cancel-in-progress: false jobs: - update-flake: + update-nix: runs-on: ubuntu-latest permissions: contents: write @@ -25,27 +25,58 @@ jobs: - name: Install Nix uses: nixbuild/nix-quick-install-action@v34 - - name: Update flake inputs + - name: Find universal binary release asset + id: find_asset run: | - nix flake update + 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 flake.lock; then + if git diff --quiet nix/package.nix; then echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT" fi - - name: Commit flake lock updates + - 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 flake.lock - git commit -m "chore(nix): update flake inputs after release ${{ github.ref_name }}" + git add nix/package.nix + 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 @@ -56,71 +87,3 @@ jobs: run: | COMMIT_SHA=$(git rev-parse HEAD) echo "sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT" - - build-nix: - needs: [update-flake] - runs-on: ${{ matrix.runner }} - strategy: - fail-fast: false - matrix: - include: - - system: aarch64-darwin - runner: macos-15 - - system: x86_64-darwin - runner: macos-15-intel - steps: - - name: Determine commit SHA - id: get_sha - run: | - # Use commit SHA from update-flake if available, otherwise use main - COMMIT_SHA="${{ needs.update-flake.outputs.commit_sha }}" - if [ -z "$COMMIT_SHA" ]; then - COMMIT_SHA="${{ needs.update-flake.outputs.no_commit_sha }}" - fi - echo "sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT" - - - name: Checkout exact commit from update-flake - uses: actions/checkout@v5 - with: - ref: ${{ steps.get_sha.outputs.sha }} - fetch-depth: 0 - - - uses: nixbuild/nix-quick-install-action@v34 - with: - nix_conf: | - substituters = https://cache.nixos.org/ https://nix-community.cachix.org https://cache.garnix.io - trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= - cores = 0 - - # To use a binary cache, uncomment and configure: - # - Create a Cachix account at https://cachix.org - # - Create a new binary cache in your Cachix account dashboard - # - Generate an auth token from your Cachix profile settings - # - Add the following secrets to your GitHub repository: - # * CACHIX_CACHE_NAME: your-cache-name - # * CACHIX_AUTH_TOKEN: your-auth-token - # - Uncomment the Cachix setup step below - - # Uncomment this section to enable Cachix binary cache pushing - # - uses: cachix/cachix-action@v15 - # with: - # name: ${{ secrets.CACHIX_CACHE_NAME }} - # authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - # skipPush: true - - uses: DeterminateSystems/magic-nix-cache-action@main # keep this, it speeds up builds. - - - name: Build rift for ${{ matrix.system }} - run: | - nix build .#default -L - - # Uncomment this section to enable Cachix binary cache pushing - # - name: Push to Cachix - # run: | - # # Get the store path - # STORE_PATH=$(nix eval --raw .#packages.${{ matrix.system }}.default.outPath 2>/dev/null || nix eval --raw .#default.outPath) - # PIN_NAME="rift-${{ matrix.system }}" - # echo "Pushing to Cachix: $STORE_PATH" - - # nix path-info --recursive "$STORE_PATH" | cachix push ${{ secrets.CACHIX_CACHE_NAME }} - - # cachix pin ${{ secrets.CACHIX_CACHE_NAME }} "$PIN_NAME" "$STORE_PATH" --keep-revisions 3 diff --git a/flake.nix b/flake.nix index 51823675..eb56fbce 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,8 @@ motd = ""; }; }; - } // { + } + // { overlays.default = import ./nix/overlay.nix inputs; }; } diff --git a/nix/package.nix b/nix/package.nix index dceb7f8b..b56f4969 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -31,17 +31,34 @@ buildInputs = [ ]; }; - bin = craneLib.buildPackage ( + build = craneLib.buildPackage ( args // { cargoArtifacts = craneLib.buildDepsOnly args; } ); + + rift-bin = pkgs.stdenv.mkDerivation { + pname = "rift-bin"; + version = "0.2.0"; + src = builtins.fetchTarball { + url = "https://github.com/acsandmann/rift/releases/download/v0.2.0/rift-universal-macos-0.2.0.tar.gz"; + sha256 = "1cm3nqz6bl01i337yg1l9v616w4kkcsc1m725s9hgj5zgprhybna"; + }; + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p $out/bin + cp -r $src/* $out/bin + chmod +x $out/bin/* + ''; + }; in { - checks.agent-engine = bin; + checks.rift = build; - packages.default = bin; + packages.rift = build; + packages.rift-bin = rift-bin; + packages.default = rift-bin; devshells.default = { packages = [ From 595fd58cb3889fdc3656569e4f0aa038edbff37c Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Mon, 10 Nov 2025 14:23:10 -0300 Subject: [PATCH 07/10] fix: merge workflows into one to use `needs` tag --- .github/workflows/release-nix-build.yml | 89 ------------------------- .github/workflows/release.yml | 80 ++++++++++++++++++++++ 2 files changed, 80 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/release-nix-build.yml diff --git a/.github/workflows/release-nix-build.yml b/.github/workflows/release-nix-build.yml deleted file mode 100644 index 5cafe47b..00000000 --- a/.github/workflows/release-nix-build.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Release - Update Nix Package - -on: - release: - types: [published] - -concurrency: - group: update-nix-rift - cancel-in-progress: false - -jobs: - update-nix: - runs-on: ubuntu-latest - 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" - 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 - 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" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c2be083..1a00f540 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,3 +119,83 @@ 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" + 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 + 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" From 9ad1151630dca3333c19c4214bae220cf95aff83 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Mon, 10 Nov 2025 14:26:04 -0300 Subject: [PATCH 08/10] patch: also update flake lockfile in case of release --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a00f540..8cc95520 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -179,6 +179,7 @@ jobs: echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT" + nix flake update fi - name: Commit package updates @@ -187,7 +188,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add nix/package.nix + 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" From 6fab090cbf0a231850ac299b467c694cfa4be835 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Tue, 11 Nov 2025 10:17:34 -0300 Subject: [PATCH 09/10] chore(flake): update inputs --- flake.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 99382d8a..c32e35fe 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1762536088, - "narHash": "sha256-wuyhKeT5Vhk2xcEYySolJc9fRY9M9VoOOlYBizyQkXs=", + "lastModified": 1765145449, + "narHash": "sha256-aBVHGWWRzSpfL++LubA0CwOOQ64WNLegrYHwsVuVN7A=", "owner": "ipetkov", "repo": "crane", - "rev": "c43a1f1ad9ff376107106b2c1173da9c88ae07ea", + "rev": "69f538cdce5955fcd47abfed4395dc6d5194c1c5", "type": "github" }, "original": { @@ -20,11 +20,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1762521437, - "narHash": "sha256-RXN+lcx4DEn3ZS+LqEJSUu/HH+dwGvy0syN7hTo/Chg=", + "lastModified": 1764011051, + "narHash": "sha256-M7SZyPZiqZUR/EiiBJnmyUbOi5oE/03tCeFrTiUZchI=", "owner": "numtide", "repo": "devshell", - "rev": "07bacc9531f5f4df6657c0a02a806443685f384a", + "rev": "17ed8d9744ebe70424659b0ef74ad6d41fc87071", "type": "github" }, "original": { @@ -41,11 +41,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1762497870, - "narHash": "sha256-SACLPSL49UcFOcLelROFp5BtI0QOeEiEZnVy0k0esr8=", + "lastModified": 1765252472, + "narHash": "sha256-byMt/uMi7DJ8tRniFopDFZMO3leSjGp6GS4zWOFT+uQ=", "owner": "nix-community", "repo": "fenix", - "rev": "a11e8c4055f55df13ea6e29997ecdaf170f910a9", + "rev": "8456b985f6652e3eef0632ee9992b439735c5544", "type": "github" }, "original": { @@ -59,11 +59,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1762440070, - "narHash": "sha256-xxdepIcb39UJ94+YydGP221rjnpkDZUlykKuF54PsqI=", + "lastModified": 1763759067, + "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "26d05891e14c88eb4a5d5bee659c0db5afb609d8", + "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", "type": "github" }, "original": { @@ -105,11 +105,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1762363567, - "narHash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=", + "lastModified": 1765186076, + "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4", + "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { @@ -131,11 +131,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1762438844, - "narHash": "sha256-ApIKJf6CcMsV2nYBXhGF95BmZMO/QXPhgfSnkA/rVUo=", + "lastModified": 1765120009, + "narHash": "sha256-nG76b87rkaDzibWbnB5bYDm6a52b78A+fpm+03pqYIw=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "4bf516ee5a960c1e2eee9fedd9b1c9e976a19c86", + "rev": "5e3e9c4e61bba8a5e72134b9ffefbef8f531d008", "type": "github" }, "original": { From 3d877dac3892df96f7f258434d732c882616d7d2 Mon Sep 17 00:00:00 2001 From: "GustavoWidman (laptop-mac)" Date: Wed, 10 Dec 2025 14:55:43 -0300 Subject: [PATCH 10/10] chore: update package version to match gh release --- Cargo.toml | 2 +- nix/package.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0724ca91..3bcbce19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rift-wm" -version = "0.1.2-beta" +version = "0.2.8-beta" edition = "2024" build = "build.rs" diff --git a/nix/package.nix b/nix/package.nix index b56f4969..e23cef12 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -40,9 +40,9 @@ rift-bin = pkgs.stdenv.mkDerivation { pname = "rift-bin"; - version = "0.2.0"; + version = "0.2.8"; src = builtins.fetchTarball { - url = "https://github.com/acsandmann/rift/releases/download/v0.2.0/rift-universal-macos-0.2.0.tar.gz"; + url = "https://github.com/acsandmann/rift/releases/download/v0.2.8/rift-universal-macos-0.2.8.tar.gz"; sha256 = "1cm3nqz6bl01i337yg1l9v616w4kkcsc1m725s9hgj5zgprhybna"; }; phases = [ "installPhase" ];