nixdirfmt + getAlias function

This commit is contained in:
kat witch 2021-08-30 03:31:55 +01:00
parent 589bef29fa
commit 5da38c626d
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
7 changed files with 89 additions and 83 deletions

View file

@ -1,57 +1,59 @@
{ config, tf, meta, kw, pkgs, lib, sources, ... }: with lib; let { config, tf, meta, kw, pkgs, lib, sources, ... }: with lib; let
oci-root = meta.deploy.targets.oci-root.tf; oci-root = meta.deploy.targets.oci-root.tf;
addr_ipv6_nix = let addr_ipv6_nix =
prefix = head (splitString "/" (oci-root.resources.oci_kw_subnet.importAttr "ipv6cidr_block")); let
in assert hasSuffix "::" prefix; prefix + "7"; prefix = head (splitString "/" (oci-root.resources.oci_kw_subnet.importAttr "ipv6cidr_block"));
in
assert hasSuffix "::" prefix; prefix + "7";
in in
{ {
imports = (with (import (sources.tf-nix + "/modules")); [ imports = (with (import (sources.tf-nix + "/modules")); [
nixos.ubuntu-linux nixos.ubuntu-linux
nixos.oracle nixos.oracle
./oracle.nix ./oracle.nix
]) ++ (with meta; [ ]) ++ (with meta; [
services.knot services.knot
services.nginx services.nginx
]); ]);
services.nginx.virtualHosts = services.nginx.virtualHosts =
let let
splashy = pkgs.host-splash-site config.networking.hostName; splashy = pkgs.host-splash-site config.networking.hostName;
in in
kw.virtualHostGen { kw.virtualHostGen {
networkFilter = [ "public" ]; networkFilter = [ "public" ];
block.locations."/" = { root = splashy; }; block.locations."/" = { root = splashy; };
}; };
networking = { networking = {
useDHCP = false; useDHCP = false;
hostName = "rinnosuke"; hostName = "rinnosuke";
interfaces.ens3 = { interfaces.ens3 = {
useDHCP = true; useDHCP = true;
ipv6 = { ipv6 = {
addresses = mkIf (config.network.addresses.public.ipv6.enable) [{ addresses = mkIf (config.network.addresses.public.ipv6.enable) [{
address = config.network.addresses.public.ipv6.address; address = config.network.addresses.public.ipv6.address;
prefixLength = 64; prefixLength = 64;
}]; }];
routes = [{ routes = [{
address = "::"; address = "::";
prefixLength = 0; prefixLength = 0;
}]; }];
};
};
}; };
};
};
network = { network = {
addresses = { addresses = {
public = { public = {
enable = true; enable = true;
ipv6.address = mkIf (tf.state.resources ? ${tf.resources.${config.networking.hostName}.out.reference}) addr_ipv6_nix; ipv6.address = mkIf (tf.state.resources ? ${tf.resources.${config.networking.hostName}.out.reference}) addr_ipv6_nix;
};
};
firewall.public.interfaces = singleton "ens3";
tf = {
enable = true;
ipv4_attr = "public_ip";
};
}; };
} };
firewall.public.interfaces = singleton "ens3";
tf = {
enable = true;
ipv4_attr = "public_ip";
};
};
}

View file

@ -14,9 +14,9 @@
group = "knot"; group = "knot";
}; };
/* environment.etc."katdns/zones/kittywit.ch.zone".text = let /* environment.etc."katdns/zones/kittywit.ch.zone".text = let
dns = pkgs.dns; dns = pkgs.dns;
in dns.lib.toString "kittywit.ch." (import ./kittywit.ch.nix {inherit dns; }); */ in dns.lib.toString "kittywit.ch." (import ./kittywit.ch.nix {inherit dns; }); */
services.knot = { services.knot = {
enable = true; enable = true;

View file

@ -20,6 +20,9 @@ in
nano = '' nano = ''
${pkgs.kitty}/bin/kitty +kitten icat ${./nano.png} ${pkgs.kitty}/bin/kitty +kitten icat ${./nano.png}
''; '';
getAlias = ''
printf '%s\n' $aliases[$1]
'';
} // shellFunAliases { } // shellFunAliases {
sed = "sd"; sed = "sd";
find = "fd"; find = "fd";
@ -55,7 +58,7 @@ in
"autolist" "autolist"
"listrowsfirst" "listrowsfirst"
]; in ]; in
'' ''
${if config.anicca.enabled then '' ${if config.anicca.enabled then ''
HISTFILE=/persist/home/.zsh_history HISTFILE=/persist/home/.zsh_history
'' else '' '' else ''

View file

@ -1,34 +1,35 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let initvim = pkgs.callPackage let
({ stdenv, elinks, nodejs }: stdenv.mkDerivation { initvim = pkgs.callPackage
name = "init.vim"; ({ stdenv, elinks, nodejs }: stdenv.mkDerivation {
src = ./init.vim; name = "init.vim";
inherit nodejs elinks; src = ./init.vim;
buildInputs = [ inherit nodejs elinks;
elinks buildInputs = [
nodejs elinks
]; nodejs
phases = [ "buildPhase" ]; ];
buildPhase = '' phases = [ "buildPhase" ];
substituteAll $src $out buildPhase = ''
''; substituteAll $src $out
}) '';
{ }; })
{ };
cocvim = pkgs.callPackage cocvim = pkgs.callPackage
({ stdenv, elinks, nodejs }: stdenv.mkDerivation { ({ stdenv, elinks, nodejs }: stdenv.mkDerivation {
name = "coc.vim"; name = "coc.vim";
src = ./coc.vim; src = ./coc.vim;
inherit nodejs; inherit nodejs;
buildInputs = [ buildInputs = [
nodejs nodejs
]; ];
phases = [ "buildPhase" ]; phases = [ "buildPhase" ];
buildPhase = '' buildPhase = ''
substituteAll $src $out substituteAll $src $out
''; '';
}) })
{ }; { };
in in
{ {
programs.neovim = { programs.neovim = {

View file

@ -2,7 +2,7 @@
{ {
wayland.windowManager.sway.extraSessionCommands = '' wayland.windowManager.sway.extraSessionCommands = ''
export KITTY_CACHE_DIRECTORY="/tmp/kitty"; export KITTY_CACHE_DIRECTORY="/tmp/kitty";
''; '';
programs.kitty = { programs.kitty = {
enable = true; enable = true;

View file

@ -1,6 +1,6 @@
let let
# we don't have lib without sources, so we need optionalAttrs # we don't have lib without sources, so we need optionalAttrs
optionalAttrs = cond: as: if cond then as else {}; optionalAttrs = cond: as: if cond then as else { };
# Sources are from niv. # Sources are from niv.
sources = import ./nix/sources.nix // optionalAttrs (builtins.pathExists ./overlays/exprs/default.nix) { sources = import ./nix/sources.nix // optionalAttrs (builtins.pathExists ./overlays/exprs/default.nix) {
katexprs = ./overlays/exprs; katexprs = ./overlays/exprs;

View file

@ -1,3 +1,3 @@
{ sources, ... }: final: prev: { { sources, ... }: final: prev: {
dns = import ( sources.kirelagin + "/dns") { pkgs = final; }; dns = import (sources.kirelagin + "/dns") { pkgs = final; };
} }