From 6ad06cb349f9ec1616a5bb2381cc57733e10082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Tue, 24 Oct 2023 23:52:45 +0200 Subject: [PATCH] nix: Some system options, like keyboard --- .../system/files/us_qwert_alt_numpad.patch | 10 -- .../roles/system/files/xorg/keyboard.conf | 7 -- config/automatrop/roles/system/tasks/main.yml | 117 ------------------ config/nix/configuration.nix | 2 + config/nix/modules/battery.nix | 2 +- config/nix/modules/desktop.nix | 26 +++- config/nix/modules/qwerty-fr-keypad.diff | 10 ++ config/nix/us_qwerty-fr | 65 ++++++++++ 8 files changed, 103 insertions(+), 136 deletions(-) delete mode 100644 config/automatrop/roles/system/files/us_qwert_alt_numpad.patch delete mode 100644 config/automatrop/roles/system/files/xorg/keyboard.conf create mode 100644 config/nix/modules/qwerty-fr-keypad.diff create mode 100644 config/nix/us_qwerty-fr diff --git a/config/automatrop/roles/system/files/us_qwert_alt_numpad.patch b/config/automatrop/roles/system/files/us_qwert_alt_numpad.patch deleted file mode 100644 index 6e745b3..0000000 --- a/config/automatrop/roles/system/files/us_qwert_alt_numpad.patch +++ /dev/null @@ -1,10 +0,0 @@ -*************** -*** 6,11 **** ---- 6,12 ---- - { - include "us(basic)" - include "level3(ralt_switch)" -+ include "keypad(oss)" - - name[Group1]= "US keyboard with french symbols - AltGr combination"; - diff --git a/config/automatrop/roles/system/files/xorg/keyboard.conf b/config/automatrop/roles/system/files/xorg/keyboard.conf deleted file mode 100644 index 8248b12..0000000 --- a/config/automatrop/roles/system/files/xorg/keyboard.conf +++ /dev/null @@ -1,7 +0,0 @@ -Section "InputClass" - Identifier "system-keyboard" - MatchIsKeyboard "on" - Option "XkbLayout" "us_qwerty-fr" - #Option "XkbModel" "pc105+inet" - Option "XkbOptions" "terminate:ctrl_alt_bksp" -EndSection diff --git a/config/automatrop/roles/system/tasks/main.yml b/config/automatrop/roles/system/tasks/main.yml index aade07b..8e8f783 100644 --- a/config/automatrop/roles/system/tasks/main.yml +++ b/config/automatrop/roles/system/tasks/main.yml @@ -2,125 +2,8 @@ # Package are installed with --asdeps because they are needed -# Etckeeper - -- name: Check if etckeeper is initialized - stat: - path: /etc/.git - register: etckeeper - become: yes - -- name: Initialize etckeeper - command: "etckeeper init" - become: yes - when: not etckeeper.stat.exists - changed_when: yes - -- name: Configure git user.name for etckeeper - git_config: - scope: local - repo: /etc - name: "{{ item.name }}" - value: "{{ item.value }}" - loop: - - name: "user.name" - value: "etckeeper on {{ inventory_hostname_short }}" - - name: "user.email" - value: "etckeeper@{{ inventory_hostname }}" - become: yes - -# Manjaro configuration - -- name: Remove Manjaro's pamac - pacman: - name: pamac - state: absent - become: yes - when: arch_based and False # I'm trying to remember why I usually delete this thing - -# Verbose logging during boot - -- name: Check if using Uboot - stat: - path: /boot/extlinux/extlinux.conf - register: extlinux -# This (and the following) was made with the Pinebook in mind, -# not sure about compatibility - -- name: Remove non-tty1 console (Uboot) - replace: - path: /boot/extlinux/extlinux.conf - regexp: '^APPEND(.*) console=(?!tty1)\S+(.*)$' - replace: 'APPEND\1\2' - become: yes - when: extlinux.stat.exists -# Only one console= will be removed because regular expression are either hard -# or somewhat limited. It's just what I need anyway - -- name: Remove bootsplash.bootfile (Uboot) - replace: - path: /boot/extlinux/extlinux.conf - regexp: '^APPEND(.*) bootsplash.bootfile=\S+(.*)$' - replace: 'APPEND\1\2' - become: yes - when: extlinux.stat.exists - -- name: Remove bootsplash packages (Arch based) - pacman: - name: - - bootsplash-systemd - - bootsplash-theme-manjaro - state: absent - become: yes - when: arch_based - - -# Display Manager - -- name: Remove display manager packages (Arch based) - pacman: - name: - - sddm - - sddm-breath2-theme - state: absent - become: yes - when: arch_based - # Xorg configuration -- name: Check if there is nvidia-xrun is installed - stat: - path: /etc/X11/nvidia-xorg.conf - register: nvidia_xrun - when: display_server == 'x11' - -- name: Add nvidia-xrun xorg config directory - set_fact: - xorg_common_config_dirs: "{{ xorg_default_config_dirs + xorg_nvidia_config_dirs }}" - vars: - xorg_default_config_dirs: - - /etc/X11/xorg.conf.d - xorg_nvidia_config_dirs: "{{ ['/etc/X11/nvidia-xorg.conf.d'] if nvidia_xrun.stat.exists else [] }}" - when: display_server == 'x11' - -- name: Configure Xorg keyboard layout - copy: - src: xorg/keyboard.conf - dest: "{{ item }}/00-keyboard.conf" - become: yes - when: display_server == 'x11' - notify: etc changed - loop: "{{ xorg_common_config_dirs }}" - -- name: Use Alt keys for numpad - patch: - src: us_qwert_alt_numpad.patch - dest: /usr/share/X11/xkb/symbols/us_qwerty-fr - become: yes - when: display_server == 'x11' -# This is not very nice but it's updated so infrequently that it's not worth -# the trouble - - name: Check if there is Intel backlight stat: path: /sys/class/backlight/intel_backlight diff --git a/config/nix/configuration.nix b/config/nix/configuration.nix index 43a9174..1d7c485 100644 --- a/config/nix/configuration.nix +++ b/config/nix/configuration.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { imports = [ + + # ./modules/common.nix ./modules/desktop.nix ./modules/battery.nix diff --git a/config/nix/modules/battery.nix b/config/nix/modules/battery.nix index 98d754e..4052fe2 100644 --- a/config/nix/modules/battery.nix +++ b/config/nix/modules/battery.nix @@ -1,4 +1,4 @@ { pkgs, ... }: { - environment.systemPackages = with pkgs; [ tlp powertop ]; + environment.systemPackages = with pkgs; [ powertop ]; } diff --git a/config/nix/modules/desktop.nix b/config/nix/modules/desktop.nix index 58d46de..c2fe119 100644 --- a/config/nix/modules/desktop.nix +++ b/config/nix/modules/desktop.nix @@ -3,7 +3,30 @@ # Enable the X11 windowing system services.xserver.enable = true; - # FIXME qwerty-fr for X11 + services.xserver = { + extraLayouts.qwerty-fr = { + description = "QWERTY-fr"; + languages = [ "fr" ]; + symbolsFile = "${pkgs.stdenv.mkDerivation { + name = "qwerty-fr-keypad"; + src = builtins.fetchGit { + url = "https://github.com/qwerty-fr/qwerty-fr.git"; + rev = "3a4d13089e8ef016aa20baf6b2bf3ea53de674b8"; + }; + patches = [ ./qwerty-fr-keypad.diff ]; + # TODO This doesn't seem to be applied... it's the whole point of the derivation :( + installPhase = '' + runHook preInstall + mkdir -p $out/linux + cp $src/linux/us_qwerty-fr $out/linux + runHook postInstall + ''; + }}/linux/us_qwerty-fr"; + }; + layout = "qwerty-fr"; + # TODO home.keyboard = null; in home-manager... or something + + }; # Enable sound sound.enable = true; @@ -79,4 +102,5 @@ ]; environment.systemPackages = with pkgs; [ pavucontrol ]; + } diff --git a/config/nix/modules/qwerty-fr-keypad.diff b/config/nix/modules/qwerty-fr-keypad.diff new file mode 100644 index 0000000..d0a0246 --- /dev/null +++ b/config/nix/modules/qwerty-fr-keypad.diff @@ -0,0 +1,10 @@ +--- ./linux/us_qwerty-fr ++++ ./linux/us_qwerty-fr +@@ -4,6 +4,7 @@ + { + include "us(basic)" + include "level3(ralt_switch)" ++ include "keypad(oss)" + + name[Group1]= "US keyboard with french symbols - AltGr combination"; + diff --git a/config/nix/us_qwerty-fr b/config/nix/us_qwerty-fr new file mode 100644 index 0000000..a18b0ea --- /dev/null +++ b/config/nix/us_qwerty-fr @@ -0,0 +1,65 @@ + +partial alphanumeric_keys +xkb_symbols "qwerty-fr" +{ + include "us(basic)" + include "level3(ralt_switch)" + include "keypad(oss)" + + name[Group1]= "US keyboard with french symbols - AltGr combination"; + + key { [ grave, asciitilde, dead_grave, dead_tilde ] }; + key { [ 1, exclam, onesuperior, exclamdown ] }; + key { [ 2, at, twosuperior, dead_doubleacute ] }; + key { [ 3, numbersign, ecircumflex, Ecircumflex ] }; + key { [ 4, dollar, EuroSign, dead_currency ] }; // FIXME: dead_currency has a different mapping than the one we want for qwerty-fr. Need to define a custom dead key instead. See Windows layout for dead key definition. + key { [ 5, percent, dead_macron, dead_abovedot ] }; + key { [ 6, asciicircum, dead_circumflex, dead_caron ] }; + key { [ 7, ampersand, ucircumflex, Ucircumflex ] }; + key { [ 8, asterisk, icircumflex, Icircumflex ] }; + key { [ 9, parenleft, ocircumflex, Ocircumflex ] }; + key { [ 0, parenright, oslash, Oslash ] }; + key { [ minus, underscore, endash, emdash ] }; + key { [ equal, plus, notequal, approxeq ] }; + + key { [ q, Q, acircumflex, Acircumflex ] }; + key { [ w, W, eacute, Eacute ] }; + key { [ e, E, egrave, Egrave ] }; + key { [ r, R, registered, copyright ] }; + key { [ t, T, thorn, THORN ] }; + key { [ y, Y, dead_invertedbreve, dead_breve ] }; + key { [ u, U, ugrave, Ugrave ] }; + key { [ i, I, igrave, Igrave ] }; + key { [ o, O, ograve, Ograve ] }; + key { [ p, P, oe, OE ] }; + key { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] }; + key { [ bracketright, braceright, guillemotright, rightdoublequotemark ] }; + + key { [ a, A, agrave, Agrave ] }; + key { [ s, S, ae, AE ] }; + key { [ d, D, ediaeresis, Ediaeresis ] }; + key { [ f, F, VoidSymbol, VoidSymbol ] }; + key { [ g, G, dead_greek, VoidSymbol ] }; // FIXME: dead_greek has a different mapping than the one we want for qwerty-fr. Need to define a custom dead key instead. See Windows layout for dead key definition. + key { [ h, H, ydiaeresis, Ydiaeresis ] }; + key { [ j, J, udiaeresis, Udiaeresis ] }; + key { [ k, K, idiaeresis, Idiaeresis ] }; + key { [ l, L, odiaeresis, Odiaeresis ] }; + key { [ semicolon, colon, dead_acute, dead_abovering ] }; + key { [ apostrophe, quotedbl, dead_grave, dead_diaeresis ] }; + key { [ backslash, bar, VoidSymbol, doublelowquotemark ] }; // „ + + key { [ less, greater, lessthanequal, greaterthanequal ] }; + key { [ z, Z, adiaeresis, Adiaeresis ] }; + key { [ x, X, multiply, division ] }; + key { [ c, C, ccedilla, Ccedilla ] }; + key { [ v, V, VoidSymbol, VoidSymbol ] }; + key { [ b, B, ssharp, U1E9E ] }; // ß, ẞ (capital) + key { [ n, N, ntilde, Ntilde ] }; + key { [ m, M, VoidSymbol, VoidSymbol ] }; + key { [ comma, less, dead_cedilla, dead_ogonek ] }; + key { [ period, greater, periodcentered, ellipsis ] }; // ., >, ·, … + key { [ slash, question, rightsinglequotemark, questiondown ] }; // /, ?, ’, ¿ + key { [ space, space, nobreakspace, 0x100202F ] }; // espace insécable fine + +}; +