Allow choosing between iwd and wpa_supplicant
This commit is contained in:
parent
0a2f22b0af
commit
c0a5d1f8cc
|
@ -1475,11 +1475,11 @@
|
|||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1720031269,
|
||||
"narHash": "sha256-rwz8NJZV+387rnWpTYcXaRNvzUSnnF9aHONoJIYmiUQ=",
|
||||
"lastModified": 1724819573,
|
||||
"narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f4128e00b0ae8ec65918efeba59db998750ead6",
|
||||
"rev": "71e91c409d1e654808b2621f28a327acfdad8dc2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -150,6 +150,15 @@ in
|
|||
type = "options";
|
||||
};
|
||||
|
||||
"Home-manager options" = mkBasicSearchEngine {
|
||||
aliases = [
|
||||
"@hm"
|
||||
"@home-manager"
|
||||
];
|
||||
param = "query";
|
||||
url = "https://home-manager-options.extranix.com";
|
||||
};
|
||||
|
||||
"Pursuit" = mkBasicSearchEngine {
|
||||
url = "https://pursuit.purescript.org/search";
|
||||
param = "q";
|
||||
|
|
|
@ -38,8 +38,11 @@
|
|||
"navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||
"neoconf": { "branch": "main", "commit": "23f24edab5f78465a0bc3320678e038664b9aa6e" },
|
||||
"neodev": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
|
||||
"neotest": { "branch": "master", "commit": "6d6ad113f56edc7c3f2a77a0836ea8c1b955ebea" },
|
||||
"neotest-haskell": { "branch": "master", "commit": "10cd953fb7c81de82ce8dc618e0614e0ab5fa1e3" },
|
||||
"nui": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
|
||||
"null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
||||
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
|
||||
"plenary": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||
"purescript": { "branch": "main", "commit": "82348352e6568fcc0385bd7c99a8ead3a479feea" },
|
||||
"rust-tools": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" },
|
||||
|
|
|
@ -518,7 +518,7 @@ let
|
|||
(nmap "<c-p>" "find_files" "File finder [p]alette")
|
||||
(nmap "<leader>d" "diagnostics" "[D]iagnostics")
|
||||
(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
|
||||
(findFilesByExtension "tx" "tex" "[t]ex")
|
||||
(findFilesByExtension "ts" "ts" "[t]ypescript")
|
||||
|
@ -643,8 +643,14 @@ let
|
|||
# {{{ treesitter
|
||||
treesitter = {
|
||||
# REASON: more grammars
|
||||
# dir = upkgs.vimPlugins.nvim-treesitter.withAllGrammars;
|
||||
package = "nvim-treesitter/nvim-treesitter";
|
||||
dir = pkgs.symlinkJoin {
|
||||
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";
|
||||
|
||||
dependencies.nix = [ pkgs.tree-sitter ];
|
||||
|
@ -1218,6 +1224,43 @@ let
|
|||
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
|
||||
# {{{ haskell support
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
# {{{ Set up my custom imperanence wrapper
|
||||
# {{{ Set up my custom imperanenceo wrapper
|
||||
satellite.persistence = {
|
||||
enable = true;
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
|||
"${config.xdg.cacheHome}/ghcide"
|
||||
"${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
|
||||
satellite.persistence.at.cache.apps.nodejs = {
|
||||
|
@ -135,6 +138,12 @@
|
|||
"${config.xdg.configHome}/Bitwarden"
|
||||
];
|
||||
# }}}
|
||||
# {{{ Gnome keyring
|
||||
services.gnome-keyring.enable = true;
|
||||
satellite.persistence.at.state.apps.gnome-keyring.directories = [
|
||||
"${config.xdg.dataHome}/keyrings"
|
||||
];
|
||||
# }}}
|
||||
# }}}
|
||||
# {{{ Cli
|
||||
# {{{ Sops
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# {{{ Imports
|
||||
imports = [
|
||||
../common/global
|
||||
../common/users/pilot.nix
|
||||
|
||||
../common/optional/users/pilot.nix
|
||||
../common/optional/bluetooth.nix
|
||||
../common/optional/greetd.nix
|
||||
../common/optional/oci.nix
|
||||
|
@ -17,6 +17,7 @@
|
|||
../common/optional/desktop/steam.nix
|
||||
../common/optional/wayland/hyprland.nix
|
||||
|
||||
../common/optional/services/iwd.nix
|
||||
../common/optional/services/kanata.nix
|
||||
../common/optional/services/nginx.nix
|
||||
../common/optional/services/syncthing.nix
|
||||
|
|
|
@ -22,7 +22,6 @@ let
|
|||
./unicode.nix
|
||||
./persistence.nix
|
||||
./ports.nix
|
||||
./wireless
|
||||
|
||||
../../../../common
|
||||
# }}}
|
||||
|
@ -48,11 +47,6 @@ in
|
|||
# Boot using systemd
|
||||
boot.initrd.systemd.enable = true;
|
||||
# }}}
|
||||
# {{{ Disable sudo default lecture
|
||||
security.sudo.extraConfig = ''
|
||||
Defaults lecture = never
|
||||
'';
|
||||
# }}}
|
||||
|
||||
nixpkgs = {
|
||||
# Add all overlays defined in the overlays directory
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
# See [the imperanence readme](https://github.com/nix-community/impermanence#home-manager)
|
||||
programs.fuse.userAllowOther = true;
|
||||
|
||||
# {{{ Disable sudo default lecture
|
||||
security.sudo.extraConfig = ''
|
||||
Defaults lecture = never
|
||||
'';
|
||||
# }}}
|
||||
# {{{ Create home directories
|
||||
systemd.tmpfiles.rules =
|
||||
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;
|
||||
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
|
||||
|
||||
../common/global/wireless
|
||||
../common/global/cli/fish.nix
|
||||
../common/optional/services/wpa_supplicant.nix
|
||||
../common/optional/services/kanata.nix
|
||||
];
|
||||
# }}}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# {{{ Imports
|
||||
imports = [
|
||||
../common/global
|
||||
../common/users/pilot.nix
|
||||
../common/optional/users/pilot.nix
|
||||
../common/optional/oci.nix
|
||||
../common/optional/services/tailscale.nix
|
||||
../common/optional/services/acme.nix
|
||||
|
@ -15,6 +15,7 @@
|
|||
../common/optional/services/postgres.nix
|
||||
../common/optional/services/syncthing.nix
|
||||
../common/optional/services/restic
|
||||
../common/optional/services/wpa_supplicant.nix
|
||||
|
||||
# ./services/commafeed.nix
|
||||
# ./services/ddclient.nix
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# {{{ Imports
|
||||
imports = [
|
||||
../common/global
|
||||
../common/users/pilot.nix
|
||||
|
||||
../common/optional/users/pilot.nix
|
||||
../common/optional/bluetooth.nix
|
||||
../common/optional/greetd.nix
|
||||
../common/optional/oci.nix
|
||||
|
@ -17,6 +17,7 @@
|
|||
../common/optional/desktop/steam.nix
|
||||
../common/optional/wayland/hyprland.nix
|
||||
|
||||
../common/optional/services/wpa_supplicant.nix
|
||||
../common/optional/services/tailscale.nix
|
||||
../common/optional/services/kanata.nix
|
||||
../common/optional/services/restic
|
||||
|
|
|
@ -3,178 +3,266 @@ let
|
|||
e = import ./korora-lua.nix attrs;
|
||||
k = korora;
|
||||
h = e.helpers;
|
||||
struct = name: props: verify: (k.struct name props).override {
|
||||
total = false;
|
||||
unknown = false;
|
||||
verify = h.mkVerify verify;
|
||||
};
|
||||
struct =
|
||||
name: props: verify:
|
||||
(k.struct name props).override {
|
||||
total = false;
|
||||
unknown = false;
|
||||
verify = h.mkVerify verify;
|
||||
};
|
||||
|
||||
lazyType = name: mkType: k.typedef' name (v: (mkType true).verify v);
|
||||
|
||||
types = {
|
||||
# {{{ Helper types
|
||||
oneOrMany = type: k.union [ type (k.listOf type) ];
|
||||
oneOrMany =
|
||||
type:
|
||||
k.union [
|
||||
type
|
||||
(k.listOf type)
|
||||
];
|
||||
luaValue = k.any;
|
||||
strictLuaLiteral = (k.struct "lua literal" {
|
||||
value = k.string;
|
||||
__luaEncoderTag = k.enum "lua literal tag" [ "lua" ];
|
||||
}).override { unknown = true; };
|
||||
strictLuaLiteral =
|
||||
(k.struct "lua literal" {
|
||||
value = k.string;
|
||||
__luaEncoderTag = k.enum "lua literal tag" [ "lua" ];
|
||||
}).override
|
||||
{ unknown = true; };
|
||||
derivation = k.typedef "derivation" lib.isDerivation;
|
||||
path = k.typedef "path" lib.isPath;
|
||||
functionCheckedWith = arg: type:
|
||||
k.typedef'
|
||||
"${h.toPretty arg} -> ${type.name}"
|
||||
(f:
|
||||
if lib.isFunction f
|
||||
then type.verify (f arg)
|
||||
else "Expected function, but got ${h.toPretty f} instead");
|
||||
luaEagerOrLazy = type: k.union [ type (types.functionCheckedWith "" type) ];
|
||||
functionCheckedWith =
|
||||
arg: type:
|
||||
k.typedef' "${h.toPretty arg} -> ${type.name}" (
|
||||
f:
|
||||
if lib.isFunction f then
|
||||
type.verify (f arg)
|
||||
else
|
||||
"Expected function, but got ${h.toPretty f} instead"
|
||||
);
|
||||
luaEagerOrLazy =
|
||||
type:
|
||||
k.union [
|
||||
type
|
||||
(types.functionCheckedWith "" type)
|
||||
];
|
||||
luaLiteral = types.luaEagerOrLazy types.strictLuaLiteral;
|
||||
# }}}
|
||||
# {{{ Lazy key
|
||||
lazyKey = struct "lazy key"
|
||||
{
|
||||
mapping = k.string;
|
||||
action = k.union [ types.luaLiteral k.string ];
|
||||
mode = k.string;
|
||||
desc = k.string;
|
||||
expr = k.bool;
|
||||
ft = types.oneOrMany k.string;
|
||||
}
|
||||
[ (h.propExists "mapping") ];
|
||||
lazyKey = struct "lazy key" {
|
||||
mapping = k.string;
|
||||
action = k.union [
|
||||
types.luaLiteral
|
||||
k.string
|
||||
];
|
||||
mode = k.string;
|
||||
desc = k.string;
|
||||
expr = k.bool;
|
||||
ft = types.oneOrMany k.string;
|
||||
} [ (h.propExists "mapping") ];
|
||||
# }}}
|
||||
# {{{ Lazy module
|
||||
lazyModule = lazyType "actually lazy lazy module" (_: struct "lazy module"
|
||||
{
|
||||
package = k.string;
|
||||
dir = k.union [ k.string types.derivation types.path ];
|
||||
version = k.string;
|
||||
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 ]);
|
||||
lazyModule = lazyType "actually lazy lazy module" (
|
||||
_:
|
||||
struct "lazy module"
|
||||
{
|
||||
package = k.string;
|
||||
dir = k.union [
|
||||
k.string
|
||||
types.derivation
|
||||
types.path
|
||||
];
|
||||
version = k.string;
|
||||
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;
|
||||
}
|
||||
[ ];
|
||||
cond = types.oneOrMany types.luaLiteral;
|
||||
init = k.union [ types.luaLiteral types.tempestConfig ];
|
||||
config = k.union [ types.luaLiteral k.bool types.tempestConfig ];
|
||||
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")
|
||||
]);
|
||||
} [ ];
|
||||
cond = types.oneOrMany types.luaLiteral;
|
||||
init = types.luaEagerOrLazy (
|
||||
k.union [
|
||||
types.strictLuaLiteral
|
||||
types.strictTempestConfig
|
||||
]
|
||||
);
|
||||
config = k.union [
|
||||
k.bool
|
||||
(types.luaEagerOrLazy (
|
||||
k.union [
|
||||
types.strictLuaLiteral
|
||||
types.strictTempestConfig
|
||||
]
|
||||
))
|
||||
];
|
||||
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
|
||||
tempestKey = struct "tempest key"
|
||||
{
|
||||
mapping = k.string;
|
||||
action = k.union [ types.luaLiteral k.string ];
|
||||
mode = k.string;
|
||||
desc = k.string;
|
||||
expr = k.bool;
|
||||
silent = k.bool;
|
||||
ft = types.oneOrMany k.string;
|
||||
buffer = k.union [ k.bool k.number types.luaLiteral ];
|
||||
}
|
||||
[
|
||||
(h.propExists "mapping")
|
||||
(h.propExists "action")
|
||||
];
|
||||
tempestKey =
|
||||
struct "tempest key"
|
||||
{
|
||||
mapping = k.string;
|
||||
action = k.union [
|
||||
types.luaLiteral
|
||||
k.string
|
||||
];
|
||||
mode = k.string;
|
||||
desc = k.string;
|
||||
expr = k.bool;
|
||||
silent = k.bool;
|
||||
ft = types.oneOrMany k.string;
|
||||
buffer = k.union [
|
||||
k.bool
|
||||
k.number
|
||||
types.luaLiteral
|
||||
];
|
||||
}
|
||||
[
|
||||
(h.propExists "mapping")
|
||||
(h.propExists "action")
|
||||
];
|
||||
# }}}
|
||||
# {{{ Tempest autocmd
|
||||
tempestAutocmd = struct "tempest autocommand"
|
||||
{
|
||||
event = types.oneOrMany k.string;
|
||||
pattern = types.oneOrMany k.string;
|
||||
group = k.string;
|
||||
action = k.union [ types.tempestConfig types.luaLiteral ];
|
||||
}
|
||||
[
|
||||
(h.propExists "event")
|
||||
(h.propExists "group")
|
||||
(h.propExists "action")
|
||||
];
|
||||
tempestAutocmd =
|
||||
struct "tempest autocommand"
|
||||
{
|
||||
event = types.oneOrMany k.string;
|
||||
pattern = types.oneOrMany k.string;
|
||||
group = k.string;
|
||||
action = k.union [
|
||||
types.tempestConfig
|
||||
types.luaLiteral
|
||||
];
|
||||
}
|
||||
[
|
||||
(h.propExists "event")
|
||||
(h.propExists "group")
|
||||
(h.propExists "action")
|
||||
];
|
||||
# }}}
|
||||
# {{{ Tempest config
|
||||
tempestConfig = lazyType "lazy tempest config" (_: struct "tempest config"
|
||||
{
|
||||
vim = types.luaValue;
|
||||
callback = k.union [ types.luaLiteral types.tempestConfig ];
|
||||
setup = k.attrsOf types.luaValue;
|
||||
keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey);
|
||||
autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd);
|
||||
mkContext = types.luaValue;
|
||||
cond = types.oneOrMany types.luaLiteral;
|
||||
}
|
||||
[ ]);
|
||||
strictTempestConfig = struct "tempest config" {
|
||||
vim = types.luaValue;
|
||||
callback = k.union [
|
||||
types.luaLiteral
|
||||
types.tempestConfig
|
||||
];
|
||||
setup = k.attrsOf types.luaValue;
|
||||
keys = types.luaEagerOrLazy (types.oneOrMany types.tempestKey);
|
||||
autocmds = types.luaEagerOrLazy (types.oneOrMany types.tempestAutocmd);
|
||||
mkContext = types.luaValue;
|
||||
cond = types.oneOrMany types.luaLiteral;
|
||||
} [ ];
|
||||
|
||||
tempestConfig = lazyType "lazy tempest config" (_: types.strictTempestConfig);
|
||||
# }}}
|
||||
# {{{ Neovim env
|
||||
neovimEnv = k.enum "neovim env"
|
||||
[ "neovide" "firenvim" "vscode" ];
|
||||
neovimEnv = k.enum "neovim env" [
|
||||
"neovide"
|
||||
"firenvim"
|
||||
"vscode"
|
||||
];
|
||||
# }}}
|
||||
# {{{ Neovim config
|
||||
neovimConfig = struct "neovim configuration"
|
||||
{
|
||||
pre = k.attrsOf types.tempestConfig;
|
||||
lazy = k.attrsOf types.lazyModule;
|
||||
post = k.attrsOf types.tempestConfig;
|
||||
} [ ];
|
||||
neovimConfig = struct "neovim configuration" {
|
||||
pre = k.attrsOf types.tempestConfig;
|
||||
lazy = k.attrsOf types.lazyModule;
|
||||
post = k.attrsOf types.tempestConfig;
|
||||
} [ ];
|
||||
# }}}
|
||||
};
|
||||
|
||||
mkLib = { tempestModule }:
|
||||
mkLib =
|
||||
{ tempestModule }:
|
||||
assert h.hasType k.string tempestModule;
|
||||
rec {
|
||||
inherit (e) encode;
|
||||
inherit (h) lua;
|
||||
|
||||
# {{{ Common generation helpers
|
||||
importFrom = path: tag:
|
||||
importFrom =
|
||||
path: tag:
|
||||
assert lib.isPath path;
|
||||
assert h.hasType k.string tag;
|
||||
lua "dofile(${encode (toString path)}).${tag}";
|
||||
foldedList = value: assert h.hasType k.attrs value;
|
||||
{ inherit value; __luaEncoderTag = "foldedList"; };
|
||||
foldedList =
|
||||
value:
|
||||
assert h.hasType k.attrs value;
|
||||
{
|
||||
inherit value;
|
||||
__luaEncoderTag = "foldedList";
|
||||
};
|
||||
thunk = code: _: lua code;
|
||||
tempest = given: context: lua ''
|
||||
D.tempest.configure(
|
||||
${encode given},
|
||||
${context}
|
||||
)
|
||||
'';
|
||||
tempestBufnr = given: lua ''
|
||||
function(_, bufnr)
|
||||
return D.tempest.configure(
|
||||
require = module: lua "require(${module})";
|
||||
tempest =
|
||||
given: context:
|
||||
lua ''
|
||||
D.tempest.configure(
|
||||
${encode given},
|
||||
{ bufnr = bufnr}
|
||||
${context}
|
||||
)
|
||||
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:
|
||||
'';
|
||||
tempestBufnr =
|
||||
given:
|
||||
lua ''
|
||||
function(_, bufnr)
|
||||
return D.tempest.configure(
|
||||
${encode given},
|
||||
{ bufnr = bufnr}
|
||||
)
|
||||
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;
|
||||
lua /* lua */ ''
|
||||
# lua
|
||||
lua ''
|
||||
D.tempest.blacklist(${encode given})
|
||||
'';
|
||||
whitelist = given:
|
||||
whitelist =
|
||||
given:
|
||||
assert h.hasType (types.oneOrMany types.neovimEnv) given;
|
||||
lua /* lua */ ''
|
||||
# lua
|
||||
lua ''
|
||||
D.tempest.whitelist(${encode given})
|
||||
'';
|
||||
# :p => expands path
|
||||
|
@ -182,11 +270,17 @@ let
|
|||
notmp = lua ''vim.fn.expand("%:p:h") ~= "/tmp"'';
|
||||
# }}}
|
||||
# {{{ Main config generation entrypoint
|
||||
generateConfig = rawConfig:
|
||||
generateConfig =
|
||||
rawConfig:
|
||||
assert h.hasType types.neovimConfig rawConfig;
|
||||
let
|
||||
config = { lazy = { }; pre = { }; post = { }; } // rawConfig;
|
||||
collectNixDeps = lazyModule:
|
||||
config = {
|
||||
lazy = { };
|
||||
pre = { };
|
||||
post = { };
|
||||
} // rawConfig;
|
||||
collectNixDeps =
|
||||
lazyModule:
|
||||
if lazyModule ? dependencies then
|
||||
let
|
||||
nix = lazyModule.dependencies.nix or [ ];
|
||||
|
@ -202,12 +296,10 @@ let
|
|||
(lib.mapAttrsToList (_: collectNixDeps))
|
||||
lib.lists.flatten
|
||||
];
|
||||
processedLazyModules =
|
||||
lib.mapAttrs
|
||||
(name: module: { inherit name; } // module // {
|
||||
dependencies = (module.dependencies or { }).lua or null;
|
||||
})
|
||||
config.lazy;
|
||||
processedLazyModules = lib.mapAttrs (
|
||||
name: module:
|
||||
{ inherit name; } // module // { dependencies = (module.dependencies or { }).lua or null; }
|
||||
) config.lazy;
|
||||
|
||||
luaConfig = ''
|
||||
local M = {}
|
||||
|
@ -229,7 +321,10 @@ let
|
|||
return M
|
||||
'';
|
||||
in
|
||||
{ inherit dependencies; lua = luaConfig; };
|
||||
{
|
||||
inherit dependencies;
|
||||
lua = luaConfig;
|
||||
};
|
||||
# }}}
|
||||
};
|
||||
in
|
||||
|
|
Loading…
Reference in a new issue