• You are not logged in.
  • Index
  • Technical
  • "Bag of KbdTriks" on NIXOS using mount --bind

    "Bag of KbdTriks" on NIXOS using mount --bind

    • Started by bmx007
    • 4 Replies:
    • Reputation: 0
    • Registered: 22-Nov-2009
    • Posts: 58

    Just wanted to contribute the little trick I found about installing DreymaR amazing Extended Mode: I've been using it now for more than 6 monts and I couldn't live without it.
    For people not aware of it, Extended mode allows to use caps lock key as an extra modifier and map keys to cursor moves, mouse button etc ...
    I like it so much, that I've been trying all weekend to get it working on NIXOS... without success. 
    Until I decided to cheat and use `mount --bind` and discovered it has some advantage.

    In NIXOS, the `xbd` diretory is not in `/usr/share/X11` but in  somewhere in`nix/store/.../share/X11`, and you can't modify it. I mean you REALLY can't, so using the `install-dreymar-xmod.sh` is not an option. I tried writing my own derivation, patch xkeyboard_config etc. It dint' work. I don't see any reason it couldn't be done but I gave up. So instead of trying to copy the `xkb` directory into the nix-store, I decided to just mount the new `xkb` directory where it should be in the store

       

     mount -bind /path-to-BigBagXbdTrix/xkb /nix/store/..../share/X11/xkb 

    Then I can call

    setxkb.sh

    and it works.It even seems to carry one working after having unmounting the directory.

    So, first it's an easy solution to every body which is trying get an extended mode vi NIXOS. Second, I found
    that this method was actually safer than the actual instal--dreymar-xmod.sh script. AFAIU, this script, replace the actual
    /usr/share/X11/xkb directory with the bigbag version after backuping the original.
    This can go wrong (and it did for me by the past). Using `mount -bind` is in a way equivalent : it replaces the original directory
    with the bigbag version but as the advantage that it doesn't actuall change anything : after rebooting, you get the original version.
    No need to back-up and no risk of screwing anything.
    This make me things, that instead of having two scripts, one to install and one to select the keyboard, maybe we could have just one scrpit
    doing a mount bind, select the keyboard and unmount it.

    Just my two cents.

    Offline
    • 0
    • Reputation: 20
    • Registered: 08-Oct-2017
    • Posts: 223
    bmx007 said:

    Just wanted to contribute the little trick I found about installing DreymaR amazing Extended Mode: I've been using it now for more than 6 monts and I couldn't live without it.
    For people not aware of it, Extended mode allows to use caps lock key as an extra modifier and map keys to cursor moves, mouse button etc ...
    I like it so much, that I've been trying all weekend to get it working on NIXOS... without success. 
    Until I decided to cheat and use `mount --bind` and discovered it has some advantage.

    In NIXOS, the `xbd` diretory is not in `/usr/share/X11` but in  somewhere in`nix/store/.../share/X11`, and you can't modify it. I mean you REALLY can't, so using the `install-dreymar-xmod.sh` is not an option. I tried writing my own derivation, patch xkeyboard_config etc. It dint' work. I don't see any reason it couldn't be done but I gave up. So instead of trying to copy the `xkb` directory into the nix-store, I decided to just mount the new `xkb` directory where it should be in the store

       

     mount -bind /path-to-BigBagXbdTrix/xkb /nix/store/..../share/X11/xkb 

    Then I can call

    setxkb.sh

    and it works.It even seems to carry one working after having unmounting the directory.

    So, first it's an easy solution to every body which is trying get an extended mode vi NIXOS. Second, I found
    that this method was actually safer than the actual instal--dreymar-xmod.sh script. AFAIU, this script, replace the actual
    /usr/share/X11/xkb directory with the bigbag version after backuping the original.
    This can go wrong (and it did for me by the past). Using `mount -bind` is in a way equivalent : it replaces the original directory
    with the bigbag version but as the advantage that it doesn't actuall change anything : after rebooting, you get the original version.
    No need to back-up and no risk of screwing anything.
    This make me things, that instead of having two scripts, one to install and one to select the keyboard, maybe we could have just one scrpit
    doing a mount bind, select the keyboard and unmount it.

    Just my two cents.

    Wouldn't a symbolic link work just as well?

    ln -s
    Offline
    • 0
    • Reputation: 0
    • Registered: 22-Nov-2009
    • Posts: 58

    Wouldn't a symbolic link work just as well?

    ln -s

    Not really. To create a link such as

     ln -s xkb /usr/share/X11/xbk

    . You need to remove

    /usr/share/X11/xbk

    first (or move it) which is what we are trying to avoid. You are also mutating the system and needs the write permission on /usr/share/X11. With bind mount, you are just "forwarding" all access to /usr/share/X11/xkb to the directory of your choice.

    Offline
    • 0
    • Reputation: 90
    • From: Oslo, Norway
    • Registered: 13-Dec-2006
    • Posts: 4,501

    Wow, advanced stuff. Glad you succeeded. Yes, a script addition to bind to a new dir seems like a nice idea. How should it look? I'll look into it, or maybe you want to make a pull request on GitHub?

    So you're saying that even in su mode you can't actually change the contents of that X11 folder? Then indeed we're pretty shafted. My script has an option switch to use a different X11 dir I think (or it's editable in the script init section, can't recall). But that indeed requires system write access which is usually granted using sudo (which my script should handle). If that doesn't work, it's bad luck.

    The setxkbmap command should in theory be able to use a different XKB directory so you could install somewhere else and invoke that. But lately I haven't been able to use that option. I may be doing something wrong. The alternative directory does need to be a pretty full copy and not just my files. My install script still contains an option to try that method.

    Last edited by DreymaR (09-Feb-2018 11:31:13)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 22-Nov-2009
    • Posts: 58

    I'm happy to do a pull request if I can (whenever I have the time). even though it's just adding

     mount --bind xkb /usr/share/X11/xb

    at the end of the script

    I guess you would prefer an option to be passed to the script to instead replacing the current behavior of the script.

    So you're saying that even in su mode you can't actually change the contents of that X11 folder?

    Nixos is a bit special, and doesn't like things to be modified (which makes it great but sometimes a bit awkward). I'm not sure how
    but the whole filesystem seems to be readonly, so without hacking even sudo is not enough to overrite it. Which is good anyway, the point
    of NixOS is that you can't mess things up and can (in theoriy AND in practice) go back to a previous configuration. Allowing to screw your X11 folder would
    be against that ;-)

    Offline
    • 0
      • Index
      • Technical
      • "Bag of KbdTriks" on NIXOS using mount --bind