Allow choosing between iwd and wpa_supplicant
This commit is contained in:
parent
0a2f22b0af
commit
c0a5d1f8cc
|
@ -1475,11 +1475,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-unstable": {
|
"nixpkgs-unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1720031269,
|
"lastModified": 1724819573,
|
||||||
"narHash": "sha256-rwz8NJZV+387rnWpTYcXaRNvzUSnnF9aHONoJIYmiUQ=",
|
"narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9f4128e00b0ae8ec65918efeba59db998750ead6",
|
"rev": "71e91c409d1e654808b2621f28a327acfdad8dc2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -150,6 +150,15 @@ in
|
||||||
type = "options";
|
type = "options";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"Home-manager options" = mkBasicSearchEngine {
|
||||||
|
aliases = [
|
||||||
|
"@hm"
|
||||||
|
"@home-manager"
|
||||||
|
];
|
||||||
|
param = "query";
|
||||||
|
url = "https://home-manager-options.extranix.com";
|
||||||
|
};
|
||||||
|
|
||||||
"Pursuit" = mkBasicSearchEngine {
|
"Pursuit" = mkBasicSearchEngine {
|
||||||
url = "https://pursuit.purescript.org/search";
|
url = "https://pursuit.purescript.org/search";
|
||||||
param = "q";
|
param = "q";
|
||||||
|
|
|
@ -38,8 +38,11 @@
|
||||||
"navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
"navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||||
"neoconf": { "branch": "main", "commit": "23f24edab5f78465a0bc3320678e038664b9aa6e" },
|
"neoconf": { "branch": "main", "commit": "23f24edab5f78465a0bc3320678e038664b9aa6e" },
|
||||||
"neodev": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
|
"neodev": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
|
||||||
|
"neotest": { "branch": "master", "commit": "6d6ad113f56edc7c3f2a77a0836ea8c1b955ebea" },
|
||||||
|
"neotest-haskell": { "branch": "master", "commit": "10cd953fb7c81de82ce8dc618e0614e0ab5fa1e3" },
|
||||||
"nui": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
|
"nui": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
|
||||||
"null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
"null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
||||||
|
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
|
||||||
"plenary": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
"plenary": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||||
"purescript": { "branch": "main", "commit": "82348352e6568fcc0385bd7c99a8ead3a479feea" },
|
"purescript": { "branch": "main", "commit": "82348352e6568fcc0385bd7c99a8ead3a479feea" },
|
||||||
"rust-tools": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" },
|
"rust-tools": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" },
|
||||||
|
|
|
@ -518,7 +518,7 @@ let
|
||||||
(nmap "<c-p>" "find_files" "File finder [p]alette")
|
(nmap "<c-p>" "find_files" "File finder [p]alette")
|
||||||
(nmap "<leader>d" "diagnostics" "[D]iagnostics")
|
(nmap "<leader>d" "diagnostics" "[D]iagnostics")
|
||||||
(nmap "<c-f>" "live_grep" "[F]ind in project")
|
(nmap "<c-f>" "live_grep" "[F]ind in project")
|
||||||
(nmap "<leader>t" "builtin" "[T]elescope pickers")
|
(nmap "<c-t>" "builtin" "[T]elescope pickers")
|
||||||
# {{{ Files by extension
|
# {{{ Files by extension
|
||||||
(findFilesByExtension "tx" "tex" "[t]ex")
|
(findFilesByExtension "tx" "tex" "[t]ex")
|
||||||
(findFilesByExtension "ts" "ts" "[t]ypescript")
|
(findFilesByExtension "ts" "ts" "[t]ypescript")
|
||||||
|
@ -643,8 +643,14 @@ let
|
||||||
# {{{ treesitter
|
# {{{ treesitter
|
||||||
treesitter = {
|
treesitter = {
|
||||||
# REASON: more grammars
|
# REASON: more grammars
|
||||||
# dir = upkgs.vimPlugins.nvim-treesitter.withAllGrammars;
|
dir = pkgs.symlinkJoin {
|
||||||
package = "nvim-treesitter/nvim-treesitter";
|
name = "treesitter-with-parsers";
|
||||||
|
paths = [
|
||||||
|
upkgs.vimPlugins.nvim-treesitter.withAllGrammars
|
||||||
|
upkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies
|
||||||
|
];
|
||||||
|
};
|
||||||
|
# package = "nvim-treesitter/nvim-treesitter";
|
||||||
main = "nvim-treesitter.configs";
|
main = "nvim-treesitter.configs";
|
||||||
|
|
||||||
dependencies.nix = [ pkgs.tree-sitter ];
|
dependencies.nix = [ pkgs.tree-sitter ];
|
||||||
|
@ -1218,6 +1224,43 @@ let
|
||||||
config = importFrom ./plugins/cmp.lua "config";
|
config = importFrom ./plugins/cmp.lua "config";
|
||||||
};
|
};
|
||||||
# }}}
|
# }}}
|
||||||
|
# {{{ neotest
|
||||||
|
neotest = {
|
||||||
|
package = "nvim-neotest/neotest";
|
||||||
|
dependencies.lua = [
|
||||||
|
# {{{ Adapters
|
||||||
|
"mrcjkb/neotest-haskell"
|
||||||
|
# }}}
|
||||||
|
"plenary"
|
||||||
|
"treesitter"
|
||||||
|
"nvim-neotest/nvim-nio"
|
||||||
|
];
|
||||||
|
|
||||||
|
cond = blacklist "vscode";
|
||||||
|
config = _: {
|
||||||
|
setup.neotest.adapters = [
|
||||||
|
(require "neotest-haskell" {
|
||||||
|
build_tools = [ "stack" ];
|
||||||
|
frameworks = [ "hspec" ];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# {{{ Keybinds
|
||||||
|
keys =
|
||||||
|
let
|
||||||
|
nmap =
|
||||||
|
key: arg: desc:
|
||||||
|
nlib.nmap "<leader>t${key}" (thunk "require('neotest').run.${arg}") desc;
|
||||||
|
in
|
||||||
|
[
|
||||||
|
(nmap "c" "run()" "Run [c]urrent [t]est")
|
||||||
|
(nmap "f" "run(vim.fn.expand('%'))" "Run [t]ests in [f]ile")
|
||||||
|
(nmap "s" "stop()" "Run [c]urrent [t]est")
|
||||||
|
];
|
||||||
|
# }}}
|
||||||
|
};
|
||||||
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ language support
|
# {{{ language support
|
||||||
# {{{ haskell support
|
# {{{ haskell support
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
# {{{ Set up my custom imperanence wrapper
|
# {{{ Set up my custom imperanenceo wrapper
|
||||||
satellite.persistence = {
|
satellite.persistence = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
@ -46,6 +46,9 @@
|
||||||
"${config.xdg.cacheHome}/ghcide"
|
"${config.xdg.cacheHome}/ghcide"
|
||||||
"${config.xdg.cacheHome}/cabal"
|
"${config.xdg.cacheHome}/cabal"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# TODO: should I move this in it's own haskell-specific file?
|
||||||
|
home.file.".stack/config.yaml".text = builtins.toJSON { notify-if-nix-on-path = false; };
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Nodejs
|
# {{{ Nodejs
|
||||||
satellite.persistence.at.cache.apps.nodejs = {
|
satellite.persistence.at.cache.apps.nodejs = {
|
||||||
|
@ -135,6 +138,12 @@
|
||||||
"${config.xdg.configHome}/Bitwarden"
|
"${config.xdg.configHome}/Bitwarden"
|
||||||
];
|
];
|
||||||
# }}}
|
# }}}
|
||||||
|
# {{{ Gnome keyring
|
||||||
|
services.gnome-keyring.enable = true;
|
||||||
|
satellite.persistence.at.state.apps.gnome-keyring.directories = [
|
||||||
|
"${config.xdg.dataHome}/keyrings"
|
||||||
|
];
|
||||||
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Cli
|
# {{{ Cli
|
||||||
# {{{ Sops
|
# {{{ Sops
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
# {{{ Imports
|
# {{{ Imports
|
||||||
imports = [
|
imports = [
|
||||||
../common/global
|
../common/global
|
||||||
../common/users/pilot.nix
|
|
||||||
|
|
||||||
|
../common/optional/users/pilot.nix
|
||||||
../common/optional/bluetooth.nix
|
../common/optional/bluetooth.nix
|
||||||
../common/optional/greetd.nix
|
../common/optional/greetd.nix
|
||||||
../common/optional/oci.nix
|
../common/optional/oci.nix
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
../common/optional/desktop/steam.nix
|
../common/optional/desktop/steam.nix
|
||||||
../common/optional/wayland/hyprland.nix
|
../common/optional/wayland/hyprland.nix
|
||||||
|
|
||||||
|
../common/optional/services/iwd.nix
|
||||||
../common/optional/services/kanata.nix
|
../common/optional/services/kanata.nix
|
||||||
../common/optional/services/nginx.nix
|
../common/optional/services/nginx.nix
|
||||||
../common/optional/services/syncthing.nix
|
../common/optional/services/syncthing.nix
|
||||||
|
|
|
@ -22,7 +22,6 @@ let
|
||||||
./unicode.nix
|
./unicode.nix
|
||||||
./persistence.nix
|
./persistence.nix
|
||||||
./ports.nix
|
./ports.nix
|
||||||
./wireless
|
|
||||||
|
|
||||||
../../../../common
|
../../../../common
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -48,11 +47,6 @@ in
|
||||||
# Boot using systemd
|
# Boot using systemd
|
||||||
boot.initrd.systemd.enable = true;
|
boot.initrd.systemd.enable = true;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Disable sudo default lecture
|
|
||||||
security.sudo.extraConfig = ''
|
|
||||||
Defaults lecture = never
|
|
||||||
'';
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
nixpkgs = {
|
nixpkgs = {
|
||||||
# Add all overlays defined in the overlays directory
|
# Add all overlays defined in the overlays directory
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
# See [the imperanence readme](https://github.com/nix-community/impermanence#home-manager)
|
# See [the imperanence readme](https://github.com/nix-community/impermanence#home-manager)
|
||||||
programs.fuse.userAllowOther = true;
|
programs.fuse.userAllowOther = true;
|
||||||
|
|
||||||
|
# {{{ Disable sudo default lecture
|
||||||
|
security.sudo.extraConfig = ''
|
||||||
|
Defaults lecture = never
|
||||||
|
'';
|
||||||
|
# }}}
|
||||||
# {{{ Create home directories
|
# {{{ Create home directories
|
||||||
systemd.tmpfiles.rules =
|
systemd.tmpfiles.rules =
|
||||||
let
|
let
|
||||||
|
|
12
hosts/nixos/common/optional/services/iwd.nix
Normal file
12
hosts/nixos/common/optional/services/iwd.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
networking.wireless.iwd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
IPv6.Enabled = true;
|
||||||
|
Settings.AutoConnect = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.persistence."/persist/state".directories = [ "/var/lib/iwd" ];
|
||||||
|
}
|
4
hosts/nixos/common/optional/users/common.nix
Normal file
4
hosts/nixos/common/optional/users/common.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
authorizedKeys = { outputs, lib }:
|
||||||
|
|
||||||
|
}
|
23
hosts/nixos/common/optional/users/guest.nix
Normal file
23
hosts/nixos/common/optional/users/guest.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# For more comments check out [pilot](./pilot.nix)
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
outputs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
users.mutableUsers = false;
|
||||||
|
users.users.guest = {
|
||||||
|
isNormalUser = true;
|
||||||
|
shell = pkgs.fish;
|
||||||
|
extraGroups = [
|
||||||
|
"wheel"
|
||||||
|
"audio"
|
||||||
|
"video"
|
||||||
|
"network"
|
||||||
|
"tty"
|
||||||
|
];
|
||||||
|
password = "heyo";
|
||||||
|
openssh.authorizedKeys.keyFiles = (import ./common.nix).authorizedKeys { inherit outputs lib; };
|
||||||
|
};
|
||||||
|
}
|
|
@ -47,7 +47,26 @@
|
||||||
hashedPasswordFile = config.sops.secrets.pilot_password.path;
|
hashedPasswordFile = config.sops.secrets.pilot_password.path;
|
||||||
shell = pkgs.fish;
|
shell = pkgs.fish;
|
||||||
|
|
||||||
openssh.authorizedKeys.keyFiles = (import ./common.nix).authorizedKeys { inherit outputs lib; };
|
# {{{ Authorize ssh keys
|
||||||
|
openssh.authorizedKeys.keyFiles =
|
||||||
|
let
|
||||||
|
# Record containing all the hosts
|
||||||
|
hosts = outputs.nixosConfigurations;
|
||||||
|
|
||||||
|
# Function from hostname to relative path to public ssh key
|
||||||
|
idKey = host: ../../${host}/keys/id_ed25519.pub;
|
||||||
|
in
|
||||||
|
lib.pipe hosts [
|
||||||
|
# attrsetof host -> attrsetof path
|
||||||
|
(builtins.mapAttrs (name: _: idKey name)) # string -> host -> path
|
||||||
|
|
||||||
|
# attrsetof path -> path[]
|
||||||
|
builtins.attrValues
|
||||||
|
|
||||||
|
# path[] -> path[]
|
||||||
|
(builtins.filter builtins.pathExists)
|
||||||
|
];
|
||||||
|
# }}}
|
||||||
};
|
};
|
||||||
# }}}
|
# }}}
|
||||||
};
|
};
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
authorizedKeys = { outputs, lib }:
|
|
||||||
let
|
|
||||||
# Record containing all the hosts
|
|
||||||
hosts = outputs.nixosConfigurations;
|
|
||||||
|
|
||||||
# Function from hostname to relative path to public ssh key
|
|
||||||
idKey = host: ../../${host}/keys/id_ed25519.pub;
|
|
||||||
in
|
|
||||||
lib.pipe hosts [
|
|
||||||
# attrsetof host -> attrsetof path
|
|
||||||
(builtins.mapAttrs
|
|
||||||
(name: _: idKey name)) # string -> host -> path
|
|
||||||
|
|
||||||
# attrsetof path -> path[]
|
|
||||||
builtins.attrValues
|
|
||||||
|
|
||||||
# path[] -> path[]
|
|
||||||
(builtins.filter builtins.pathExists)
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
# For more comments check out [pilot](./pilot.nix)
|
|
||||||
{ pkgs, outputs, lib, ... }:
|
|
||||||
{
|
|
||||||
users.mutableUsers = false;
|
|
||||||
users.users.guest = {
|
|
||||||
isNormalUser = true;
|
|
||||||
shell = pkgs.fish;
|
|
||||||
extraGroups = [ "wheel" "audio" "video" "network" "tty" ];
|
|
||||||
password = "heyo";
|
|
||||||
openssh.authorizedKeys.keyFiles =
|
|
||||||
(import ./common.nix).authorizedKeys { inherit outputs lib; };
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
inputs.sops-nix.nixosModules.sops
|
inputs.sops-nix.nixosModules.sops
|
||||||
|
|
||||||
../common/global/wireless
|
|
||||||
../common/global/cli/fish.nix
|
../common/global/cli/fish.nix
|
||||||
|
../common/optional/services/wpa_supplicant.nix
|
||||||
../common/optional/services/kanata.nix
|
../common/optional/services/kanata.nix
|
||||||
];
|
];
|
||||||
# }}}
|
# }}}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# {{{ Imports
|
# {{{ Imports
|
||||||
imports = [
|
imports = [
|
||||||
../common/global
|
../common/global
|
||||||
../common/users/pilot.nix
|
../common/optional/users/pilot.nix
|
||||||
../common/optional/oci.nix
|
../common/optional/oci.nix
|
||||||
../common/optional/services/tailscale.nix
|
../common/optional/services/tailscale.nix
|
||||||
../common/optional/services/acme.nix
|
../common/optional/services/acme.nix
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
../common/optional/services/postgres.nix
|
../common/optional/services/postgres.nix
|
||||||
../common/optional/services/syncthing.nix
|
../common/optional/services/syncthing.nix
|
||||||
../common/optional/services/restic
|
../common/optional/services/restic
|
||||||
|
../common/optional/services/wpa_supplicant.nix
|
||||||
|
|
||||||
# ./services/commafeed.nix
|
# ./services/commafeed.nix
|
||||||
# ./services/ddclient.nix
|
# ./services/ddclient.nix
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
# {{{ Imports
|
# {{{ Imports
|
||||||
imports = [
|
imports = [
|
||||||
../common/global
|
../common/global
|
||||||
../common/users/pilot.nix
|
|
||||||
|
|
||||||
|
../common/optional/users/pilot.nix
|
||||||
../common/optional/bluetooth.nix
|
../common/optional/bluetooth.nix
|
||||||
../common/optional/greetd.nix
|
../common/optional/greetd.nix
|
||||||
../common/optional/oci.nix
|
../common/optional/oci.nix
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
../common/optional/desktop/steam.nix
|
../common/optional/desktop/steam.nix
|
||||||
../common/optional/wayland/hyprland.nix
|
../common/optional/wayland/hyprland.nix
|
||||||
|
|
||||||
|
../common/optional/services/wpa_supplicant.nix
|
||||||
../common/optional/services/tailscale.nix
|
../common/optional/services/tailscale.nix
|
||||||
../common/optional/services/kanata.nix
|
../common/optional/services/kanata.nix
|
||||||
../common/optional/services/restic
|
../common/optional/services/restic
|
||||||
|
|
|
@ -3,178 +3,266 @@ let
|
||||||
e = import ./korora-lua.nix attrs;
|
e = import ./korora-lua.nix attrs;
|
||||||
k = korora;
|
k = korora;
|
||||||
h = e.helpers;
|
h = e.helpers;
|
||||||
struct = name: props: verify: (k.struct name props).override {
|
struct =
|
||||||
total = false;
|
name: props: verify:
|
||||||
unknown = false;
|
(k.struct name props).override {
|
||||||
verify = h.mkVerify verify;
|
total = false;
|
||||||
};
|
unknown = false;
|
||||||
|
verify = h.mkVerify verify;
|
||||||
|
};
|
||||||
|
|
||||||
lazyType = name: mkType: k.typedef' name (v: (mkType true).verify v);
|
lazyType = name: mkType: k.typedef' name (v: (mkType true).verify v);
|
||||||
|
|
||||||
types = {
|
types = {
|
||||||
# {{{ Helper types
|
# {{{ Helper types
|
||||||
oneOrMany = type: k.union [ type (k.listOf type) ];
|
oneOrMany =
|
||||||
|
type:
|
||||||
|
k.union [
|
||||||
|
type
|
||||||
|
(k.listOf type)
|
||||||
|
];
|
||||||
luaValue = k.any;
|
luaValue = k.any;
|
||||||
strictLuaLiteral = (k.struct "lua literal" {
|
strictLuaLiteral =
|
||||||
value = k.string;
|
(k.struct "lua literal" {
|
||||||
__luaEncoderTag = k.enum "lua literal tag" [ "lua" ];
|
value = k.string;
|
||||||
}).override { unknown = true; };
|
__luaEncoderTag = k.enum "lua literal tag" [ "lua" ];
|
||||||
|
}).override
|
||||||
|
{ unknown = true; };
|
||||||
derivation = k.typedef "derivation" lib.isDerivation;
|
derivation = k.typedef "derivation" lib.isDerivation;
|
||||||
path = k.typedef "path" lib.isPath;
|
path = k.typedef "path" lib.isPath;
|
||||||
functionCheckedWith = arg: type:
|
functionCheckedWith =
|
||||||
k.typedef'
|
arg: type:
|
||||||
"${h.toPretty arg} -> ${type.name}"
|
k.typedef' "${h.toPretty arg} -> ${type.name}" (
|
||||||
(f:
|
f:
|
||||||
if lib.isFunction f
|
if lib.isFunction f then
|
||||||
then type.verify (f arg)
|
type.verify (f arg)
|
||||||
else "Expected function, but got ${h.toPretty f} instead");
|
else
|
||||||
luaEagerOrLazy = type: k.union [ type (types.functionCheckedWith "" type) ];
|
"Expected function, but got ${h.toPretty f} instead"
|
||||||
|
);
|
||||||
|
luaEagerOrLazy =
|
||||||
|
type:
|
||||||
|
k.union [
|
||||||
|
type
|
||||||
|
(types.functionCheckedWith "" type)
|
||||||
|
];
|
||||||
luaLiteral = types.luaEagerOrLazy types.strictLuaLiteral;
|
luaLiteral = types.luaEagerOrLazy types.strictLuaLiteral;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Lazy key
|
# {{{ Lazy key
|
||||||
lazyKey = struct "lazy key"
|
lazyKey = struct "lazy key" {
|
||||||
{
|
mapping = k.string;
|
||||||
mapping = k.string;
|
action = k.union [
|
||||||
action = k.union [ types.luaLiteral k.string ];
|
types.luaLiteral
|
||||||
mode = k.string;
|
k.string
|
||||||
desc = k.string;
|
];
|
||||||
expr = k.bool;
|
mode = k.string;
|
||||||
ft = types.oneOrMany k.string;
|
desc = k.string;
|
||||||
}
|
expr = k.bool;
|
||||||
[ (h.propExists "mapping") ];
|
ft = types.oneOrMany k.string;
|
||||||
|
} [ (h.propExists "mapping") ];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Lazy module
|
# {{{ Lazy module
|
||||||
lazyModule = lazyType "actually lazy lazy module" (_: struct "lazy module"
|
lazyModule = lazyType "actually lazy lazy module" (
|
||||||
{
|
_:
|
||||||
package = k.string;
|
struct "lazy module"
|
||||||
dir = k.union [ k.string types.derivation types.path ];
|
{
|
||||||
version = k.string;
|
package = k.string;
|
||||||
tag = k.string;
|
dir = k.union [
|
||||||
name = k.string;
|
k.string
|
||||||
main = k.string;
|
types.derivation
|
||||||
lazy = k.bool;
|
types.path
|
||||||
dependencies = struct "lazy dependencies"
|
];
|
||||||
{
|
version = k.string;
|
||||||
lua = k.listOf (k.union [ k.string types.lazyModule ]);
|
tag = k.string;
|
||||||
|
name = k.string;
|
||||||
|
main = k.string;
|
||||||
|
lazy = k.bool;
|
||||||
|
dependencies = struct "lazy dependencies" {
|
||||||
|
lua = k.listOf (
|
||||||
|
k.union [
|
||||||
|
k.string
|
||||||
|
types.lazyModule
|
||||||
|
]
|
||||||
|
);
|
||||||
nix = k.listOf types.derivation;
|
nix = k.listOf types.derivation;
|
||||||
}
|
} [ ];
|
||||||
[ ];
|
cond = types.oneOrMany types.luaLiteral;
|
||||||
cond = types.oneOrMany types.luaLiteral;
|
init = types.luaEagerOrLazy (
|
||||||
init = k.union [ types.luaLiteral types.tempestConfig ];
|
k.union [
|
||||||
config = k.union [ types.luaLiteral k.bool types.tempestConfig ];
|
types.strictLuaLiteral
|
||||||
event = types.oneOrMany k.string;
|
types.strictTempestConfig
|
||||||
cmd = types.oneOrMany k.string;
|
]
|
||||||
ft = types.oneOrMany k.string;
|
);
|
||||||
keys = types.oneOrMany (k.union [ k.string types.lazyKey ]);
|
config = k.union [
|
||||||
passthrough = types.luaValue;
|
k.bool
|
||||||
opts = types.luaValue;
|
(types.luaEagerOrLazy (
|
||||||
}
|
k.union [
|
||||||
[
|
types.strictLuaLiteral
|
||||||
(h.propOnlyOne [ "dir" "package" ])
|
types.strictTempestConfig
|
||||||
(h.propImplies "tag" "package")
|
]
|
||||||
(h.propImplies "version" "package")
|
))
|
||||||
]);
|
];
|
||||||
|
event = types.oneOrMany k.string;
|
||||||
|
cmd = types.oneOrMany k.string;
|
||||||
|
ft = types.oneOrMany k.string;
|
||||||
|
keys = types.oneOrMany (
|
||||||
|
k.union [
|
||||||
|
k.string
|
||||||
|
types.lazyKey
|
||||||
|
]
|
||||||
|
);
|
||||||
|
passthrough = types.luaValue;
|
||||||
|
opts = types.luaValue;
|
||||||
|
}
|
||||||
|
[
|
||||||
|
(h.propOnlyOne [
|
||||||
|
"dir"
|
||||||
|
"package"
|
||||||
|
])
|
||||||
|
(h.propImplies "tag" "package")
|
||||||
|
(h.propImplies "version" "package")
|
||||||
|
]
|
||||||
|
);
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Tempest key
|
# {{{ Tempest key
|
||||||
tempestKey = struct "tempest key"
|
tempestKey =
|
||||||
{
|
struct "tempest key"
|
||||||
mapping = k.string;
|
{
|
||||||
action = k.union [ types.luaLiteral k.string ];
|
mapping = k.string;
|
||||||
mode = k.string;
|
action = k.union [
|
||||||
desc = k.string;
|
types.luaLiteral
|
||||||
expr = k.bool;
|
k.string
|
||||||
silent = k.bool;
|
];
|
||||||
ft = types.oneOrMany k.string;
|
mode = k.string;
|
||||||
buffer = k.union [ k.bool k.number types.luaLiteral ];
|
desc = k.string;
|
||||||
}
|
expr = k.bool;
|
||||||
[
|
silent = k.bool;
|
||||||
(h.propExists "mapping")
|
ft = types.oneOrMany k.string;
|
||||||
(h.propExists "action")
|
buffer = k.union [
|
||||||
];
|
k.bool
|
||||||
|
k.number
|
||||||
|
types.luaLiteral
|
||||||
|
];
|
||||||
|
}
|
||||||
|
[
|
||||||
|
(h.propExists "mapping")
|
||||||
|
(h.propExists "action")
|
||||||
|
];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Tempest autocmd
|
# {{{ Tempest autocmd
|
||||||
tempestAutocmd = struct "tempest autocommand"
|
tempestAutocmd =
|
||||||
{
|
struct "tempest autocommand"
|
||||||
event = types.oneOrMany k.string;
|
{
|
||||||
pattern = types.oneOrMany k.string;
|
event = types.oneOrMany k.string;
|
||||||
group = k.string;
|
pattern = types.oneOrMany k.string;
|
||||||
action = k.union [ types.tempestConfig types.luaLiteral ];
|
group = k.string;
|
||||||
}
|
action = k.union [
|
||||||
[
|
types.tempestConfig
|
||||||
(h.propExists "event")
|
types.luaLiteral
|
||||||
(h.propExists "group")
|
];
|
||||||
(h.propExists "action")
|
}
|
||||||
];
|
[
|
||||||
|
(h.propExists "event")
|
||||||
|
(h.propExists "group")
|
||||||
|
(h.propExists "action")
|
||||||
|
];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Tempest config
|
# {{{ Tempest config
|
||||||
tempestConfig = lazyType "lazy tempest config" (_: struct "tempest config"
|
strictTempestConfig = struct "tempest config" {
|
||||||
{
|
vim = types.luaValue;
|
||||||
vim = types.luaValue;
|
callback = k.union [
|
||||||
callback = k.union [ types.luaLiteral types.tempestConfig ];
|
types.luaLiteral
|
||||||
setup = k.attrsOf types.luaValue;
|
types.tempestConfig
|
||||||
keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey);
|
];
|
||||||
autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd);
|
setup = k.attrsOf types.luaValue;
|
||||||
mkContext = types.luaValue;
|
keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey);
|
||||||
cond = types.oneOrMany types.luaLiteral;
|
autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd);
|
||||||
}
|
mkContext = types.luaValue;
|
||||||
[ ]);
|
cond = types.oneOrMany types.luaLiteral;
|
||||||
|
} [ ];
|
||||||
|
|
||||||
|
tempestConfig = lazyType "lazy tempest config" (_: types.strictTempestConfig);
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Neovim env
|
# {{{ Neovim env
|
||||||
neovimEnv = k.enum "neovim env"
|
neovimEnv = k.enum "neovim env" [
|
||||||
[ "neovide" "firenvim" "vscode" ];
|
"neovide"
|
||||||
|
"firenvim"
|
||||||
|
"vscode"
|
||||||
|
];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Neovim config
|
# {{{ Neovim config
|
||||||
neovimConfig = struct "neovim configuration"
|
neovimConfig = struct "neovim configuration" {
|
||||||
{
|
pre = k.attrsOf types.tempestConfig;
|
||||||
pre = k.attrsOf types.tempestConfig;
|
lazy = k.attrsOf types.lazyModule;
|
||||||
lazy = k.attrsOf types.lazyModule;
|
post = k.attrsOf types.tempestConfig;
|
||||||
post = k.attrsOf types.tempestConfig;
|
} [ ];
|
||||||
} [ ];
|
|
||||||
# }}}
|
# }}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mkLib = { tempestModule }:
|
mkLib =
|
||||||
|
{ tempestModule }:
|
||||||
assert h.hasType k.string tempestModule;
|
assert h.hasType k.string tempestModule;
|
||||||
rec {
|
rec {
|
||||||
inherit (e) encode;
|
inherit (e) encode;
|
||||||
inherit (h) lua;
|
inherit (h) lua;
|
||||||
|
|
||||||
# {{{ Common generation helpers
|
# {{{ Common generation helpers
|
||||||
importFrom = path: tag:
|
importFrom =
|
||||||
|
path: tag:
|
||||||
assert lib.isPath path;
|
assert lib.isPath path;
|
||||||
assert h.hasType k.string tag;
|
assert h.hasType k.string tag;
|
||||||
lua "dofile(${encode (toString path)}).${tag}";
|
lua "dofile(${encode (toString path)}).${tag}";
|
||||||
foldedList = value: assert h.hasType k.attrs value;
|
foldedList =
|
||||||
{ inherit value; __luaEncoderTag = "foldedList"; };
|
value:
|
||||||
|
assert h.hasType k.attrs value;
|
||||||
|
{
|
||||||
|
inherit value;
|
||||||
|
__luaEncoderTag = "foldedList";
|
||||||
|
};
|
||||||
thunk = code: _: lua code;
|
thunk = code: _: lua code;
|
||||||
tempest = given: context: lua ''
|
require = module: lua "require(${module})";
|
||||||
D.tempest.configure(
|
tempest =
|
||||||
${encode given},
|
given: context:
|
||||||
${context}
|
lua ''
|
||||||
)
|
D.tempest.configure(
|
||||||
'';
|
|
||||||
tempestBufnr = given: lua ''
|
|
||||||
function(_, bufnr)
|
|
||||||
return D.tempest.configure(
|
|
||||||
${encode given},
|
${encode given},
|
||||||
{ bufnr = bufnr}
|
${context}
|
||||||
)
|
)
|
||||||
end
|
'';
|
||||||
'';
|
tempestBufnr =
|
||||||
keymap = mode: mapping: action: desc:
|
given:
|
||||||
{ inherit mode mapping action desc; };
|
lua ''
|
||||||
nmap = mapping: action: desc:
|
function(_, bufnr)
|
||||||
{ inherit mapping action desc; };
|
return D.tempest.configure(
|
||||||
unmap = mapping:
|
${encode given},
|
||||||
{ inherit mapping; action = "<nop>"; };
|
{ bufnr = bufnr}
|
||||||
blacklist = given:
|
)
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
keymap = mode: mapping: action: desc: {
|
||||||
|
inherit
|
||||||
|
mode
|
||||||
|
mapping
|
||||||
|
action
|
||||||
|
desc
|
||||||
|
;
|
||||||
|
};
|
||||||
|
nmap = mapping: action: desc: { inherit mapping action desc; };
|
||||||
|
unmap = mapping: {
|
||||||
|
inherit mapping;
|
||||||
|
action = "<nop>";
|
||||||
|
};
|
||||||
|
blacklist =
|
||||||
|
given:
|
||||||
assert h.hasType (types.oneOrMany types.neovimEnv) given;
|
assert h.hasType (types.oneOrMany types.neovimEnv) given;
|
||||||
lua /* lua */ ''
|
# lua
|
||||||
|
lua ''
|
||||||
D.tempest.blacklist(${encode given})
|
D.tempest.blacklist(${encode given})
|
||||||
'';
|
'';
|
||||||
whitelist = given:
|
whitelist =
|
||||||
|
given:
|
||||||
assert h.hasType (types.oneOrMany types.neovimEnv) given;
|
assert h.hasType (types.oneOrMany types.neovimEnv) given;
|
||||||
lua /* lua */ ''
|
# lua
|
||||||
|
lua ''
|
||||||
D.tempest.whitelist(${encode given})
|
D.tempest.whitelist(${encode given})
|
||||||
'';
|
'';
|
||||||
# :p => expands path
|
# :p => expands path
|
||||||
|
@ -182,11 +270,17 @@ let
|
||||||
notmp = lua ''vim.fn.expand("%:p:h") ~= "/tmp"'';
|
notmp = lua ''vim.fn.expand("%:p:h") ~= "/tmp"'';
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Main config generation entrypoint
|
# {{{ Main config generation entrypoint
|
||||||
generateConfig = rawConfig:
|
generateConfig =
|
||||||
|
rawConfig:
|
||||||
assert h.hasType types.neovimConfig rawConfig;
|
assert h.hasType types.neovimConfig rawConfig;
|
||||||
let
|
let
|
||||||
config = { lazy = { }; pre = { }; post = { }; } // rawConfig;
|
config = {
|
||||||
collectNixDeps = lazyModule:
|
lazy = { };
|
||||||
|
pre = { };
|
||||||
|
post = { };
|
||||||
|
} // rawConfig;
|
||||||
|
collectNixDeps =
|
||||||
|
lazyModule:
|
||||||
if lazyModule ? dependencies then
|
if lazyModule ? dependencies then
|
||||||
let
|
let
|
||||||
nix = lazyModule.dependencies.nix or [ ];
|
nix = lazyModule.dependencies.nix or [ ];
|
||||||
|
@ -202,12 +296,10 @@ let
|
||||||
(lib.mapAttrsToList (_: collectNixDeps))
|
(lib.mapAttrsToList (_: collectNixDeps))
|
||||||
lib.lists.flatten
|
lib.lists.flatten
|
||||||
];
|
];
|
||||||
processedLazyModules =
|
processedLazyModules = lib.mapAttrs (
|
||||||
lib.mapAttrs
|
name: module:
|
||||||
(name: module: { inherit name; } // module // {
|
{ inherit name; } // module // { dependencies = (module.dependencies or { }).lua or null; }
|
||||||
dependencies = (module.dependencies or { }).lua or null;
|
) config.lazy;
|
||||||
})
|
|
||||||
config.lazy;
|
|
||||||
|
|
||||||
luaConfig = ''
|
luaConfig = ''
|
||||||
local M = {}
|
local M = {}
|
||||||
|
@ -218,7 +310,7 @@ let
|
||||||
-- {{{ Pre-plugin config
|
-- {{{ Pre-plugin config
|
||||||
M.pre = ${encode (foldedList config.pre)}
|
M.pre = ${encode (foldedList config.pre)}
|
||||||
-- }}}
|
-- }}}
|
||||||
-- {{{ Lazy modules
|
-- {{{ Lazy modules
|
||||||
M.lazy = ${encode (foldedList processedLazyModules)}
|
M.lazy = ${encode (foldedList processedLazyModules)}
|
||||||
D.tempest.prepareLazySpec(M.lazy)
|
D.tempest.prepareLazySpec(M.lazy)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
@ -229,7 +321,10 @@ let
|
||||||
return M
|
return M
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{ inherit dependencies; lua = luaConfig; };
|
{
|
||||||
|
inherit dependencies;
|
||||||
|
lua = luaConfig;
|
||||||
|
};
|
||||||
# }}}
|
# }}}
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in a new issue