Skip to content

Commit

Permalink
feat: Allow to exclude dotfiles on pillar data
Browse files Browse the repository at this point in the history
  • Loading branch information
seven-beep committed Sep 30, 2024
1 parent 7e2502b commit be5f119
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!--
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>
SPDX-License-Identifier: CC-BY-SA-4.0
-->
Expand All @@ -13,6 +14,7 @@ Dotfiles.
* [Description](#description)
* [Installation](#installation)
* [Salt](#salt)
* [Pillar](#pillar)
* [Script](#script)
* [Usage](#usage)
* [License](#license)
Expand Down Expand Up @@ -59,6 +61,48 @@ Install specific files in Dom0:
sudo qubesctl state.apply dotfiles.copy-dom0,dotfiles.copy-sh,dotfiles.copy-vim,dotfiles.copy-x11
```

#### Pillar

With salt, each state execution can be opt out by topic via a corresponding
pillar set to a non true value (eg: Setting qusal:dotfiles:dom0 to false will
disable states specific to dom0, setting qusal:dotfiles:git to false will
disable states specific to git).

You will need a top file and a sls file in your pillar_roots, when following
[the Qusal's installation instructions](https://github.com/ben-grande/qusal/blob/main/docs/INSTALL.md),
`/srv/pillar/qusal` will be added to you pillar_roots.

By default, the formulas assume that you opt-in for all dotfiles.

Example: /srv/pillar/qusal/dotfiles.top:

```yaml
base:
'*':
- qusal.dotfiles
```
It will apply the qusal/dotfiles sls to all targets.
Example: /srv/pillar/qusal/dotfiles.sls containing the data to pass to the
targets:
```yaml
qusal:
dotfiles:
dom0: false
```
It will disable the dom0 dotfiles configuration.
Enable the pillar top above:
```sh
sudo qubesctl top.enable qusal.dotfiles pillar=true
```

Now subsequent calls to the states of this repository will skip copy-dom0.

### Script

You can simply deploy all configurations with:
Expand Down
5 changes: 5 additions & 0 deletions copy-all.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{#
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if salt['pillar.get']('qusal:dotfiles:all', default=true) == true -%}

include:
- .copy-dom0
- .copy-git
Expand All @@ -17,6 +20,8 @@ include:
- .copy-x11
- .copy-xfce

{%- endif -%}

{#
Unfortunately salt.states.file does not keep permissions when using salt-ssh.
Best option is 'file.managed mode: keep' or 'file.recurse file_mode: keep'.
Expand Down
6 changes: 6 additions & 0 deletions copy-dom0.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:dom0', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-dom0-home":
Expand All @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-git.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:git', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-git-home":
Expand Down Expand Up @@ -65,3 +69,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-gtk.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:gtk', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-gtk-home":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-mutt.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:mutt', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-mutt-home":
Expand All @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-net.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:net', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-net-home":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-pgp.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:gpg', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-pgp-home":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-sh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:sh', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-sh-home":
Expand Down Expand Up @@ -43,3 +47,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-ssh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:ssh', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-ssh-home":
Expand All @@ -24,3 +28,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-tmux.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:tmux', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-tmux-home":
Expand Down Expand Up @@ -37,3 +41,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-vim.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:vim', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-vim-home":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-x11.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:x11', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-x11-home":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-xfce.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true )
and (salt['pillar.get']('qusal:dotfiles:xfce', default=true) == true )) -%}

{%- import "dom0/gui-user.jinja" as gui_user -%}
"{{ slsdotpath }}-copy-xfce-home":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}

0 comments on commit be5f119

Please sign in to comment.