From 2c7afc146c5987f64bb0352eb34396e680834982 Mon Sep 17 00:00:00 2001 From: pegasust Date: Wed, 9 Nov 2022 13:00:23 +0000 Subject: [PATCH] add fromYaml and stuff --- home-nix/flake.lock | 35 ++++++++---- home-nix/flake.nix | 22 ++++++-- home-nix/fromYamlSandbox/flake.nix | 87 ++++++++++++++++++++++++++++++ home-nix/home.nix | 8 ++- lib-nix/default.nix | 4 +- lib-nix/fromYaml | 1 - 6 files changed, 138 insertions(+), 19 deletions(-) delete mode 160000 lib-nix/fromYaml diff --git a/home-nix/flake.lock b/home-nix/flake.lock index 4849cac..9848659 100644 --- a/home-nix/flake.lock +++ b/home-nix/flake.lock @@ -45,6 +45,22 @@ "type": "github" } }, + "from-yaml": { + "flake": false, + "locked": { + "lastModified": 1667993187, + "narHash": "sha256-JG1XYGCmR7Jqawvs8AO4c2mrOl37BXGGgU9cfeL0b8k=", + "owner": "pegasust", + "repo": "fromYaml", + "rev": "ef0ed4acfc4a6b7a0f1515cb48f5dbdda89dac3c", + "type": "github" + }, + "original": { + "owner": "pegasust", + "repo": "fromYaml", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -53,11 +69,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1667708081, - "narHash": "sha256-FChEy05x4ed/pttjfTeKxjPCnHknMYrUtDyBiYbreT4=", + "lastModified": 1667981810, + "narHash": "sha256-p27zd5M+OkfND46gzbGkaHlNBZsYe95M48OJuFeuuSY=", "owner": "nix-community", "repo": "home-manager", - "rev": "1ef0da321217c6c19b7a30509631c080a19321e5", + "rev": "6ce3493a3c5c6a8f4cfa6f5f88723272e0cfd335", "type": "github" }, "original": { @@ -102,11 +118,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1667629849, - "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", + "lastModified": 1667811565, + "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62", + "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", "type": "github" }, "original": { @@ -135,6 +151,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "from-yaml": "from-yaml", "home-manager": "home-manager", "nixgl": "nixgl", "nixpkgs": "nixpkgs_2", @@ -147,11 +164,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1667943215, - "narHash": "sha256-FSD8RIL85Kbq3wVzxzYPuWkXtNaW/HldGpVVRDoPpnY=", + "lastModified": 1667962118, + "narHash": "sha256-RJi/HxlFxxJr1VeM3LLwrrRhiDGza+gphDMzt9QUS+M=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "01a89f997e49dd624c7f94813feceda63e91ee2e", + "rev": "91af035847a74cbd49ce9f764f8ef5fc641cb9b0", "type": "github" }, "original": { diff --git a/home-nix/flake.nix b/home-nix/flake.nix index 4972a3c..aa82f91 100644 --- a/home-nix/flake.nix +++ b/home-nix/flake.nix @@ -9,15 +9,27 @@ flake-utils.url = "github:numtide/flake-utils"; nixgl.url = "github:guibou/nixGL"; rust-overlay.url = "github:oxalica/rust-overlay"; + from-yaml = { + url = "github:pegasust/fromYaml"; + flake = false; + }; }; - outputs = { nixpkgs, home-manager, nixgl, rust-overlay, flake-utils, ... }: + outputs = + { nixpkgs + , home-manager + , nixgl + , rust-overlay + , flake-utils + , from-yaml + , ... + }: let system = "x86_64-linux"; overlays = [ nixgl.overlay rust-overlay.overlays.default ]; # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; pkgs = import nixpkgs { inherit system overlays; }; - lib = (import ../lib-nix { inherit pkgs; lib = pkgs.lib; }); + lib = (import ../lib-nix { inherit pkgs from-yaml; lib = pkgs.lib; }); in rec { inherit pkgs; @@ -31,7 +43,7 @@ # we migrate this from in-place modules to allow flexibility # in this case, we can add "home" to input arglist of home.nix extraSpecialArgs = { - inherit lib; + myLib = lib; myHome = { username = "nixos"; homeDirectory = "/home/nixos"; @@ -44,7 +56,7 @@ ./home.nix ]; extraSpecialArgs = { - # inherit lib; + myLib = lib; myHome = { username = "ubuntu_admin"; homeDirectory = "/home/ubuntu_admin"; @@ -57,7 +69,7 @@ ./home.nix ]; extraSpecialArgs = { - # inherit lib; + myLib = lib; myHome = { username = "hwtr"; homeDirectory = "/home/hwtr"; diff --git a/home-nix/fromYamlSandbox/flake.nix b/home-nix/fromYamlSandbox/flake.nix index c097de7..3525075 100644 --- a/home-nix/fromYamlSandbox/flake.nix +++ b/home-nix/fromYamlSandbox/flake.nix @@ -16,7 +16,94 @@ inherit nixpkgs; inherit from-yaml; inherit lib; + inherit pkgs; fromYamlFn = lib.fromYaml; + yamlCmd = str: (builtins.fromJSON(pkgs.runCommand "echo ${str} | yq")); + test_0 = '' + key_bindings: + - hello: + "N" + ''; + key_bind = '' +key_bindings: + - { key: N, mods: Control, action: CreateNewWindow } + # - { key: Paste, action: Paste } + # - { key: Copy, action: Copy } + #- { key: L, mods: Control, action: ClearLogNotice } + #- { key: L, mods: Control, mode: ~Vi|~Search, chars: "\x0c" } + #- { key: PageUp, mods: Shift, mode: ~Alt, action: ScrollPageUp } + #- { key: PageDown, mods: Shift, mode: ~Alt, action: ScrollPageDown } + #- { key: Home, mods: Shift, mode: ~Alt, action: ScrollToTop } + #- { key: End, mods: Shift, mode: ~Alt, action: ScrollToBottom } + + # Vi Mode + #- { key: Space, mods: Shift|Control, mode: ~Search, action: ToggleViMode } + - { key: Escape, mods: Shift, mode: ~Search, action: ToggleViMode } + #- { key: Space, mods: Shift|Control, mode: Vi|~Search, action: ScrollToBottom } + #- { key: Escape, mode: Vi|~Search, action: ClearSelection } + #- { key: I, mode: Vi|~Search, action: ToggleViMode } + #- { key: I, mode: Vi|~Search, action: ScrollToBottom } + #- { key: C, mods: Control, mode: Vi|~Search, action: ToggleViMode } + #- { key: Y, mods: Control, mode: Vi|~Search, action: ScrollLineUp } + #- { key: E, mods: Control, mode: Vi|~Search, action: ScrollLineDown } + #- { key: G, mode: Vi|~Search, action: ScrollToTop } + #- { key: G, mods: Shift, mode: Vi|~Search, action: ScrollToBottom } + #- { key: B, mods: Control, mode: Vi|~Search, action: ScrollPageUp } + #- { key: F, mods: Control, mode: Vi|~Search, action: ScrollPageDown } + #- { key: U, mods: Control, mode: Vi|~Search, action: ScrollHalfPageUp } + #- { key: D, mods: Control, mode: Vi|~Search, action: ScrollHalfPageDown } + #- { key: Y, mode: Vi|~Search, action: Copy } + #- { key: Y, mode: Vi|~Search, action: ClearSelection } + #- { key: Copy, mode: Vi|~Search, action: ClearSelection } + #- { key: V, mode: Vi|~Search, action: ToggleNormalSelection } + #- { key: V, mods: Shift, mode: Vi|~Search, action: ToggleLineSelection } + #- { key: V, mods: Control, mode: Vi|~Search, action: ToggleBlockSelection } + #- { key: V, mods: Alt, mode: Vi|~Search, action: ToggleSemanticSelection } + #- { key: Return, mode: Vi|~Search, action: Open } + #- { key: Z, mode: Vi|~Search, action: CenterAroundViCursor } + #- { key: K, mode: Vi|~Search, action: Up } + #- { key: J, mode: Vi|~Search, action: Down } + #- { key: H, mode: Vi|~Search, action: Left } + #- { key: L, mode: Vi|~Search, action: Right } + #- { key: Up, mode: Vi|~Search, action: Up } + #- { key: Down, mode: Vi|~Search, action: Down } + #- { key: Left, mode: Vi|~Search, action: Left } + #- { key: Right, mode: Vi|~Search, action: Right } + #- { key: Key0, mode: Vi|~Search, action: First } + #- { key: Key4, mods: Shift, mode: Vi|~Search, action: Last } + #- { key: Key6, mods: Shift, mode: Vi|~Search, action: FirstOccupied } + #- { key: H, mods: Shift, mode: Vi|~Search, action: High } + #- { key: M, mods: Shift, mode: Vi|~Search, action: Middle } + #- { key: L, mods: Shift, mode: Vi|~Search, action: Low } + #- { key: B, mode: Vi|~Search, action: SemanticLeft } + #- { key: W, mode: Vi|~Search, action: SemanticRight } + #- { key: E, mode: Vi|~Search, action: SemanticRightEnd } + #- { key: B, mods: Shift, mode: Vi|~Search, action: WordLeft } + #- { key: W, mods: Shift, mode: Vi|~Search, action: WordRight } + #- { key: E, mods: Shift, mode: Vi|~Search, action: WordRightEnd } + #- { key: Key5, mods: Shift, mode: Vi|~Search, action: Bracket } + #- { key: Slash, mode: Vi|~Search, action: SearchForward } + #- { key: Slash, mods: Shift, mode: Vi|~Search, action: SearchBackward } + #- { key: N, mode: Vi|~Search, action: SearchNext } + #- { key: N, mods: Shift, mode: Vi|~Search, action: SearchPrevious } + + # Search Mode + #- { key: Return, mode: Search|Vi, action: SearchConfirm } + #- { key: Escape, mode: Search, action: SearchCancel } + #- { key: C, mods: Control, mode: Search, action: SearchCancel } + #- { key: U, mods: Control, mode: Search, action: SearchClear } + #- { key: W, mods: Control, mode: Search, action: SearchDeleteWord } + #- { key: P, mods: Control, mode: Search, action: SearchHistoryPrevious } + #- { key: N, mods: Control, mode: Search, action: SearchHistoryNext } + #- { key: Up, mode: Search, action: SearchHistoryPrevious } + #- { key: Down, mode: Search, action: SearchHistoryNext } + #- { key: Return, mode: Search|~Vi, action: SearchFocusNext } + #- { key: Return, mods: Shift, mode: Search|~Vi, action: SearchFocusPrevious } + + # (Windows, Linux, and BSD only) + - { key: V, mods: Control|Shift, mode: ~Vi, action: Paste } + - { key: C, mods: Control|Shift, action: Copy } + ''; }; } diff --git a/home-nix/home.nix b/home-nix/home.nix index f9f16ee..d0b3ba6 100644 --- a/home-nix/home.nix +++ b/home-nix/home.nix @@ -2,7 +2,7 @@ { config , pkgs , myHome -# , lib +, myLib , ... }: { @@ -22,6 +22,7 @@ pkgs.nodejs-18_x pkgs.rust-analyzer pkgs.stdenv.cc.cc.lib + pkgs.yq ] ++ (myHome.packages or [ ]); nixpkgs.config.allowUnfree = true; @@ -30,9 +31,12 @@ xdg.configFile."starship.toml".text = builtins.readFile ../starship/starship.toml; ## Programs ## + programs.jq = { + enable = true; + }; programs.alacritty = myHome.programs.alacritty or { enable = true; - # settings = lib.fromYaml builtins.readFile ../alacritty/alacritty.yml; + # settings = myLib.fromYaml (builtins.readFile ../alacritty/alacritty.yml); }; programs.direnv = { enable = true; diff --git a/lib-nix/default.nix b/lib-nix/default.nix index 15541e9..7b11e9b 100644 --- a/lib-nix/default.nix +++ b/lib-nix/default.nix @@ -1,4 +1,4 @@ -{pkgs, lib, ...}@flake_import: +{pkgs, lib, from-yaml, ...}@flake_import: { - fromYaml = import ./fromYaml/fromYaml.nix {inherit lib;}; + fromYaml = import "${from-yaml}/fromYaml.nix" {inherit lib;}; } diff --git a/lib-nix/fromYaml b/lib-nix/fromYaml deleted file mode 160000 index f31858f..0000000 --- a/lib-nix/fromYaml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f31858f94e3f05d4982754eab0e1f427d1ca2497