Skip to content

Instantly share code, notes, and snippets.

@cmacrae
Last active December 24, 2019 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmacrae/e41c431da8294d37f89602dd20b82f34 to your computer and use it in GitHub Desktop.
Save cmacrae/e41c431da8294d37f89602dd20b82f34 to your computer and use it in GitHub Desktop.

Revisions

  1. Calum MacRae revised this gist Dec 24, 2019. 1 changed file with 11 additions and 10 deletions.
    21 changes: 11 additions & 10 deletions nix_help_wanted.md
    @@ -6,17 +6,18 @@ As such, I have two configuration files that I'd like to take Nix sets/a list of
    I want to write a function that takes this:
    ```nix
    {
    input."1:1:AT_Translated_Set_2_keyboard" = {
    xkb_layout = "gb";
    xkb_options = "ctrl:nocaps";
    };
    inputs = {
    "1:1:AT_Translated_Set_2_keyboard" = {
    xkb_layout = "gb";
    xkb_options = "ctrl:nocaps";
    };
    input."1739:0:Synaptics_TM3381-002" = {
    pointer_accel = "0.7";
    tap = "enabled";
    dwt = "enabled";
    natural_scroll = "enabled";
    "1739:0:Synaptics_TM3381-002" = {
    pointer_accel = "0.7";
    tap = "enabled";
    dwt = "enabled";
    natural_scroll = "enabled";
    };
    };
    }
    ```
  2. Calum MacRae created this gist Dec 24, 2019.
    81 changes: 81 additions & 0 deletions nix_help_wanted.md
    @@ -0,0 +1,81 @@
    ## About
    I'm trying to get a bit of a better grasp on the Nix language, rather than just as a vehicle for systems configuration.
    As such, I have two configuration files that I'd like to take Nix sets/a list of sets to template out these files from.

    ### 1. The `inputs` config
    I want to write a function that takes this:
    ```nix
    {
    input."1:1:AT_Translated_Set_2_keyboard" = {
    xkb_layout = "gb";
    xkb_options = "ctrl:nocaps";
    };
    input."1739:0:Synaptics_TM3381-002" = {
    pointer_accel = "0.7";
    tap = "enabled";
    dwt = "enabled";
    natural_scroll = "enabled";
    };
    }
    ```
    And outputs this as a string:
    ```
    input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_layout gb
    xkb_options ctrl:nocaps
    }
    input "1739:0:Synaptics_TM3381-002" {
    pointer_accel 0.7
    tap enabled
    dwt enabled
    natural_scroll enabled
    }
    ```

    ### 2. The `outputs` config
    I'd like to write a function that takes this:
    ```nix
    {
    outputs = [
    { eDP1 = {};}
    {
    "DP-1" = {
    position = "0,0";
    transform = "270";
    };
    "HDMI-A-2" = { position = "1440,470"; };
    "eDP-1" = { position = "1440,1910"; };
    }
    {
    "DP-3" = { position = "450,0"; };
    "DP-4" = { position = "0,1440"; };
    "eDP-1" = { position = "800,2880"; };
    }
    ];
    }
    ```
    And outputs this:
    ```
    {
    output eDP-1
    }
    {
    output DP-1 position 0,0 transform 270
    output HDMI-A-2 position 1440,470
    output eDP-1 position 1440,1910
    }
    {
    output DP-3 position 450,0
    output DP-4 position 0,1440
    output eDP-1 position 800,2880
    }
    ```

    Any pointers to functions that do something similar that I can read as a point of reference,
    or any help in general on how to do this would be greatly appreciated!