treewide: alejandra -> nixfmt-rfc-style

This commit is contained in:
Nikodem Rabuliński 2024-02-25 19:09:09 +01:00
parent d64c02e3da
commit 6558fdb739
51 changed files with 1108 additions and 928 deletions

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
options.assets = lib.mkOption { options.assets = lib.mkOption {
type = lib.types.unspecified; type = lib.types.unspecified;
readOnly = true; readOnly = true;

View file

@ -4,31 +4,37 @@
withSystem, withSystem,
self, self,
... ...
}: let }:
collectFlakeOutputs = { let
config, collectFlakeOutputs =
pkgs, { config, pkgs }:
}: let let
inherit (pkgs) lib; inherit (pkgs) lib;
collectDrvs = prefix: attrs: let collectDrvs =
prefix: attrs:
let
drvs = lib.pipe attrs [ drvs = lib.pipe attrs [
(lib.filterAttrs (_: lib.isDerivation)) (lib.filterAttrs (_: lib.isDerivation))
(lib.mapAttrsToList (name: drv: { (lib.mapAttrsToList (
name = lib.concatStringsSep "." (prefix ++ [name]); name: drv: {
name = lib.concatStringsSep "." (prefix ++ [ name ]);
inherit drv; inherit drv;
})) }
))
]; ];
recursed = lib.pipe attrs [ recursed = lib.pipe attrs [
(lib.filterAttrs (_: val: (lib.filterAttrs (
(!lib.isDerivation val) && (lib.isAttrs val) && (val.recurseForDerivations or true))) _: val: (!lib.isDerivation val) && (lib.isAttrs val) && (val.recurseForDerivations or true)
(lib.mapAttrsToList (name: collectDrvs (prefix ++ [name]))) ))
(lib.mapAttrsToList (name: collectDrvs (prefix ++ [ name ])))
]; ];
in in
drvs ++ (lib.flatten recursed); drvs ++ (lib.flatten recursed);
rootOutputs = builtins.removeAttrs config.onPush.default.outputs ["effects"]; rootOutputs = builtins.removeAttrs config.onPush.default.outputs [ "effects" ];
in in
collectDrvs [] rootOutputs; collectDrvs [ ] rootOutputs;
in { in
{
defaultEffectSystem = "aarch64-linux"; defaultEffectSystem = "aarch64-linux";
hercules-ci = { hercules-ci = {
@ -41,27 +47,22 @@ in {
herculesCI = herculesCI: { herculesCI = herculesCI: {
onPush.default = { onPush.default = {
outputs.effects = { outputs.effects = {
pin-cache = withSystem config.defaultEffectSystem ({ pin-cache = withSystem config.defaultEffectSystem (
pkgs, { pkgs, hci-effects, ... }:
hci-effects, let
...
}: let
collected = collectFlakeOutputs { collected = collectFlakeOutputs {
inherit (herculesCI) config; inherit (herculesCI) config;
inherit pkgs; inherit pkgs;
}; };
cachixCommands = cachixCommands =
lib.concatMapStringsSep lib.concatMapStringsSep "\n"
"\n" ({ name, drv }: "cachix pin nrabulinski ${lib.escapeShellArg name} ${lib.escapeShellArg drv}")
({
name,
drv,
}: "cachix pin nrabulinski ${lib.escapeShellArg name} ${lib.escapeShellArg drv}")
collected; collected;
in in
hci-effects.runIf (herculesCI.config.repo.branch == "main") (hci-effects.mkEffect { hci-effects.runIf (herculesCI.config.repo.branch == "main") (
hci-effects.mkEffect {
secretsMap."cachix-token" = "cachix-token"; secretsMap."cachix-token" = "cachix-token";
inputs = [pkgs.cachix]; inputs = [ pkgs.cachix ];
userSetupScript = '' userSetupScript = ''
cachix authtoken $(readSecretString cachix-token .token) cachix authtoken $(readSecretString cachix-token .token)
''; '';
@ -69,32 +70,36 @@ in {
# They have already been built as part of this job, # They have already been built as part of this job,
# we only want to pin them to make sure cachix doesn't GC them. # we only want to pin them to make sure cachix doesn't GC them.
effectScript = builtins.unsafeDiscardStringContext cachixCommands; effectScript = builtins.unsafeDiscardStringContext cachixCommands;
})); }
)
);
}; };
}; };
}; };
perSystem = { perSystem =
pkgs, { pkgs, lib, ... }:
lib, rec {
... legacyPackages.outputsList =
}: rec { let
legacyPackages.outputsList = let
config = self.herculesCI { config = self.herculesCI {
primaryRepo = {}; primaryRepo = { };
herculesCI = {}; herculesCI = { };
}; };
in in
collectFlakeOutputs {inherit config pkgs;}; collectFlakeOutputs { inherit config pkgs; };
legacyPackages.github-matrix = let legacyPackages.github-matrix =
systems = lib.groupBy ({drv, ...}: drv.system) legacyPackages.outputsList; let
systems = lib.groupBy ({ drv, ... }: drv.system) legacyPackages.outputsList;
in in
lib.concatMapStringsSep "\n" ({ lib.concatMapStringsSep "\n"
name, (
value, { name, value }:
}: '' ''
${name}=${builtins.toJSON (map (d: d.name) value)} ${name}=${builtins.toJSON (map (d: d.name) value)}
'') (lib.attrsToList systems); ''
)
(lib.attrsToList systems);
}; };
} }

View file

@ -1,6 +1,7 @@
{ {
outputs = inputs @ {flake-parts, ...}: outputs =
flake-parts.lib.mkFlake {inherit inputs;} { inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@ -18,13 +19,15 @@
./pkgs ./pkgs
]; ];
perSystem = { perSystem =
{
inputs', inputs',
self', self',
pkgs, pkgs,
lib, lib,
... ...
}: { }:
{
devShells.default = pkgs.mkShellNoCC { devShells.default = pkgs.mkShellNoCC {
packages = [ packages = [
inputs'.agenix.packages.agenix inputs'.agenix.packages.agenix
@ -45,7 +48,7 @@
# Re-export it for convenience and for caching # Re-export it for convenience and for caching
packages.attic = inputs'.attic.packages.attic; packages.attic = inputs'.attic.packages.attic;
formatter = pkgs.alejandra; formatter = pkgs.nixfmt-rfc-style;
}; };
}; };
@ -126,8 +129,7 @@
}; };
}; };
/* /* TODO: Uncomment once (if ever?) nixConfig makes sense in flakes
TODO: Uncomment once (if ever?) nixConfig makes sense in flakes
nixConfig = { nixConfig = {
extra-substituters = [ extra-substituters = [
"https://hyprland.cachix.org" "https://hyprland.cachix.org"

View file

@ -3,7 +3,8 @@
self, self,
inputs, inputs,
... ...
}: { }:
{
imports = [ imports = [
./kazuki ./kazuki
./hijiri-vm ./hijiri-vm
@ -15,15 +16,20 @@
./kogata ./kogata
]; ];
builders = let builders =
let
sharedOptions = { sharedOptions = {
_file = ./default.nix; _file = ./default.nix;
settei.sane-defaults.allSshKeys = config.assets.sshKeys.user; settei.sane-defaults.allSshKeys = config.assets.sshKeys.user;
settei.flake-qol.inputs = inputs // {settei = self;}; settei.flake-qol.inputs = inputs // {
settei = self;
}; };
in { };
nixos = name: module: in
{
nixos =
name: module:
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
modules = [ modules = [
inputs.agenix.nixosModules.age inputs.agenix.nixosModules.age
@ -40,7 +46,8 @@
specialArgs.configurationName = name; specialArgs.configurationName = name;
}; };
darwin = name: module: darwin =
name: module:
inputs.darwin.lib.darwinSystem { inputs.darwin.lib.darwinSystem {
modules = [ modules = [
inputs.agenix.darwinModules.age inputs.agenix.darwinModules.age

View file

@ -1,10 +1,12 @@
{ {
configurations.nixos.hijiri-vm = { configurations.nixos.hijiri-vm =
{
modulesPath, modulesPath,
lib, lib,
username, username,
... ...
}: { }:
{
imports = [ imports = [
"${modulesPath}/profiles/qemu-guest.nix" "${modulesPath}/profiles/qemu-guest.nix"
./disks.nix ./disks.nix

View file

@ -1,6 +1,8 @@
args: let args:
let
bootDevice = args.bootDevice or "/dev/vda"; bootDevice = args.bootDevice or "/dev/vda";
in { in
{
disko.devices.disk.bootDisk = { disko.devices.disk.bootDisk = {
type = "disk"; type = "disk";
device = bootDevice; device = bootDevice;
@ -26,10 +28,15 @@ in {
end = "100%"; end = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = ["-f"]; extraArgs = [ "-f" ];
subvolumes = let subvolumes =
mountOptions = ["compress=zstd" "noatime"]; let
in { mountOptions = [
"compress=zstd"
"noatime"
];
in
{
"/root" = { "/root" = {
inherit mountOptions; inherit mountOptions;
mountpoint = "/"; mountpoint = "/";

View file

@ -1,5 +1,7 @@
{ {
configurations.darwin.hijiri = {pkgs, ...}: { configurations.darwin.hijiri =
{ pkgs, ... }:
{
imports = [ imports = [
./skhd.nix ./skhd.nix
./yabai.nix ./yabai.nix

View file

@ -1,13 +1,22 @@
{lib, ...}: { { lib, ... }:
{
services.skhd = { services.skhd = {
enable = true; enable = true;
skhdConfig = let skhdConfig =
let
spaceCount = 6; spaceCount = 6;
spaceBindings = spaceBindings =
lib.genList lib.genList
(i: let num = toString (i + 1); in "cmd - ${num} : yabai -m space --focus ${num}") (
i:
let
num = toString (i + 1);
in
"cmd - ${num} : yabai -m space --focus ${num}"
)
spaceCount; spaceCount;
in '' in
''
cmd - return : wezterm cmd - return : wezterm
cmd + shift - return : qutebrowser cmd + shift - return : qutebrowser

View file

@ -1,8 +1,5 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
services.yabai = { services.yabai = {
enable = true; enable = true;
enableScriptingAddition = true; enableScriptingAddition = true;

View file

@ -1,14 +1,26 @@
{lib, ...}: { { lib, ... }:
configurations.nixos = let {
mkInstaller = system: ({pkgs, ...}: { configurations.nixos =
nixpkgs = {inherit system;}; let
mkInstaller =
system:
(
{ pkgs, ... }:
{
nixpkgs = {
inherit system;
};
environment.systemPackages = [pkgs.nixos-install-tools]; environment.systemPackages = [ pkgs.nixos-install-tools ];
# Make nixos-anywhere treat this as a installer iso # Make nixos-anywhere treat this as a installer iso
system.nixos.variant_id = "installer"; system.nixos.variant_id = "installer";
}); }
systems = ["aarch64-linux" "x86_64-linux"]; );
systems = [
"aarch64-linux"
"x86_64-linux"
];
installers = map (system: lib.nameValuePair "installer-${system}" (mkInstaller system)) systems; installers = map (system: lib.nameValuePair "installer-${system}" (mkInstaller system)) systems;
in in
lib.listToAttrs installers; lib.listToAttrs installers;

View file

@ -1,10 +1,8 @@
{ { config, lib, ... }:
config, let
lib,
...
}: let
atticPort = 9476; atticPort = 9476;
in { in
{
age.secrets.attic-creds = { age.secrets.attic-creds = {
file = ../../secrets/attic-creds.age; file = ../../secrets/attic-creds.age;
owner = config.services.atticd.user; owner = config.services.atticd.user;
@ -48,7 +46,7 @@ in {
}; };
systemd.services.atticd = { systemd.services.atticd = {
after = ["storage\\x2dbox.mount"]; after = [ "storage\\x2dbox.mount" ];
serviceConfig.DynamicUser = lib.mkForce false; serviceConfig.DynamicUser = lib.mkForce false;
}; };
@ -57,8 +55,11 @@ in {
defaults.email = "nikodem@rabulinski.com"; defaults.email = "nikodem@rabulinski.com";
}; };
users.users.nginx.extraGroups = ["acme"]; users.users.nginx.extraGroups = [ "acme" ];
networking.firewall.allowedTCPPorts = [80 443]; networking.firewall.allowedTCPPorts = [
80
443
];
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -94,7 +95,7 @@ in {
}; };
upstreams."attic".servers = { upstreams."attic".servers = {
"localhost:${toString atticPort}" = {}; "localhost:${toString atticPort}" = { };
}; };
appendHttpConfig = '' appendHttpConfig = ''

View file

@ -3,10 +3,12 @@
pkgs, pkgs,
inputs', inputs',
... ...
}: let }:
formatJson = pkgs.formats.json {}; let
formatJson = pkgs.formats.json { };
serverDomain = "matrix.nrab.lol"; serverDomain = "matrix.nrab.lol";
in { in
{
services.matrix-conduit = { services.matrix-conduit = {
enable = true; enable = true;
package = inputs'.settei.packages.conduit-next; package = inputs'.settei.packages.conduit-next;
@ -23,8 +25,13 @@ in {
defaults.email = "nikodem@rabulinski.com"; defaults.email = "nikodem@rabulinski.com";
}; };
users.users.nginx.extraGroups = ["acme"]; users.users.nginx.extraGroups = [ "acme" ];
networking.firewall.allowedTCPPorts = [80 443 8448 2222]; networking.firewall.allowedTCPPorts = [
80
443
8448
2222
];
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -35,9 +42,7 @@ in {
enableACME = true; enableACME = true;
locations."=/.well-known/matrix/server" = { locations."=/.well-known/matrix/server" = {
alias = formatJson.generate "well-known-matrix-server" { alias = formatJson.generate "well-known-matrix-server" { "m.server" = serverDomain; };
"m.server" = serverDomain;
};
extraConfig = '' extraConfig = ''
default_type application/json; default_type application/json;
add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Allow-Origin "*";
@ -95,7 +100,7 @@ in {
}; };
upstreams."backend_conduit".servers = { upstreams."backend_conduit".servers = {
"localhost:${toString config.services.matrix-conduit.settings.global.port}" = {}; "localhost:${toString config.services.matrix-conduit.settings.global.port}" = { };
}; };
}; };
} }

View file

@ -1,10 +1,12 @@
{ {
configurations.nixos.kazuki = { configurations.nixos.kazuki =
{
config, config,
modulesPath, modulesPath,
lib, lib,
... ...
}: { }:
{
imports = [ imports = [
"${modulesPath}/profiles/qemu-guest.nix" "${modulesPath}/profiles/qemu-guest.nix"
./disks.nix ./disks.nix
@ -30,8 +32,8 @@
systemd.network.networks."10-wan" = { systemd.network.networks."10-wan" = {
matchConfig.Name = "enp1s0"; matchConfig.Name = "enp1s0";
networkConfig.DHCP = "ipv4"; networkConfig.DHCP = "ipv4";
address = ["2a01:4f8:c012:e5c::/64"]; address = [ "2a01:4f8:c012:e5c::/64" ];
routes = [{routeConfig.Gateway = "fe80::1";}]; routes = [ { routeConfig.Gateway = "fe80::1"; } ];
}; };
networking.useNetworkd = true; networking.useNetworkd = true;

View file

@ -1,6 +1,8 @@
args: let args:
let
bootDevice = args.bootDevice or "/dev/sda"; bootDevice = args.bootDevice or "/dev/sda";
in { in
{
disko.devices.disk.bootDisk = { disko.devices.disk.bootDisk = {
type = "disk"; type = "disk";
device = bootDevice; device = bootDevice;
@ -26,10 +28,15 @@ in {
end = "-4G"; end = "-4G";
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = ["-f"]; extraArgs = [ "-f" ];
subvolumes = let subvolumes =
mountOptions = ["compress=zstd" "noatime"]; let
in { mountOptions = [
"compress=zstd"
"noatime"
];
in
{
"/root" = { "/root" = {
inherit mountOptions; inherit mountOptions;
mountpoint = "/"; mountpoint = "/";

View file

@ -1,12 +1,18 @@
{config, ...}: { { config, ... }:
{
# nix shell nixpkgs#apacheHttpd -c htpasswd -nbB "" "super secret password" | cut -d: -f2 # nix shell nixpkgs#apacheHttpd -c htpasswd -nbB "" "super secret password" | cut -d: -f2
age.secrets = { age.secrets = {
leet-nrab-lol.file = ../../secrets/leet-nrab-lol-pass.age; leet-nrab-lol.file = ../../secrets/leet-nrab-lol-pass.age;
alert-nrab-lol.file = ../../secrets/alert-nrab-lol-pass.age; alert-nrab-lol.file = ../../secrets/alert-nrab-lol-pass.age;
}; };
users.users.nginx.extraGroups = ["acme"]; users.users.nginx.extraGroups = [ "acme" ];
networking.firewall.allowedTCPPorts = [80 443 8448 2222]; networking.firewall.allowedTCPPorts = [
80
443
8448
2222
];
mailserver = { mailserver = {
enable = true; enable = true;
@ -21,7 +27,7 @@
loginAccounts = { loginAccounts = {
"1337@nrab.lol" = { "1337@nrab.lol" = {
hashedPasswordFile = config.age.secrets.leet-nrab-lol.path; hashedPasswordFile = config.age.secrets.leet-nrab-lol.path;
aliases = ["n@rab.lol"]; aliases = [ "n@rab.lol" ];
}; };
"alert@nrab.lol" = { "alert@nrab.lol" = {
hashedPasswordFile = config.age.secrets.alert-nrab-lol.path; hashedPasswordFile = config.age.secrets.alert-nrab-lol.path;
@ -34,5 +40,5 @@
}; };
# TODO: Remove once SNM gets their shit together # TODO: Remove once SNM gets their shit together
services.dovecot2.sieve.extensions = ["fileinto"]; services.dovecot2.sieve.extensions = [ "fileinto" ];
} }

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
age.secrets.nrab-lol-cf = { age.secrets.nrab-lol-cf = {
file = ../../secrets/nrab-lol-cf.age; file = ../../secrets/nrab-lol-cf.age;
owner = config.services.nginx.user; owner = config.services.nginx.user;
@ -15,8 +16,11 @@
}; };
}; };
users.users.nginx.extraGroups = ["acme"]; users.users.nginx.extraGroups = [ "acme" ];
networking.firewall.allowedTCPPorts = [80 443]; networking.firewall.allowedTCPPorts = [
80
443
];
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -35,7 +39,7 @@
}; };
upstreams.ntfy.servers = { upstreams.ntfy.servers = {
"localhost:9800" = {}; "localhost:9800" = { };
}; };
}; };

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
age.secrets.storage-box-webdav = { age.secrets.storage-box-webdav = {
file = ../../secrets/storage-box-webdav.age; file = ../../secrets/storage-box-webdav.age;
}; };

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
age.secrets.vault-cert-env = { age.secrets.vault-cert-env = {
file = ../../secrets/vault-cert-env.age; file = ../../secrets/vault-cert-env.age;
owner = config.services.nginx.user; owner = config.services.nginx.user;
@ -11,8 +12,13 @@
}; };
}; };
users.users.nginx.extraGroups = ["acme"]; users.users.nginx.extraGroups = [ "acme" ];
networking.firewall.allowedTCPPorts = [80 443 8448 2222]; networking.firewall.allowedTCPPorts = [
80
443
8448
2222
];
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -31,7 +37,7 @@
}; };
upstreams.vaultwarden.servers = { upstreams.vaultwarden.servers = {
"localhost:${toString config.services.vaultwarden.config.ROCKET_PORT}" = {}; "localhost:${toString config.services.vaultwarden.config.ROCKET_PORT}" = { };
}; };
}; };

View file

@ -1,17 +1,14 @@
{ {
configurations.darwin.kogata = { configurations.darwin.kogata =
pkgs, { pkgs, lib, ... }:
lib, {
...
}: {
nixpkgs.system = "aarch64-darwin"; nixpkgs.system = "aarch64-darwin";
settei.user.config.common.desktop.enable = true; settei.user.config.common.desktop.enable = true;
# TODO: Make it a settei module so it's easy to concatenate which pkgs are allowed # TODO: Make it a settei module so it's easy to concatenate which pkgs are allowed
nixpkgs.config.allowUnfreePredicate = pkg: nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "teams" ];
builtins.elem (lib.getName pkg) ["teams"]; environment.systemPackages = with pkgs; [ teams ];
environment.systemPackages = with pkgs; [teams];
common.hercules.enable = true; common.hercules.enable = true;
common.github-runner = { common.github-runner = {

View file

@ -1,10 +1,12 @@
{ {
configurations.nixos.legion = { configurations.nixos.legion =
{
config, config,
lib, lib,
username, username,
... ...
}: { }:
{
imports = [ imports = [
./hardware.nix ./hardware.nix
# ./disks.nix # ./disks.nix
@ -28,7 +30,7 @@
hostName = "legion"; hostName = "legion";
hostId = builtins.substring 0 8 (builtins.readFile ./machine-id); hostId = builtins.substring 0 8 (builtins.readFile ./machine-id);
networkmanager.enable = true; networkmanager.enable = true;
firewall.trustedInterfaces = ["tailscale0"]; firewall.trustedInterfaces = [ "tailscale0" ];
}; };
systemd.services.NetworkManager-wait-online.enable = false; systemd.services.NetworkManager-wait-online.enable = false;

View file

@ -5,13 +5,17 @@
lib, lib,
username, username,
... ...
}: { }:
{
# Needed for nvidia and steam # Needed for nvidia and steam
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
settei.user.config = { settei.user.config = {
common.desktop.enable = true; common.desktop.enable = true;
home.packages = with pkgs; [brightnessctl dmenu]; home.packages = with pkgs; [
brightnessctl
dmenu
];
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
enable = true; enable = true;
@ -32,14 +36,18 @@
enable = true; enable = true;
remotePlay.openFirewall = true; remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true; dedicatedServer.openFirewall = true;
gamescopeSession = {}; gamescopeSession = { };
}; };
hardware.steam-hardware.enable = true; hardware.steam-hardware.enable = true;
services.logind = services.logind =
lib.genAttrs lib.genAttrs
["lidSwitch" "lidSwitchDocked" "lidSwitchExternalPower"] [
"lidSwitch"
"lidSwitchDocked"
"lidSwitchExternalPower"
]
(_: "ignore"); (_: "ignore");
services.pipewire = { services.pipewire = {
@ -51,13 +59,16 @@
programs.dconf.enable = true; programs.dconf.enable = true;
services.dbus.enable = true; services.dbus.enable = true;
users.users.${username}.extraGroups = ["video" "input"]; users.users.${username}.extraGroups = [
"video"
"input"
];
# NVIDIA stuff # NVIDIA stuff
services.xserver = { services.xserver = {
enable = true; enable = true;
excludePackages = [pkgs.xterm]; excludePackages = [ pkgs.xterm ];
videoDrivers = ["nvidia"]; videoDrivers = [ "nvidia" ];
xkb.layout = "pl"; xkb.layout = "pl";
displayManager.startx.enable = true; displayManager.startx.enable = true;
config = lib.mkForce '' config = lib.mkForce ''

View file

@ -1,8 +1,7 @@
args: args:
/* /* let
let
bootDevice = args.bootDevice or "/dev/nvme0n1"; bootDevice = args.bootDevice or "/dev/nvme0n1";
in in
*/ */
{ {
assertions = [ assertions = [

View file

@ -1,8 +1,20 @@
{config, ...}: { { config, ... }:
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "uas"]; {
boot.extraModulePackages = with config.boot.kernelPackages; [acpi_call]; boot.initrd.availableKernelModules = [
boot.kernelModules = ["kvm-intel" "i2c-dev" "acpi_call"]; "xhci_pci"
boot.blacklistedKernelModules = ["nouveau"]; "ahci"
"nvme"
"usbhid"
"usb_storage"
"uas"
];
boot.extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
boot.kernelModules = [
"kvm-intel"
"i2c-dev"
"acpi_call"
];
boot.blacklistedKernelModules = [ "nouveau" ];
# Needed for enableAllFirmware # Needed for enableAllFirmware
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@ -15,37 +27,57 @@
# TODO: Move to disko only # TODO: Move to disko only
# TODO: Actually set up impermanence # TODO: Actually set up impermanence
boot.supportedFilesystems = ["btrfs"]; boot.supportedFilesystems = [ "btrfs" ];
boot.initrd.luks.devices."enc".device = "/dev/disk/by-label/LUKS"; boot.initrd.luks.devices."enc".device = "/dev/disk/by-label/LUKS";
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-label/LINUX"; device = "/dev/disk/by-label/LINUX";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=root" "compress=zstd" "noatime"]; options = [
"subvol=root"
"compress=zstd"
"noatime"
];
}; };
fileSystems."/home" = { fileSystems."/home" = {
device = "/dev/disk/by-label/LINUX"; device = "/dev/disk/by-label/LINUX";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=home" "compress=zstd" "noatime"]; options = [
"subvol=home"
"compress=zstd"
"noatime"
];
}; };
fileSystems."/nix" = { fileSystems."/nix" = {
device = "/dev/disk/by-label/LINUX"; device = "/dev/disk/by-label/LINUX";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=nix" "compress=zstd" "noatime"]; options = [
"subvol=nix"
"compress=zstd"
"noatime"
];
}; };
fileSystems."/persist" = { fileSystems."/persist" = {
device = "/dev/disk/by-label/LINUX"; device = "/dev/disk/by-label/LINUX";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=persist" "compress=zstd" "noatime"]; options = [
"subvol=persist"
"compress=zstd"
"noatime"
];
}; };
fileSystems."/var/log" = { fileSystems."/var/log" = {
device = "/dev/disk/by-label/LINUX"; device = "/dev/disk/by-label/LINUX";
fsType = "btrfs"; fsType = "btrfs";
options = ["subvol=log" "compress=zstd" "noatime"]; options = [
"subvol=log"
"compress=zstd"
"noatime"
];
neededForBoot = true; neededForBoot = true;
}; };
@ -54,7 +86,5 @@
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ swapDevices = [ { device = "/dev/disk/by-label/SWAP"; } ];
{device = "/dev/disk/by-label/SWAP";}
];
} }

View file

@ -4,13 +4,15 @@
config, config,
username, username,
... ...
}: let }:
let
mail = "alert@nrab.lol"; mail = "alert@nrab.lol";
aliases = pkgs.writeText "mail-aliases" '' aliases = pkgs.writeText "mail-aliases" ''
${username}: nikodem@rabulinski.com ${username}: nikodem@rabulinski.com
root: ${mail} root: ${mail}
''; '';
in { in
{
age.secrets.alert-plaintext.file = ../../secrets/alert-plain-pass.age; age.secrets.alert-plaintext.file = ../../secrets/alert-plain-pass.age;
programs.msmtp = { programs.msmtp = {

View file

@ -3,19 +3,21 @@
lib, lib,
username, username,
... ...
}: { }:
imports = [ {
./media.nix imports = [ ./media.nix ];
boot.supportedFilesystems = [
"ext4"
"zfs"
]; ];
boot.supportedFilesystems = ["ext4" "zfs"]; boot.zfs.extraPools = [ "yottapool" ];
boot.zfs.extraPools = ["yottapool"];
services.zfs = { services.zfs = {
autoScrub.enable = true; autoScrub.enable = true;
zed.settings = { zed.settings = {
ZED_DEBUG_LOG = "/tmp/zed.debug.log"; ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_EMAIL_ADDR = [username]; ZED_EMAIL_ADDR = [ username ];
ZED_EMAIL_PROG = lib.getExe pkgs.msmtp; ZED_EMAIL_PROG = lib.getExe pkgs.msmtp;
ZED_EMAIL_OPTS = "@ADDRESS@"; ZED_EMAIL_OPTS = "@ADDRESS@";
@ -38,8 +40,8 @@
options = "bind,nofail"; options = "bind,nofail";
what = "/media/data"; what = "/media/data";
where = "/export/yotta-data"; where = "/export/yotta-data";
requires = ["zfs-mount.service"]; requires = [ "zfs-mount.service" ];
wantedBy = ["multi-user.target"]; wantedBy = [ "multi-user.target" ];
} }
]; ];

View file

@ -1,4 +1,5 @@
{username, ...}: { { username, ... }:
{
services.jellyfin.enable = true; services.jellyfin.enable = true;
services.radarr.enable = true; services.radarr.enable = true;
services.sonarr.enable = true; services.sonarr.enable = true;
@ -10,9 +11,12 @@
}; };
users.users = { users.users = {
jellyfin.extraGroups = ["radarr" "sonarr"]; jellyfin.extraGroups = [
radarr.extraGroups = ["deluge"]; "radarr"
sonarr.extraGroups = ["deluge"]; "sonarr"
${username}.extraGroups = ["deluge"]; ];
radarr.extraGroups = [ "deluge" ];
sonarr.extraGroups = [ "deluge" ];
${username}.extraGroups = [ "deluge" ];
}; };
} }

View file

@ -1,10 +1,12 @@
{ {
configurations.nixos.ude = { configurations.nixos.ude =
{
config, config,
modulesPath, modulesPath,
lib, lib,
... ...
}: { }:
{
imports = [ imports = [
"${modulesPath}/profiles/qemu-guest.nix" "${modulesPath}/profiles/qemu-guest.nix"
./disks.nix ./disks.nix
@ -34,6 +36,6 @@
include /impure/nginx/*.conf; include /impure/nginx/*.conf;
''; '';
}; };
networking.firewall.allowedTCPPorts = [80]; networking.firewall.allowedTCPPorts = [ 80 ];
}; };
} }

View file

@ -1,6 +1,8 @@
args: let args:
let
bootDevice = args.bootDevice or "/dev/sda"; bootDevice = args.bootDevice or "/dev/sda";
in { in
{
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
@ -24,10 +26,15 @@ in {
size = "100%"; size = "100%";
content = { content = {
type = "btrfs"; type = "btrfs";
extraArgs = ["-f"]; extraArgs = [ "-f" ];
subvolumes = let subvolumes =
mountOptions = ["compress=zstd" "noatime"]; let
in { mountOptions = [
"compress=zstd"
"noatime"
];
in
{
"/root" = { "/root" = {
mountpoint = "/"; mountpoint = "/";
inherit mountOptions; inherit mountOptions;

View file

@ -2,13 +2,15 @@
nixpkgs, nixpkgs,
darwin, darwin,
home-manager, home-manager,
}: { }:
{
config, config,
lib, lib,
flake-parts-lib, flake-parts-lib,
... ...
}: }:
with lib; { with lib;
{
_file = ./configurations.nix; _file = ./configurations.nix;
options = { options = {
@ -32,31 +34,22 @@ with lib; {
configurations = { configurations = {
nixos = mkOption { nixos = mkOption {
type = types.lazyAttrsOf types.deferredModule; type = types.lazyAttrsOf types.deferredModule;
default = {}; default = { };
}; };
darwin = mkOption { darwin = mkOption {
type = types.lazyAttrsOf types.deferredModule; type = types.lazyAttrsOf types.deferredModule;
default = {}; default = { };
}; };
home = mkOption { home = mkOption {
type = types.lazyAttrsOf types.deferredModule; type = types.lazyAttrsOf types.deferredModule;
default = {}; default = { };
}; };
}; };
}; };
config.flake = { config.flake = {
nixosConfigurations = nixosConfigurations = mapAttrs config.builders.nixos config.configurations.nixos;
mapAttrs darwinConfigurations = mapAttrs config.builders.darwin config.configurations.darwin;
config.builders.nixos homeConfigurations = mapAttrs config.builders.home config.configurations.home;
config.configurations.nixos;
darwinConfigurations =
mapAttrs
config.builders.darwin
config.configurations.darwin;
homeConfigurations =
mapAttrs
config.builders.home
config.configurations.home;
}; };
} }

View file

@ -3,13 +3,17 @@
lib, lib,
inputs, inputs,
... ...
}: let }:
let
inherit (flake-parts-lib) importApply; inherit (flake-parts-lib) importApply;
flakeModules = { flakeModules = {
configurations = importApply ./configurations.nix {inherit (inputs) nixpkgs darwin home-manager;}; configurations = importApply ./configurations.nix { inherit (inputs) nixpkgs darwin home-manager; };
}; };
in { in
{
imports = lib.attrValues flakeModules; imports = lib.attrValues flakeModules;
flake = {inherit flakeModules;}; flake = {
inherit flakeModules;
};
} }

View file

@ -6,13 +6,15 @@
inputs', inputs',
machineName, machineName,
... ...
} @ args: let }@args:
let
# TODO: Conditionally define based on whether we're in a system configuration or not # TODO: Conditionally define based on whether we're in a system configuration or not
fishOverlayModule = lib.mkIf (!args ? osConfig) { fishOverlayModule = lib.mkIf (!args ? osConfig) {
# See modules/system/common/default.nix for reasoning. # See modules/system/common/default.nix for reasoning.
nixpkgs.overlays = [(_: _: {inherit (inputs'.settei.packages) fish;})]; nixpkgs.overlays = [ (_: _: { inherit (inputs'.settei.packages) fish; }) ];
}; };
in { in
{
_file = ./default.nix; _file = ./default.nix;
imports = [ imports = [
@ -49,7 +51,10 @@ in {
}; };
}; };
home.packages = [inputs'.settei.packages.base-packages pkgs.nh]; home.packages = [
inputs'.settei.packages.base-packages
pkgs.nh
];
home.sessionVariables.EDITOR = "hx"; home.sessionVariables.EDITOR = "hx";
} }

View file

@ -5,7 +5,8 @@
inputs, inputs,
inputs', inputs',
... ...
}: { }:
{
_file = ./default.nix; _file = ./default.nix;
options.common.desktop = { options.common.desktop = {
@ -23,7 +24,8 @@
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = let package =
let
firefox-pkgs = pkgs.extend inputs.firefox-darwin.overlay; firefox-pkgs = pkgs.extend inputs.firefox-darwin.overlay;
in in
lib.mkIf pkgs.stdenv.isDarwin firefox-pkgs.firefox-bin; lib.mkIf pkgs.stdenv.isDarwin firefox-pkgs.firefox-bin;
@ -32,9 +34,7 @@
programs.qutebrowser = { programs.qutebrowser = {
enable = true; enable = true;
package = package =
if pkgs.stdenv.isDarwin if pkgs.stdenv.isDarwin then inputs'.niko-nur.packages.qutebrowser-bin else pkgs.qutebrowser;
then inputs'.niko-nur.packages.qutebrowser-bin
else pkgs.qutebrowser;
}; };
programs.zellij = { programs.zellij = {
@ -42,7 +42,7 @@
settings = { settings = {
keybinds = { keybinds = {
shared_except = { shared_except = {
_args = ["locked"]; _args = [ "locked" ];
unbind = "Ctrl q"; unbind = "Ctrl q";
}; };
}; };

View file

@ -1,4 +1,5 @@
{isLinux}: { { isLinux }:
{
config, config,
configurationName, configurationName,
lib, lib,
@ -7,7 +8,8 @@
inputs', inputs',
username, username,
... ...
}: let }:
let
sharedConfig = { sharedConfig = {
settei = { settei = {
username = lib.mkDefault "niko"; username = lib.mkDefault "niko";
@ -20,7 +22,7 @@
enable = lib.mkDefault true; enable = lib.mkDefault true;
# TODO: Move to settei or leave here? # TODO: Move to settei or leave here?
extraArgs.machineName = configurationName; extraArgs.machineName = configurationName;
config.imports = [inputs.settei.homeModules.common]; config.imports = [ inputs.settei.homeModules.common ];
}; };
}; };
@ -31,7 +33,7 @@
# NixOS' fish module doesn't allow setting what package to use for fish, # NixOS' fish module doesn't allow setting what package to use for fish,
# so I need to override the fish package. # so I need to override the fish package.
nixpkgs.overlays = [(_: _: {inherit (inputs'.settei.packages) fish;})]; nixpkgs.overlays = [ (_: _: { inherit (inputs'.settei.packages) fish; }) ];
nix.settings.allow-import-from-derivation = false; nix.settings.allow-import-from-derivation = false;
}; };
@ -53,15 +55,16 @@
system.stateVersion = 4; system.stateVersion = 4;
# Every macOS ARM machine can emulate x86. # Every macOS ARM machine can emulate x86.
nix.settings.extra-platforms = lib.mkIf pkgs.stdenv.isAarch64 ["x86_64-darwin"]; nix.settings.extra-platforms = lib.mkIf pkgs.stdenv.isAarch64 [ "x86_64-darwin" ];
}; };
in { in
{
_file = ./default.nix; _file = ./default.nix;
imports = [ imports = [
(import ./hercules.nix {inherit isLinux;}) (import ./hercules.nix { inherit isLinux; })
(import ./user.nix {inherit isLinux;}) (import ./user.nix { inherit isLinux; })
(import ./github-runner.nix {inherit isLinux;}) (import ./github-runner.nix { inherit isLinux; })
]; ];
config = lib.mkMerge [ config = lib.mkMerge [

View file

@ -1,9 +1,11 @@
{isLinux}: { { isLinux }:
{
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
inherit (lib) mkOption types; inherit (lib) mkOption types;
github-runner-user = "github-runner"; github-runner-user = "github-runner";
@ -20,10 +22,10 @@
services.github-runners = lib.pipe cfg.runners [ services.github-runners = lib.pipe cfg.runners [
(lib.mapAttrsToList ( (lib.mapAttrsToList (
name: cfg: name: cfg:
lib.genList (i: lib.genList
lib.nameValuePair (
"${name}-${toString i}" i:
{ lib.nameValuePair "${name}-${toString i}" {
enable = true; enable = true;
tokenFile = config.age.secrets.github-token.path; tokenFile = config.age.secrets.github-token.path;
inherit (cfg) url; inherit (cfg) url;
@ -32,8 +34,9 @@
serviceOverrides = { serviceOverrides = {
DynamicUser = false; DynamicUser = false;
}; };
extraLabels = ["nix"]; extraLabels = [ "nix" ];
}) }
)
cfg.instances cfg.instances
)) ))
lib.flatten lib.flatten
@ -45,41 +48,48 @@
isSystemUser = true; isSystemUser = true;
group = github-runner-user; group = github-runner-user;
}; };
groups.${github-runner-user} = {}; groups.${github-runner-user} = { };
}; };
}; };
darwinConfig = lib.optionalAttrs (!isLinux) { darwinConfig = lib.optionalAttrs (!isLinux) {
warnings = lib.singleton "common.github-runner doesn't do anything on darwin yet"; warnings = lib.singleton "common.github-runner doesn't do anything on darwin yet";
}; };
in { in
{
_file = ./github-runner.nix; _file = ./github-runner.nix;
options.common.github-runner = { options.common.github-runner = {
enable = lib.mkEnableOption "using this machine as a self-hosted github runner"; enable = lib.mkEnableOption "using this machine as a self-hosted github runner";
runners = mkOption { runners = mkOption {
type = with types; type =
attrsOf (submodule ({name, ...}: { with types;
attrsOf (
submodule (
{ name, ... }:
{
options = { options = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "${name}-${config.networking.hostName}"; default = "${name}-${config.networking.hostName}";
}; };
url = mkOption { url = mkOption { type = types.str; };
type = types.str;
};
instances = mkOption { instances = mkOption {
type = types.int; type = types.int;
default = 1; default = 1;
}; };
}; };
})); }
)
);
}; };
}; };
config = lib.mkIf cfg.enable (lib.mkMerge [ config = lib.mkIf cfg.enable (
lib.mkMerge [
sharedConfig sharedConfig
linuxConfig linuxConfig
darwinConfig darwinConfig
]); ]
);
} }

View file

@ -1,27 +1,29 @@
{isLinux}: { { isLinux }:
{
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: let }:
let
options = { options = {
common.hercules.enable = lib.mkEnableOption "Enables hercules-ci-agent with my configuration"; common.hercules.enable = lib.mkEnableOption "Enables hercules-ci-agent with my configuration";
}; };
herculesUser = herculesUser =
if isLinux if isLinux then
then config.systemd.services.hercules-ci-agent.serviceConfig.User config.systemd.services.hercules-ci-agent.serviceConfig.User
else config.launchd.daemons.hercules-ci-agent.serviceConfig.UserName; else
in { config.launchd.daemons.hercules-ci-agent.serviceConfig.UserName;
in
{
_file = ./hercules.nix; _file = ./hercules.nix;
inherit options; inherit options;
config = config =
lib.mkIf false lib.mkIf false
/* # config.common.hercules.enable
config.common.hercules.enable
*/
{ {
age.secrets.hercules-token = { age.secrets.hercules-token = {
file = ../../../secrets/hercules-token.age; file = ../../../secrets/hercules-token.age;

View file

@ -1,24 +1,21 @@
{isLinux}: { { isLinux }:
config, { config, lib, ... }:
lib, let
...
}: let
sharedConfig = { sharedConfig = {
settei.programs.podman.enable = true; settei.programs.podman.enable = true;
}; };
linuxConfig = lib.optionalAttrs isLinux { linuxConfig = lib.optionalAttrs isLinux { boot.kernel.sysctl."kernel.yama.ptrace_scope" = 0; };
boot.kernel.sysctl."kernel.yama.ptrace_scope" = 0;
};
darwinConfig = lib.optionalAttrs (!isLinux) {}; darwinConfig = lib.optionalAttrs (!isLinux) { };
finalConfig = lib.mkMerge [ finalConfig = lib.mkMerge [
sharedConfig sharedConfig
linuxConfig linuxConfig
darwinConfig darwinConfig
]; ];
in { in
{
_file = ./user.nix; _file = ./user.nix;
config = lib.mkIf config.settei.user.enable finalConfig; config = lib.mkIf config.settei.user.enable finalConfig;

View file

@ -1,17 +1,22 @@
{ config, lib, ... }:
{ {
config, flake =
lib, lib.genAttrs
... [
}: { "nixosModules"
flake = lib.genAttrs ["nixosModules" "darwinModules"] (attr: let "darwinModules"
]
(
attr:
let
isLinux = lib.hasPrefix "nixos" attr; isLinux = lib.hasPrefix "nixos" attr;
in { in
{
settei = import ./settei { settei = import ./settei {
inherit (config) perInput; inherit (config) perInput;
inherit isLinux; inherit isLinux;
}; };
common = import ./common { common = import ./common { inherit isLinux; };
inherit isLinux; }
}; );
});
} }

View file

@ -2,25 +2,25 @@
perInput, perInput,
# TODO: Figure out a nicer way of doing this without infrec? # TODO: Figure out a nicer way of doing this without infrec?
isLinux, isLinux,
}: { }:
{
lib, lib,
pkgs, pkgs,
config, config,
options, options,
... ...
}: { }:
{
_file = ./default.nix; _file = ./default.nix;
imports = [ imports = [
(import ./sane-defaults.nix {inherit isLinux;}) (import ./sane-defaults.nix { inherit isLinux; })
(import ./flake-qol.nix {inherit perInput;}) (import ./flake-qol.nix { inherit perInput; })
./user.nix ./user.nix
(import ./programs {inherit isLinux;}) (import ./programs { inherit isLinux; })
]; ];
options.settei = with lib; { options.settei = with lib; {
username = mkOption { username = mkOption { type = types.str; };
type = types.str;
};
}; };
} }

View file

@ -1,11 +1,14 @@
{perInput}: { { perInput }:
{
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
cfg = config.settei.flake-qol; cfg = config.settei.flake-qol;
in { in
{
_file = ./flake-qol.nix; _file = ./flake-qol.nix;
options.settei.flake-qol = with lib; { options.settei.flake-qol = with lib; {
@ -14,9 +17,7 @@ in {
type = types.bool; type = types.bool;
default = true; default = true;
}; };
inputs = mkOption { inputs = mkOption { type = types.unspecified; };
type = types.unspecified;
};
inputs-flakes = mkOption { inputs-flakes = mkOption {
type = types.attrs; type = types.attrs;
readOnly = true; readOnly = true;
@ -27,10 +28,9 @@ in {
}; };
}; };
config = let config =
reexportedArgs = lib.mkIf cfg.reexportAsArgs { let
inherit (cfg) inputs inputs-flakes inputs'; reexportedArgs = lib.mkIf cfg.reexportAsArgs { inherit (cfg) inputs inputs-flakes inputs'; };
};
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
settei.flake-qol = { settei.flake-qol = {
@ -42,7 +42,7 @@ in {
settei.user.extraArgs = reexportedArgs; settei.user.extraArgs = reexportedArgs;
nix = { nix = {
registry = lib.mapAttrs (_: flake: {inherit flake;}) cfg.inputs-flakes; registry = lib.mapAttrs (_: flake: { inherit flake; }) cfg.inputs-flakes;
nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes; nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes;
}; };
}; };

View file

@ -1,7 +1,6 @@
{isLinux}: { { isLinux }:
{
_file = ./default.nix; _file = ./default.nix;
imports = [ imports = [ (import ./podman.nix { inherit isLinux; }) ];
(import ./podman.nix {inherit isLinux;})
];
} }

View file

@ -1,11 +1,13 @@
{isLinux}: { { isLinux }:
{
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
sharedConfig = { sharedConfig = {
environment.systemPackages = [pkgs.podman-compose]; environment.systemPackages = [ pkgs.podman-compose ];
}; };
linuxConfig = lib.optionalAttrs isLinux { linuxConfig = lib.optionalAttrs isLinux {
@ -16,16 +18,15 @@
}; };
}; };
darwinConfig = lib.optionalAttrs (!isLinux) { darwinConfig = lib.optionalAttrs (!isLinux) { environment.systemPackages = [ pkgs.podman ]; };
environment.systemPackages = [pkgs.podman];
};
finalConfig = lib.mkMerge [ finalConfig = lib.mkMerge [
sharedConfig sharedConfig
linuxConfig linuxConfig
darwinConfig darwinConfig
]; ];
in { in
{
_file = ./podman.nix; _file = ./podman.nix;
options.settei.programs.podman.enable = lib.mkEnableOption "Podman"; options.settei.programs.podman.enable = lib.mkEnableOption "Podman";

View file

@ -1,8 +1,6 @@
{isLinux}: { { isLinux }:
config, { config, lib, ... }@args:
lib, let
...
} @ args: let
cfg = config.settei.sane-defaults; cfg = config.settei.sane-defaults;
inherit (config.settei) username; inherit (config.settei) username;
@ -11,7 +9,7 @@
enable = mkEnableOption "Personal sane defaults (but they should make sense for anyone)"; enable = mkEnableOption "Personal sane defaults (but they should make sense for anyone)";
allSshKeys = mkOption { allSshKeys = mkOption {
type = types.attrsOf types.singleLineStr; type = types.attrsOf types.singleLineStr;
default = {}; default = { };
}; };
tailnet = mkOption { tailnet = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -20,9 +18,11 @@
}; };
}; };
sharedConfig = let sharedConfig =
let
adminNeedsPassword = isLinux -> config.security.sudo.wheelNeedsPassword; adminNeedsPassword = isLinux -> config.security.sudo.wheelNeedsPassword;
in { in
{
_module.args = { _module.args = {
username = lib.mkDefault username; username = lib.mkDefault username;
}; };
@ -39,18 +39,25 @@
settei.user.config.programs.git.enable = lib.mkDefault true; settei.user.config.programs.git.enable = lib.mkDefault true;
# FIXME: Move to common # FIXME: Move to common
users.users.${username}.openssh.authorizedKeys.keys = let users.users.${username}.openssh.authorizedKeys.keys =
let
configName' = configName' =
args.configurationName args.configurationName
or (throw "pass configurationName to module arguments or set users.users.${username}.openssh.authorizedKeys yourself"); or (throw "pass configurationName to module arguments or set users.users.${username}.openssh.authorizedKeys yourself"
);
filteredKeys = lib.filterAttrs (name: _: name != configName') cfg.allSshKeys; filteredKeys = lib.filterAttrs (name: _: name != configName') cfg.allSshKeys;
in in
lib.mkDefault (lib.attrValues filteredKeys); lib.mkDefault (lib.attrValues filteredKeys);
nix = { nix = {
settings = { settings = {
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"]; experimental-features = [
trusted-users = lib.optionals (!adminNeedsPassword) [username]; "nix-command"
"flakes"
"repl-flake"
"auto-allocate-uids"
];
trusted-users = lib.optionals (!adminNeedsPassword) [ username ];
auto-allocate-uids = true; auto-allocate-uids = true;
extra-substituters = [ extra-substituters = [
"https://hyprland.cachix.org" "https://hyprland.cachix.org"
@ -72,9 +79,11 @@
}; };
}; };
linuxConfig = lib.optionalAttrs isLinux (let linuxConfig = lib.optionalAttrs isLinux (
let
nmEnabled = config.networking.networkmanager.enable; nmEnabled = config.networking.networkmanager.enable;
in { in
{
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
services.openssh.enable = true; services.openssh.enable = true;
@ -87,9 +96,9 @@
isNormalUser = true; isNormalUser = true;
home = "/home/${username}"; home = "/home/${username}";
group = username; group = username;
extraGroups = ["wheel"]; extraGroups = [ "wheel" ];
}; };
groups.${username} = {}; groups.${username} = { };
}; };
# TODO: Actually this should be extraRules which makes wheel users without any password set # TODO: Actually this should be extraRules which makes wheel users without any password set
@ -104,14 +113,13 @@
"1.1.1.1" "1.1.1.1"
"1.0.0.1" "1.0.0.1"
]; ];
search = [cfg.tailnet]; search = [ cfg.tailnet ];
}; };
# NetworkManager probably means desktop system so we don't want to slow down boot times # NetworkManager probably means desktop system so we don't want to slow down boot times
systemd.services = lib.mkIf nmEnabled { systemd.services = lib.mkIf nmEnabled { NetworkManager-wait-online.enable = false; };
NetworkManager-wait-online.enable = false; }
}; );
});
darwinConfig = lib.optionalAttrs (!isLinux) { darwinConfig = lib.optionalAttrs (!isLinux) {
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
@ -120,14 +128,17 @@
users.users.${username}.home = "/Users/${username}"; users.users.${username}.home = "/Users/${username}";
}; };
in { in
{
_file = ./sane-defaults.nix; _file = ./sane-defaults.nix;
inherit options; inherit options;
config = lib.mkIf config.settei.sane-defaults.enable (lib.mkMerge [ config = lib.mkIf config.settei.sane-defaults.enable (
lib.mkMerge [
sharedConfig sharedConfig
linuxConfig linuxConfig
darwinConfig darwinConfig
]); ]
);
} }

View file

@ -3,39 +3,40 @@
options, options,
lib, lib,
... ...
} @ args: let }@args:
let
hasHomeManager = options ? home-manager; hasHomeManager = options ? home-manager;
cfg = config.settei.user; cfg = config.settei.user;
inherit (config.settei) username; inherit (config.settei) username;
in { in
{
_file = ./user.nix; _file = ./user.nix;
options.settei.user = with lib; { options.settei.user = with lib; {
enable = mkEnableOption "User-specific configuration"; enable = mkEnableOption "User-specific configuration";
config = mkOption { config = mkOption {
type = types.deferredModule; type = types.deferredModule;
default = {}; default = { };
}; };
extraArgs = mkOption { extraArgs = mkOption {
type = types.attrs; type = types.attrs;
default = {}; default = { };
}; };
}; };
config = let config =
let
hmConfig = lib.optionalAttrs hasHomeManager { hmConfig = lib.optionalAttrs hasHomeManager {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = home-manager.extraSpecialArgs = {
{
inherit (args) inputs inputs'; inherit (args) inputs inputs';
} } // cfg.extraArgs;
// cfg.extraArgs;
home-manager.users.${username} = { home-manager.users.${username} = {
_file = ./user.nix; _file = ./user.nix;
imports = [cfg.config]; imports = [ cfg.config ];
home = { home = {
inherit username; inherit username;
@ -47,7 +48,8 @@ in {
}; };
}; };
in in
lib.mkIf cfg.enable (lib.mkMerge [ lib.mkIf cfg.enable (
lib.mkMerge [
{ {
assertions = [ assertions = [
{ {
@ -57,5 +59,6 @@ in {
]; ];
} }
hmConfig hmConfig
]); ]
);
} }

View file

@ -8,19 +8,21 @@
rocksdb, rocksdb,
darwin, darwin,
rustPlatform, rustPlatform,
}: let }:
rust = with fenix; let
rust =
with fenix;
combine [ combine [
stable.cargo stable.cargo
stable.rustc stable.rustc
]; ];
crane' = crane.overrideToolchain rust; crane' = crane.overrideToolchain rust;
in in
crane'.buildPackage { crane'.buildPackage {
inherit src; inherit src;
strictDeps = true; strictDeps = true;
nativeBuildInputs = [rustPlatform.bindgenHook]; nativeBuildInputs = [ rustPlatform.bindgenHook ];
buildInputs = lib.optionals stdenv.isDarwin [ buildInputs = lib.optionals stdenv.isDarwin [
libiconv libiconv
@ -31,4 +33,4 @@ in
# Use system RocksDB # Use system RocksDB
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include"; ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
ROCKSDB_LIB_DIR = "${rocksdb}/lib"; ROCKSDB_LIB_DIR = "${rocksdb}/lib";
} }

View file

@ -1,10 +1,13 @@
{inputs, ...}: { { inputs, ... }:
perSystem = { {
perSystem =
{
pkgs, pkgs,
system, system,
inputs', inputs',
... ...
}: { }:
{
packages.conduit-next = pkgs.callPackage ./conduit { packages.conduit-next = pkgs.callPackage ./conduit {
src = inputs.conduit-src; src = inputs.conduit-src;
crane = inputs.crane.lib.${system}; crane = inputs.crane.lib.${system};

View file

@ -1,6 +1,7 @@
let let
keys = import ../assets/ssh.nix; keys = import ../assets/ssh.nix;
in { in
{
"leet-nrab-lol-pass.age".publicKeys = [ "leet-nrab-lol-pass.age".publicKeys = [
keys.system.kazuki keys.system.kazuki
keys.other.bootstrap keys.other.bootstrap

View file

@ -1,9 +1,8 @@
{inputs, ...}: { { inputs, ... }:
perSystem = { {
pkgs, perSystem =
inputs', { pkgs, inputs', ... }:
... let
}: let
wrapped = inputs.wrapper-manager-hm-compat.lib { wrapped = inputs.wrapper-manager-hm-compat.lib {
inherit pkgs; inherit pkgs;
modules = [ modules = [
@ -19,8 +18,8 @@
}; };
}; };
all-packages = wrapped.config.build.packages; all-packages = wrapped.config.build.packages;
in { in
packages = {
all-packages; packages = all-packages;
}; };
} }

View file

@ -1,20 +1,19 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
wrappers.fish = { wrappers.fish = {
basePackage = pkgs.fish; basePackage = pkgs.fish;
wrapByDefault = false; wrapByDefault = false;
programs.fish = {config, ...}: { programs.fish =
{ config, ... }:
{
extraWrapperFlags = "--inherit-argv0"; extraWrapperFlags = "--inherit-argv0";
prependFlags = let prependFlags =
let
# Can't rely on pathAdd because fish used as login shell will ignore the variables the wrapper sets up # Can't rely on pathAdd because fish used as login shell will ignore the variables the wrapper sets up
path-add-lines = path-add-lines =
lib.concatMapStringsSep "\n" lib.concatMapStringsSep "\n" (pkg: "fish_add_path --path --prepend '${lib.getExe' pkg ""}'")
(pkg: "fish_add_path --path --prepend '${lib.getExe' pkg ""}'")
config.pathAdd; config.pathAdd;
config-fish = pkgs.writeText "config.fish" '' config-fish = pkgs.writeText "config.fish" ''
${path-add-lines} ${path-add-lines}
@ -22,12 +21,20 @@
source ${./prompt.fish} source ${./prompt.fish}
source ${./config.fish} source ${./config.fish}
''; '';
in [ in
[
"-C" "-C"
"source ${config-fish}" "source ${config-fish}"
]; ];
pathAdd = with pkgs; [eza bat fzf ripgrep zoxide direnv]; pathAdd = with pkgs; [
eza
bat
fzf
ripgrep
zoxide
direnv
];
}; };
}; };
} }

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.helix = { programs.helix = {
enable = true; enable = true;
settings = { settings = {
@ -25,8 +26,8 @@
{ {
name = "koka"; name = "koka";
scope = "scope.koka"; scope = "scope.koka";
file-types = ["kk"]; file-types = [ "kk" ];
roots = []; roots = [ ];
indent = { indent = {
tab-width = 4; tab-width = 4;
unit = " "; unit = " ";
@ -43,5 +44,5 @@
}; };
}; };
wrappers.helix.pathAdd = [pkgs.nil]; wrappers.helix.pathAdd = [ pkgs.nil ];
} }

View file

@ -3,8 +3,10 @@
inputs', inputs',
config, config,
... ...
}: { }:
wrappers.rash = let {
wrappers.rash =
let
readlinePatched = pkgs.fetchFromGitHub { readlinePatched = pkgs.fetchFromGitHub {
owner = "nrabulinski"; owner = "nrabulinski";
repo = "readline"; repo = "readline";
@ -12,12 +14,10 @@
hash = "sha256-1yU0ZUBQqYEn85j4T2pLs02MTyJnO5BbYALIa88iomY="; hash = "sha256-1yU0ZUBQqYEn85j4T2pLs02MTyJnO5BbYALIa88iomY=";
}; };
racket-with-libs = inputs'.racket.packages.racket.newLayer { racket-with-libs = inputs'.racket.packages.racket.newLayer {
withRacketPackages = ps: withRacketPackages =
with ps; [ ps: with ps; [
readline-gpl readline-gpl
(readline-lib.override { (readline-lib.override { src = "${readlinePatched}/readline-lib"; })
src = "${readlinePatched}/readline-lib";
})
rash rash
threading threading
functional functional
@ -37,9 +37,10 @@
profile-lib profile-lib
images-gui-lib images-gui-lib
]; ];
buildInputs = with pkgs; [readline]; buildInputs = with pkgs; [ readline ];
}; };
in { in
{
basePackage = pkgs.writeShellScriptBin "rash-repl" '' basePackage = pkgs.writeShellScriptBin "rash-repl" ''
exec "${racket-with-libs}/bin/rash-repl" "$@" exec "${racket-with-libs}/bin/rash-repl" "$@"
''; '';

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
wrappers.wezterm = { wrappers.wezterm = {
basePackage = pkgs.wezterm; basePackage = pkgs.wezterm;
env.WEZTERM_CONFIG_FILE.value = ./config.lua; env.WEZTERM_CONFIG_FILE.value = ./config.lua;