format rfc-style

This commit is contained in:
Sean Buckley 2024-11-07 22:59:57 -05:00
parent a201733f96
commit 1bb5a821a6
32 changed files with 600 additions and 412 deletions

View file

@ -2,13 +2,19 @@
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.impermanence.url = "github:nix-community/impermanence";
outputs = { self, nixpkgs, impermanence }:
outputs =
{
self,
nixpkgs,
impermanence,
}:
let
inherit (nixpkgs) lib;
mypkgs = pkgs:
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { }) //
{
mypkgs =
pkgs:
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { })
// {
iso = import lib/gen-iso.nix lib pkgs.system;
};
@ -35,35 +41,34 @@
gen-ssh-config = import lib/gen-ssh-config.nix lib;
ssh-keys = import lib/ssh-keys.nix;
dirToAttrs = dir: f: lib.mapAttrs'
(name: _: {
dirToAttrs =
dir: f:
lib.mapAttrs' (name: _: {
name = lib.removeSuffix ".nix" name;
value = f "${toString dir}/${name}";
})
(builtins.readDir dir);
}) (builtins.readDir dir);
};
nixosModules =
{
nixosModules = {
inherit pins;
inherit (impermanence.nixosModules) impermanence;
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
} //
self.lib.dirToAttrs ./modules import;
} // self.lib.dirToAttrs ./modules import;
nixosConfigurations = self.lib.dirToAttrs ./hosts
(dir:
let cfg = import dir;
in lib.nixosSystem {
nixosConfigurations = self.lib.dirToAttrs ./hosts (
dir:
let
cfg = import dir;
in
lib.nixosSystem {
inherit (cfg) system;
modules =
cfg.modules ++
[{ networking.hostName = builtins.baseNameOf dir; }] ++
(builtins.attrValues self.nixosModules);
cfg.modules
++ [ { networking.hostName = builtins.baseNameOf dir; } ]
++ (builtins.attrValues self.nixosModules);
}
);
packages = forAllSystems (system:
mypkgs nixpkgs.legacyPackages.${system});
packages = forAllSystems (system: mypkgs nixpkgs.legacyPackages.${system});
};
}

View file

@ -20,7 +20,10 @@ in
];
services.openssh.hostKeys = [
{ type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; }
{
type = "ed25519";
path = "${persist}/ssh_host_ed25519_key";
}
];
users.mutableUsers = false;
@ -36,11 +39,27 @@ in
hardware.enableRedistributableFirmware = true;
fileSystems = {
"/" = { device = "tmpfs"; fsType = "tmpfs"; options = [ "mode=755" ]; };
"/boot" = { device = "/dev/disk/by-partlabel/EFI\\x20system\\x20partition"; fsType = "vfat"; };
"/home" = { device = "zroot/locker/home"; fsType = "zfs"; };
"/nix" = { device = "zroot/locker/nix"; fsType = "zfs"; };
"/var/log" = { device = "zroot/locker/log"; fsType = "zfs"; };
"/" = {
device = "tmpfs";
fsType = "tmpfs";
options = [ "mode=755" ];
};
"/boot" = {
device = "/dev/disk/by-partlabel/EFI\\x20system\\x20partition";
fsType = "vfat";
};
"/home" = {
device = "zroot/locker/home";
fsType = "zfs";
};
"/nix" = {
device = "zroot/locker/nix";
fsType = "zfs";
};
"/var/log" = {
device = "zroot/locker/log";
fsType = "zfs";
};
};
system.stateVersion = "22.05";

View file

@ -8,7 +8,10 @@ in
};
services.openssh.hostKeys = [
{ type = "ed25519"; path = "${persist}/ssh_host_ed25519_key"; }
{
type = "ed25519";
path = "${persist}/ssh_host_ed25519_key";
}
];
# services.ollama = {
@ -22,7 +25,10 @@ in
sconfig = {
gnome = true;
desktop.enable = true;
wg-home = { enable = true; path = "${persist}/wireguard_home.conf"; };
wg-home = {
enable = true;
path = "${persist}/wireguard_home.conf";
};
};
environment.persistence."${persist}/system".directories = [
@ -49,14 +55,32 @@ in
boot = {
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [ "xhci_pci" "vmd" "nvme" "sd_mod" ];
initrd.availableKernelModules = [
"xhci_pci"
"vmd"
"nvme"
"sd_mod"
];
};
fileSystems = {
"/" = { device = "tmpfs"; fsType = "tmpfs"; options = [ "mode=755" ]; };
"/boot" = { fsType = "vfat"; device = "/dev/nvme0n1p1"; };
"/nix" = { device = "levi/nix"; fsType = "zfs"; };
"/home" = { device = "levi/home"; fsType = "zfs"; };
"/" = {
device = "tmpfs";
fsType = "tmpfs";
options = [ "mode=755" ];
};
"/boot" = {
fsType = "vfat";
device = "/dev/nvme0n1p1";
};
"/nix" = {
device = "levi/nix";
fsType = "zfs";
};
"/home" = {
device = "levi/home";
fsType = "zfs";
};
};
users.mutableUsers = false;

View file

@ -1,15 +1,20 @@
{ runCommand }: {
{ runCommand }:
{
b64decode = input:
builtins.readFile
(runCommand "b64decode" { } ''
b64decode =
input:
builtins.readFile (
runCommand "b64decode" { } ''
base64 -d >$out <${builtins.toFile "input" input}
'');
''
);
b64encode = input:
builtins.readFile
(runCommand "b64encode" { } ''
b64encode =
input:
builtins.readFile (
runCommand "b64encode" { } ''
base64 -w0 >$out <${builtins.toFile "input" input}
'');
''
);
}

View file

@ -1,16 +1,18 @@
lib:
system:
lib: system:
let
sys = lib.nixosSystem {
inherit system;
modules = [
({ modulesPath, ... }: {
(
{ modulesPath, ... }:
{
imports = [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
];
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
})
}
)
];
};

View file

@ -1,23 +1,22 @@
lib:
nixosConfigurations:
lib: nixosConfigurations:
let
sshKnownHostsTxt = builtins.toFile "known_hosts" (lib.concatMapStrings
(hostName:
let d = nixosConfigurations.${hostName}.config.deploy;
in lib.concatMapStrings (key: "${d.ssh.HostName} ${key}\n") d.sshPublicKeys
)
(builtins.attrNames nixosConfigurations)
sshKnownHostsTxt = builtins.toFile "known_hosts" (
lib.concatMapStrings (
hostName:
let
d = nixosConfigurations.${hostName}.config.deploy;
in
lib.concatMapStrings (key: "${d.ssh.HostName} ${key}\n") d.sshPublicKeys
) (builtins.attrNames nixosConfigurations)
);
attrsToList = lib.mapAttrsToList (n: v: "${n} ${v}");
attrsToLines = a: lib.concatLines (attrsToList a);
in
lib.concatMapStrings
(host: ''
lib.concatMapStrings (host: ''
Host ${host}
UserKnownHostsFile ${sshKnownHostsTxt}
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
'')
(builtins.attrNames nixosConfigurations)
'') (builtins.attrNames nixosConfigurations)

View file

@ -1,10 +1,17 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.sconfig.ad-domain;
in
{
options.sconfig.ad-domain = with lib; with types;
options.sconfig.ad-domain =
with lib;
with types;
{
enable = mkEnableOption "Join Domain with SSSD";
longname = mkOption {
@ -17,8 +24,7 @@ in
};
};
config = lib.mkIf cfg.enable
{
config = lib.mkIf cfg.enable {
networking.domain = cfg.longname;
networking.search = [ (cfg.longname) ];
security.pam.services.sshd.makeHomeDir = true;

View file

@ -1,15 +1,14 @@
let
brave = (final: prev: {
brave = (
final: prev: {
brave =
let
# updates to the newer version before it hits the channels
version = "1";
hash = "";
in
if
prev.lib.versionAtLeast prev.brave.version version
then
if prev.lib.versionAtLeast prev.brave.version version then
prev.brave
else
prev.brave.overrideAttrs {
@ -18,7 +17,8 @@ let
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-browser_${version}_amd64.deb";
};
};
});
}
);
in
{

View file

@ -42,9 +42,11 @@
(writeShellScriptBin "dirt" "while sleep 1; do grep '^Dirty:' /proc/meminfo ; done")
(lib.hiPrio (writeShellScriptBin "iftop" ''
(lib.hiPrio (
writeShellScriptBin "iftop" ''
exec ${iftop}/bin/iftop -P -m100M "$@"
''))
''
))
(writeShellScriptBin "bat" ''
${bat}/bin/bat --pager=never --color=always --wrap=never --terminal-width=80 "$@"
@ -85,7 +87,11 @@
update_process_names = 1;
};
package = pkgs.htop.overrideAttrs (
{ patches ? [ ], ... }: {
{
patches ? [ ],
...
}:
{
patches = patches ++ [
# This patch fixes process sort order while in tree view.
# Started in 3.3.0. Should be fixed in 3.4.0.

View file

@ -11,16 +11,20 @@ let
SeparatorFg = 16;
};
customEnd = [{
customEnd = [
{
Content = "$";
Foreground = 231;
Background = 102;
Separator = left_hard_divider;
}];
}
];
plconfig = builtins.toFile "powerline-config.json" (builtins.toJSON {
plconfig = builtins.toFile "powerline-config.json" (
builtins.toJSON {
modes.patched.Separator = upper_left_triangle;
});
}
);
args = [
"-modules=\${remote:+'user,host,'}nix-shell,git,jobs,cwd,newline,customend"
@ -37,9 +41,7 @@ in
environment.systemPackages = [
pkgs.powerline-go
(pkgs.writeShellScriptBin
"powerline-go-customend"
"echo '${builtins.toJSON customEnd}'")
(pkgs.writeShellScriptBin "powerline-go-customend" "echo '${builtins.toJSON customEnd}'")
];
environment.etc."powerline-theme.json".text = builtins.toJSON theme;

View file

@ -1,20 +1,43 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
aconfig = (pkgs.formats.toml { }).generate "alacritty.toml"
{
aconfig = (pkgs.formats.toml { }).generate "alacritty.toml" {
env.TERM = "xterm-256color";
font.size = 12;
window = {
dynamic_padding = true;
resize_increments = true;
dimensions = { columns = 120; lines = 40; };
dimensions = {
columns = 120;
lines = 40;
};
};
keyboard.bindings = [
{ action = "ScrollHalfPageDown"; mods = "Shift"; key = "PageDown"; }
{ action = "ScrollHalfPageUp"; mods = "Shift"; key = "PageUp"; }
{ action = "SpawnNewInstance"; mods = "Control|Shift"; key = "N"; }
{ action = "SpawnNewInstance"; mods = "Control|Shift"; key = "T"; }
{
action = "ScrollHalfPageDown";
mods = "Shift";
key = "PageDown";
}
{
action = "ScrollHalfPageUp";
mods = "Shift";
key = "PageUp";
}
{
action = "SpawnNewInstance";
mods = "Control|Shift";
key = "N";
}
{
action = "SpawnNewInstance";
mods = "Control|Shift";
key = "T";
}
];
colors = {
primary.background = "0x1e1e1e";

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkIf (config.sconfig.desktop.enable) {
environment.systemPackages = [
@ -26,8 +31,14 @@
ShowFullUrlsInAddressBar = true;
SyncDisabled = true; # required for BrowsingDataLifetime
BrowsingDataLifetime = [
{ data_types = [ "browsing_history" ]; time_to_live_in_hours = 24 * 7; }
{ data_types = [ "download_history" ]; time_to_live_in_hours = 6; }
{
data_types = [ "browsing_history" ];
time_to_live_in_hours = 24 * 7;
}
{
data_types = [ "download_history" ];
time_to_live_in_hours = 6;
}
];
};
};

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
with lib;
{
options.sconfig.desktop = {

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkIf (config.sconfig.desktop.enable) {
environment.systemPackages = [
@ -12,8 +17,12 @@
OfferToSaveLogins = false;
DisableFormHistory = true;
SearchSuggestEnabled = false;
Preferences = builtins.mapAttrs
(n: v: { Value = v; Status = "locked"; })
Preferences =
builtins.mapAttrs
(n: v: {
Value = v;
Status = "locked";
})
{
"accessibility.force_disabled" = 1;
"browser.aboutConfig.showWarning" = false;
@ -29,8 +38,10 @@
"ui.key.menuAccessKeyFocuses" = false;
};
ExtensionSettings =
{ "*".installation_mode = "blocked"; } //
builtins.mapAttrs
{
"*".installation_mode = "blocked";
}
// builtins.mapAttrs
(n: v: {
installation_mode = "force_installed";
install_url = "https://addons.mozilla.org/firefox/downloads/latest/${v}/latest.xpi";

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
config = lib.mkIf (config.sconfig.desktop.enable) {
environment.systemPackages = with pkgs; [
@ -22,9 +27,8 @@
environment.etc."vscode-keybindings.json".source = ./vscode-keybindings.json;
environment.etc."vscode-settings.json".text = builtins.toJSON (
(
builtins.fromJSON (builtins.readFile ./vscode-settings.json)
) // {
(builtins.fromJSON (builtins.readFile ./vscode-settings.json))
// {
# NixOS-specific vscode settings:
"extensions.autoCheckUpdates" = false;
"extensions.autoUpdate" = false;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.sconfig.devtools;
in
@ -6,8 +11,7 @@ in
options.sconfig.devtools.enable = lib.mkEnableOption "Development Tools";
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs;
[
environment.systemPackages = with pkgs; [
black
cargo
efm-langserver
@ -34,8 +38,7 @@ in
# dedicated script, because bash aliases dont work with `watch`
(writeShellScriptBin "k" "exec kubectl \"$@\"")
(google-cloud-sdk.withExtraComponents
[ google-cloud-sdk.components.gke-gcloud-auth-plugin ])
(google-cloud-sdk.withExtraComponents [ google-cloud-sdk.components.gke-gcloud-auth-plugin ])
];
programs.bash.interactiveShellInit = ''
alias t=terraform

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.sconfig.gnome;
in

View file

@ -4,11 +4,15 @@ let
exec prettier --stdin-filepath "$HX_FILE"
'';
prettier-formats = map
prettier-formats =
map
(name: {
inherit name;
auto-format = true;
indent = { tab-width = 4; unit = "\t"; };
indent = {
tab-width = 4;
unit = "\t";
};
formatter.command = hx-pretty;
})
[
@ -21,8 +25,7 @@ let
in
{
environment.etc."bck-helix/config.toml".source =
(pkgs.formats.toml { }).generate "config.toml" {
environment.etc."bck-helix/config.toml".source = (pkgs.formats.toml { }).generate "config.toml" {
theme = "dark_plus";
editor = {
auto-format = true;
@ -43,28 +46,44 @@ in
};
environment.etc."bck-helix/languages.toml".source =
(pkgs.formats.toml { }).generate "languages.toml" {
(pkgs.formats.toml { }).generate "languages.toml"
{
language = prettier-formats ++ [
{
name = "bash";
auto-format = true;
indent = { tab-width = 4; unit = "\t"; };
indent = {
tab-width = 4;
unit = "\t";
};
}
{
name = "lua";
auto-format = true;
indent = { tab-width = 4; unit = "\t"; };
indent = {
tab-width = 4;
unit = "\t";
};
}
{
name = "nix";
auto-format = true;
formatter = { command = "nixfmt"; args = [ "--verify" ]; };
formatter = {
command = "nixfmt";
args = [ "--verify" ];
};
}
{
name = "python";
auto-format = true;
language-servers = [ "pyright" ];
formatter = { command = "black"; args = [ "--quiet" "-" ]; };
formatter = {
command = "black";
args = [
"--quiet"
"-"
];
};
}
{
name = "yaml";
@ -81,13 +100,19 @@ in
};
environment.systemPackages = with pkgs; [
(helix.overrideAttrs ({ patches ? [ ], ... }: {
(helix.overrideAttrs (
{
patches ? [ ],
...
}:
{
# Patch required for .editorconfig to work properly with formatters
patches = patches ++ [ ./format-filepath.patch ];
postPatch = ''
sed 's/tab-width = .,/tab-width = 4,/' -i languages.toml
'';
}))
}
))
];
environment.etc."bck-settings.sh".text = ''

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.sconfig.plasma;
in

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.sconfig.security-tools;

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.sconfig.swapspace;
in

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.sconfig.wg-home;
in

View file

@ -1,5 +1,6 @@
{ lib
, writeTextDir
{
lib,
writeTextDir,
}:
writeTextDir "authorized_keys" (lib.concatLines (import ../lib/ssh-keys.nix))

View file

@ -1,20 +1,17 @@
{ lib
, extraBinPaths ? [ ]
, neovim-unwrapped
, vimPlugins
, wrapNeovim
{
lib,
extraBinPaths ? [ ],
neovim-unwrapped,
vimPlugins,
wrapNeovim,
}:
let
luafiles = lib.concatLines (map
(x: "luafile ${./lua}/${x}")
(builtins.attrNames (builtins.readDir ./lua))
luafiles = lib.concatLines (
map (x: "luafile ${./lua}/${x}") (builtins.attrNames (builtins.readDir ./lua))
);
extraPath = lib.concatLines (map
(p: "let $PATH .= ':${p}/bin'")
(extraBinPaths)
);
extraPath = lib.concatLines (map (p: "let $PATH .= ':${p}/bin'") (extraBinPaths));
in
wrapNeovim neovim-unwrapped {

View file

@ -1,11 +1,12 @@
{ stdenv
, autoPatchelfHook
, libglvnd
, makeWrapper
, python3
, qt6
, requireFile
, unzip
{
stdenv,
autoPatchelfHook,
libglvnd,
makeWrapper,
python3,
qt6,
requireFile,
unzip,
}:
let

View file

@ -1,6 +1,7 @@
{ nixos-rebuild
, python3
, writeShellScriptBin
{
nixos-rebuild,
python3,
writeShellScriptBin,
}:
writeShellScriptBin "deploy" ''

View file

@ -1,14 +1,16 @@
{ callPackage
, firecracker
, writeShellApplication
, writeText
{
callPackage,
firecracker,
writeShellApplication,
writeText,
}:
let
kernel = callPackage ./kernel.nix { };
rootfs = callPackage ./rootfs.nix { };
vmconfig = writeText "vmconfig.json" (builtins.toJSON {
vmconfig = writeText "vmconfig.json" (
builtins.toJSON {
boot-source = {
kernel_image_path = "${kernel}/vmlinux";
boot_args = "panic=1 console=ttyS0 ro";
@ -24,11 +26,14 @@ let
machine-config.vcpu_count = 2;
machine-config.mem_size_mib = 1024;
network-interfaces = [ ];
});
}
);
in
writeShellApplication {
name = "firecracker-vm";
text = "${firecracker}/bin/firecracker --no-api --config-file ${vmconfig}";
derivationArgs.passthru = { inherit kernel rootfs; };
derivationArgs.passthru = {
inherit kernel rootfs;
};
}

View file

@ -1,7 +1,8 @@
{ fetchFromGitHub
, linuxManualConfig
, linux_6_1
, kernel ? linux_6_1
{
fetchFromGitHub,
linuxManualConfig,
linux_6_1,
kernel ? linux_6_1,
}:
let
@ -12,22 +13,20 @@ let
hash = "sha256-NuVH12cy38uu+8oms66p9k0xoMOJSl5AvY5pD1FCKkI=";
};
shortVer = builtins.head (
builtins.match
"([0-9]+\.[0-9]+).*"
kernel.version
);
shortVer = builtins.head (builtins.match "([0-9]+\.[0-9]+).*" kernel.version);
in
(linuxManualConfig {
inherit (kernel) src version;
configfile =
"${fcsrc}/resources/guest_configs/microvm-kernel-ci-x86_64-${shortVer}.config";
configfile = "${fcsrc}/resources/guest_configs/microvm-kernel-ci-x86_64-${shortVer}.config";
}).overrideAttrs (o: {
}).overrideAttrs
(o: {
postInstall = (o.postInstall or "") + ''
postInstall =
(o.postInstall or "")
+ ''
cp vmlinux $out/
'';

View file

@ -1,8 +1,9 @@
{ e2fsprogs
, pkgsStatic
, runCommand
, util-linux
, writeShellScript
{
e2fsprogs,
pkgsStatic,
runCommand,
util-linux,
writeShellScript,
}:
let

View file

@ -1,8 +1,9 @@
{ lib
, dpkg
, fetchurl
, stdenv
, steam-run
{
lib,
dpkg,
fetchurl,
stdenv,
steam-run,
}:
stdenv.mkDerivation rec {

View file

@ -1,11 +1,12 @@
{ stdenv
, autoPatchelfHook
, fetchFromGitHub
, fetchzip
, gcc-unwrapped
, makeWrapper
, ocamlPackages
, model ? "small"
{
stdenv,
autoPatchelfHook,
fetchFromGitHub,
fetchzip,
gcc-unwrapped,
makeWrapper,
ocamlPackages,
model ? "small",
}:
let
@ -30,8 +31,7 @@ let
'';
in
stdenv.mkDerivation rec
{
stdenv.mkDerivation rec {
pname = "mp4grep";
version = "0.1.4";

View file

@ -1,4 +1,9 @@
{ stdenv, python3, fetchFromGitHub, makeWrapper }:
{
stdenv,
python3,
fetchFromGitHub,
makeWrapper,
}:
stdenv.mkDerivation rec {
pname = "weevely";
@ -11,14 +16,16 @@ stdenv.mkDerivation rec {
sha256 = "0sgjf7ihgipb33k73d84dcx7snv2fvbzyd0f4468k1w5w6zqm9xj";
};
pythonWithPkgs = python3.withPackages (ps: with ps; [
pythonWithPkgs = python3.withPackages (
ps: with ps; [
Mako
prettytable
pyopenssl
pysocks
python-dateutil
pyyaml
]);
]
);
buildInputs = [ makeWrapper ];