Skip to content

Conversation

@leon-erd
Copy link
Contributor

Description

I added an "extraConfig" option to aerospace. This allows to write a multiline string directly to the toml file. This is needed for aerospace because for certain commands you need multiline strings in your toml.
E.g. suggested in the default config (https://nikitabobko.github.io/AeroSpace/guide.html#default-config):

alt-enter = '''exec-and-forget osascript -e '
tell application "Terminal"
    do script
    activate
end tell'
'''

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

CC Maintainers: @damidoug

@damidoug
Copy link
Contributor

Good point, can be useful... i recommend also you add some testes on
tests/modules/programs/aerospace

@leon-erd
Copy link
Contributor Author

What do you want tested? :)
Imo there isnt really much to test with this PR it just concats the string provided by the user to the end of the generated toml.
I guess its mostly error prone due to a wrong string provided by the user.

@leon-erd
Copy link
Contributor Author

By the way on-window-detected is also broken due to the way the toml generator handles arrays of tables.
E.g. this nix expression with the example given in the module

programs.aerospace = {
    enable = true;
    userSettings = {
      on-window-detected = [
        {
          check-further-callbacks = false;
          "if" = {
            app-id = "Another.Cool.App";
            app-name-regex-substring = "CoolApp";
            during-aerospace-startup = false;
            window-title-regex-substring = "Title";
            workspace = "cool-workspace";
          };
          run = [
            "move-node-to-workspace m"
            "resize-node"
          ];
        }
        {
          "if" = {
            app-id = "org.nixos.firefox";
          };
          run = "layout floating";
        }
      ];
    };
  };

creates this toml

~ ➜ cat .config/aerospace/aerospace.toml
accordion-padding = 30
after-startup-command = []
default-root-container-layout = "tiles"
default-root-container-orientation = "auto"
enable-normalization-flatten-containers = true
enable-normalization-opposite-orientation-for-nested-containers = true
exec-on-workspace-change = []
on-focus-changed = []
on-focused-monitor-changed = ["move-mouse monitor-lazy-center"]

[key-mapping]
preset = "qwerty"

[[on-window-detected]]
check-further-callbacks = false
run = ["move-node-to-workspace m", "resize-node"]

[on-window-detected.if]
app-id = "Another.Cool.App"
app-name-regex-substring = "CoolApp"
during-aerospace-startup = false
window-title-regex-substring = "Title"
workspace = "cool-workspace"

[[on-window-detected]]
run = "layout floating"

[on-window-detected.if]
app-id = "org.nixos.firefox"

instead of

[[on-window-detected]]
if.app-id = "org.nixos.firefox"
run = "layout floating"

With this PR the user can at least insert the correct expression directly into the toml

@khaneliman khaneliman merged commit 64020f4 into nix-community:master Oct 26, 2025
6 checks passed
@andre4ik3 andre4ik3 mentioned this pull request Oct 29, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants