Migrated legion over. Started migrating hijiri

This commit is contained in:
Nikodem Rabuliński 2023-09-20 09:47:17 +02:00
parent 31dd42d37d
commit f79b3d6ff7
No known key found for this signature in database
GPG key ID: FF629AA9E08138DB
40 changed files with 397 additions and 228 deletions

View file

@ -8,7 +8,7 @@ Collection of my personal Nix configurations and opinionated NixOS, nix-darwin,
## Project structure ## Project structure
- hosts - per-machine configurations - hosts - per-machine configurations
- kazuki - my linux arm server - kazuki - my linux arm server
- legion - my linux x86 server[^1] - legion - my linux x86 server
- hijiri - my macbook[^1] - hijiri - my macbook[^1]
- hijiri-vm - linux vm running on my macbook - hijiri-vm - linux vm running on my macbook
- miyagi - my work machine[^1] - miyagi - my work machine[^1]

View file

@ -13,5 +13,6 @@
system = { system = {
kazuki = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEyYhYWDNmKSrpcslD3NzWW+lQmDcLJdjLh7CSkL4hW5 root@kazuki"; kazuki = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEyYhYWDNmKSrpcslD3NzWW+lQmDcLJdjLh7CSkL4hW5 root@kazuki";
legion = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0Ktyj0FSn8KLRwRGd0Tp/qNUPXV7+XyxAsWGWdMYp8 root@legion";
}; };
} }

View file

@ -1,4 +1,4 @@
{self, ...}: { {
defaultEffectSystem = "aarch64-linux"; defaultEffectSystem = "aarch64-linux";
hercules-ci = { hercules-ci = {
@ -7,12 +7,4 @@
when.dayOfWeek = "Mon"; when.dayOfWeek = "Mon";
}; };
}; };
herculesCI = {
onPush = {
default.enable = true;
wrappers.outputs = self.packages.aarch64-linux;
};
};
} }

40
flake.lock generated
View file

@ -282,6 +282,30 @@
"type": "gitlab" "type": "gitlab"
} }
}, },
"nh": {
"inputs": {
"flake-parts": [
"flake-parts"
],
"nix-filter": "nix-filter",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1694971480,
"narHash": "sha256-5UKSMDiboMIs15WN6jbctJgYfnGPfkHhvWWaboB2rGk=",
"owner": "viperML",
"repo": "nh",
"rev": "4b88da6fc89bf06d6598ce9a881590a7cc0dcafd",
"type": "github"
},
"original": {
"owner": "viperML",
"repo": "nh",
"type": "github"
}
},
"niko-nur": { "niko-nur": {
"inputs": { "inputs": {
"flake-parts": [ "flake-parts": [
@ -303,6 +327,21 @@
"type": "github" "type": "github"
} }
}, },
"nix-filter": {
"locked": {
"lastModified": 1687178632,
"narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=",
"owner": "numtide",
"repo": "nix-filter",
"rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nix-filter",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1687274257, "lastModified": 1687274257,
@ -441,6 +480,7 @@
"hercules-ci-effects": "hercules-ci-effects", "hercules-ci-effects": "hercules-ci-effects",
"home-manager": "home-manager", "home-manager": "home-manager",
"mailserver": "mailserver", "mailserver": "mailserver",
"nh": "nh",
"niko-nur": "niko-nur", "niko-nur": "niko-nur",
"nixpkgs": "nixpkgs_5", "nixpkgs": "nixpkgs_5",
"racket": "racket", "racket": "racket",

View file

@ -19,15 +19,19 @@
]; ];
perSystem = { perSystem = {
pkgs,
inputs', inputs',
pkgs,
lib,
... ...
}: { }: {
devShells.default = pkgs.mkShellNoCC { devShells.default = pkgs.mkShellNoCC {
packages = [ packages =
[
inputs'.deploy-rs.packages.deploy-rs inputs'.deploy-rs.packages.deploy-rs
inputs'.agenix.packages.agenix inputs'.agenix.packages.agenix
]; ]
# TODO: Contribute darwin support to nh
++ lib.optionals (!pkgs.stdenv.isDarwin) [inputs'.nh.packages.default];
}; };
formatter = pkgs.alejandra; formatter = pkgs.alejandra;
@ -54,11 +58,9 @@
}; };
niko-nur = { niko-nur = {
url = "github:nrabulinski/nur-packages"; url = "github:nrabulinski/nur-packages";
inputs = {
# Not overriding nixpkgs to get cache hits # Not overriding nixpkgs to get cache hits
# nixpkgs.follows = "nixpkgs"; # inputs.nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts"; inputs.flake-parts.follows = "flake-parts";
};
}; };
darwin = { darwin = {
url = "github:lnl7/nix-darwin"; url = "github:lnl7/nix-darwin";
@ -68,11 +70,9 @@
darwin-old-for-agenix.url = "github:lnl7/nix-darwin/22620845fee1cc16f4ea639509c50fd989ccc1ce"; darwin-old-for-agenix.url = "github:lnl7/nix-darwin/22620845fee1cc16f4ea639509c50fd989ccc1ce";
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs = { inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.follows = "nixpkgs"; inputs.darwin.follows = "darwin-old-for-agenix";
darwin.follows = "darwin-old-for-agenix"; inputs.home-manager.follows = "home-manager";
home-manager.follows = "home-manager";
};
}; };
mailserver = { mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver"; url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
@ -84,10 +84,8 @@
}; };
wrapper-manager-hm-compat = { wrapper-manager-hm-compat = {
url = "github:nrabulinski/wrapper-manager-hm-compat"; url = "github:nrabulinski/wrapper-manager-hm-compat";
inputs = { inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.follows = "nixpkgs"; inputs.home-manager.follows = "home-manager";
home-manager.follows = "home-manager";
};
}; };
# stylix = { # stylix = {
# url = "github:danth/stylix"; # url = "github:danth/stylix";
@ -106,10 +104,13 @@
}; };
hercules-ci-effects = { hercules-ci-effects = {
url = "github:hercules-ci/hercules-ci-effects"; url = "github:hercules-ci/hercules-ci-effects";
inputs = { inputs.flake-parts.follows = "flake-parts";
flake-parts.follows = "flake-parts"; inputs.hercules-ci-agent.follows = "hercules-ci-agent";
hercules-ci-agent.follows = "hercules-ci-agent";
}; };
nh = {
url = "github:viperML/nh";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
}; };
}; };
@ -120,6 +121,7 @@
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://cache.nixos.org/" "https://cache.nixos.org/"
"https://hercules-ci.cachix.org" "https://hercules-ci.cachix.org"
"https://nrabulinski.cachix.org"
]; ];
trusted-public-keys = [ trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
@ -127,6 +129,7 @@
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0=" "hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0="
"nrabulinski.cachix.org-1:Q5FD7+1c68uH74CQK66UWNzxhanZW8xcg1LFXxGK8ic="
]; ];
}; };
} }

View file

@ -5,10 +5,16 @@
lib, lib,
... ...
}: { }: {
builders = { imports = [
nixos = name: module: let ./kazuki
defaultOptions = { ./hijiri-vm
username, ./hijiri
./legion
./installer
];
builders = let
sharedOptions = {
inputs', inputs',
lib, lib,
... ...
@ -28,12 +34,25 @@
user = { user = {
enable = true; enable = true;
config = { config = {
home.packages = lib.attrValues inputs'.settei.packages; home.packages = let
wrappers = lib.attrValues inputs'.settei.packages;
extraPkgs = [inputs'.nh.packages.default];
in
wrappers ++ extraPkgs;
programs.git.enable = true;
home.sessionVariables.EDITOR = "hx";
}; };
}; };
}; };
time.timeZone = lib.mkDefault "Europe/Warsaw"; time.timeZone = lib.mkDefault "Europe/Warsaw";
};
in {
nixos = name: module: let
defaultOptions = {
_file = ./default.nix;
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8"; i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
}; };
in in
@ -46,17 +65,29 @@
inputs.hercules-ci-agent.nixosModules.agent-service inputs.hercules-ci-agent.nixosModules.agent-service
self.nixosModules.settei self.nixosModules.settei
self.nixosModules.common self.nixosModules.common
sharedOptions
defaultOptions
module
];
specialArgs.configurationName = name;
};
darwin = name: module: let
defaultOptions = {
_file = ./default.nix;
};
in
inputs.darwin.lib.darwinSystem {
modules = [
inputs.agenix.darwinModules.age
inputs.home-manager.darwinModules.home-manager
inputs.hercules-ci-agent.darwinModules.agent-service
self.darwinModules.settei
sharedOptions
defaultOptions defaultOptions
module module
]; ];
specialArgs.configurationName = name; specialArgs.configurationName = name;
}; };
}; };
imports = [
./kazuki
./hijiri-vm
# ./legion
./installer
];
} }

View file

@ -1,9 +1,4 @@
{ {
self,
inputs,
config,
...
}: {
configurations.nixos.hijiri-vm = { configurations.nixos.hijiri-vm = {
modulesPath, modulesPath,
lib, lib,
@ -15,7 +10,7 @@
./disks.nix ./disks.nix
]; ];
nixpkgs.system = "aarch64-linux"; nixpkgs.hostPlatform = "aarch64-linux";
boot = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;

5
hosts/hijiri/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
configurations.darwin.hijiri = {
nixpkgs.hostPlatform = "aarch64-darwin";
};
}

View file

@ -1,9 +1,6 @@
{ {
config,
self,
...
}: {
configurations.nixos.kazuki = { configurations.nixos.kazuki = {
config,
modulesPath, modulesPath,
lib, lib,
... ...
@ -17,7 +14,7 @@
./vault.nix ./vault.nix
]; ];
nixpkgs.system = "aarch64-linux"; nixpkgs.hostPlatform = "aarch64-linux";
boot = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
@ -26,10 +23,5 @@
}; };
common.hercules.enable = true; common.hercules.enable = true;
age.secrets.kazuki-cachix = {
file = ../../secrets/kazuki-cachix.age;
owner = config.systemd.services.hercules-ci-agent.serviceConfig.User;
};
services.hercules-ci-agent.settings.binaryCachesPath = config.age.secrets.kazuki-cachix.path;
}; };
} }

View file

@ -1,4 +1,5 @@
{config, ...}: { {config, ...}: {
# 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;

View file

@ -1,18 +1,17 @@
{config, ...}: let {
inherit (config.assets) sshKeys;
in {
configurations.nixos.legion = { configurations.nixos.legion = {
config, config,
lib, lib,
username,
... ...
}: { }: {
imports = [ imports = [
./hardware.nix ./hardware.nix
# ./disks.nix # ./disks.nix
./initrd.nix ./msmtp.nix
]; ];
nixpkgs.system = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";
specialisation = { specialisation = {
nas.configuration = ./nas; nas.configuration = ./nas;
@ -28,10 +27,15 @@ in {
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;
useDHCP = true;
firewall.trustedInterfaces = ["tailscale0"]; firewall.trustedInterfaces = ["tailscale0"];
}; };
systemd.services.NetworkManager-wait-online.enable = false;
powerManagement.cpuFreqGovernor = "performance"; powerManagement.cpuFreqGovernor = "performance";
age.secrets.niko-pass.file = ../../secrets/legion-niko-pass.age;
users.users.${username}.hashedPasswordFile = config.age.secrets.niko-pass.path;
common.hercules.enable = true;
}; };
} }

View file

@ -1,6 +1,10 @@
args: let args:
/*
let
bootDevice = args.bootDevice or "/dev/nvme0n1"; bootDevice = args.bootDevice or "/dev/nvme0n1";
in { in
*/
{
assertions = [ assertions = [
{ {
assertion = false; assertion = false;

View file

@ -1,9 +1,11 @@
{...}: { {config, ...}: {
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "uas"]; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "uas"];
boot.extraModulePackages = with config.boot.kernelPackages; [acpi_call]; boot.extraModulePackages = with config.boot.kernelPackages; [acpi_call];
boot.kernelModules = ["kvm-intel" "i2c-dev" "acpi_call"]; boot.kernelModules = ["kvm-intel" "i2c-dev" "acpi_call"];
boot.blacklistedKernelModules = ["nouveau"]; boot.blacklistedKernelModules = ["nouveau"];
# Needed for enableAllFirmware
nixpkgs.config.allowUnfree = true;
hardware = { hardware = {
enableAllFirmware = true; enableAllFirmware = true;
cpu.intel.updateMicrocode = true; cpu.intel.updateMicrocode = true;

View file

@ -1,14 +0,0 @@
{
config,
username,
...
}: {
boot.initrd = {
availableKernelModules = ["ath10k_pci" "r8169"];
network.enable = true;
network.ssh = {
enable = true;
authorizedKeys = config.users.users.${username}.openssh.authorizedKeys.keys;
};
};
}

1
hosts/legion/machine-id Normal file
View file

@ -0,0 +1 @@
524209a432724c7abaf04398cdd6eecd

34
hosts/legion/msmtp.nix Normal file
View file

@ -0,0 +1,34 @@
# TODO: Potentially make this a common module?
{
pkgs,
config,
username,
...
}: let
mail = "alert@nrab.lol";
aliases = pkgs.writeText "mail-aliases" ''
${username}: nikodem@rabulinski.com
root: ${mail}
'';
in {
age.secrets.alert-plaintext.file = ../../secrets/alert-plain-pass.age;
programs.msmtp = {
enable = true;
setSendmail = true;
defaults = {
inherit aliases;
tls = "on";
auth = "login";
tls_starttls = "off";
};
accounts = {
default = {
host = "mail.nrab.lol";
passwordeval = "cat ${config.age.secrets.alert-plaintext.path}";
user = mail;
from = mail;
};
};
};
}

View file

@ -1,5 +1,6 @@
{ {
pkgs, pkgs,
lib,
username, username,
... ...
}: { }: {
@ -7,7 +8,7 @@
./media.nix ./media.nix
]; ];
boot.supportedFilesystems = ["zfs"]; boot.supportedFilesystems = ["ext4" "zfs"];
boot.zfs.extraPools = ["yottapool"]; boot.zfs.extraPools = ["yottapool"];
services.zfs = { services.zfs = {
@ -15,7 +16,7 @@
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 = "${pkgs.msmtp}/bin/msmtp"; ZED_EMAIL_PROG = lib.getExe pkgs.msmtp;
ZED_EMAIL_OPTS = "@ADDRESS@"; ZED_EMAIL_OPTS = "@ADDRESS@";
ZED_NOTIFY_INTERVAL_SECS = 3600; ZED_NOTIFY_INTERVAL_SECS = 3600;
@ -26,8 +27,8 @@
}; };
}; };
fileSystems."/nix-cache" = { fileSystems."/bulk" = {
device = "/dev/disk/by-label/CACHE"; device = "/dev/disk/by-label/BULK";
fsType = "ext4"; fsType = "ext4";
}; };
} }

View file

@ -1,4 +1,4 @@
{ {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;
@ -13,6 +13,6 @@
jellyfin.extraGroups = ["radarr" "sonarr"]; jellyfin.extraGroups = ["radarr" "sonarr"];
radarr.extraGroups = ["deluge"]; radarr.extraGroups = ["deluge"];
sonarr.extraGroups = ["deluge"]; sonarr.extraGroups = ["deluge"];
niko.extraGroups = ["deluge"]; ${username}.extraGroups = ["deluge"];
}; };
} }

View file

@ -0,0 +1,5 @@
{config, ...}: {
flake.darwinModules = {
settei = import ./settei {inherit (config) perInput;};
};
}

View file

@ -0,0 +1,6 @@
{perInput}: {
imports = [
(import ../../shared/settei {inherit perInput;})
./sane-defaults.nix
];
}

View file

@ -0,0 +1,17 @@
# For sane-default options shared between NixOS and darwin, see modules/shared/settei/sane-defaults.nix
{
config,
lib,
username,
...
}: {
config = lib.mkIf config.settei.sane-defaults.enable {
services.nix-daemon.enable = true;
security.pam.enableSudoTouchIdAuth = true;
users.users.${username}.home = "/Users/${username}";
system.stateVersion = 4;
};
}

View file

@ -1,6 +1,7 @@
{ {
imports = [ imports = [
./nixos ./nixos
./darwin
./flake ./flake
]; ];
} }

View file

@ -7,10 +7,8 @@
lib, lib,
flake-parts-lib, flake-parts-lib,
... ...
}: let }:
inherit (lib) mkOption mapAttrs; with lib; {
inherit (flake-parts-lib) mkSubmoduleOptions;
in {
_file = ./configurations.nix; _file = ./configurations.nix;
options = { options = {
@ -18,37 +16,36 @@ in {
# Probably should hardly ever be overriden # Probably should hardly ever be overriden
builders = { builders = {
nixos = mkOption { nixos = mkOption {
type = lib.types.functionTo lib.types.unspecified; type = types.functionTo types.unspecified;
default = _name: nixpkgs.lib.nixosSystem; default = _name: nixpkgs.lib.nixosSystem;
}; };
darwin = mkOption { darwin = mkOption {
type = lib.types.functionTo lib.types.unspecified; type = types.functionTo types.unspecified;
default = _name: darwin.lib.darwinSystem; default = _name: darwin.lib.darwinSystem;
}; };
home = mkOption { home = mkOption {
type = lib.types.functionTo lib.types.unspecified; type = types.functionTo types.unspecified;
default = _name: home-manager.lib.homeManagerConfiguration; default = _name: home-manager.lib.homeManagerConfiguration;
}; };
}; };
configurations = { configurations = {
nixos = mkOption { nixos = mkOption {
type = lib.types.unspecified; type = types.attrsOf types.deferredModule;
default = {}; default = {};
}; };
darwin = mkOption { darwin = mkOption {
type = lib.types.unspecified; type = types.attrsOf types.deferredModule;
default = {}; default = {};
}; };
home = mkOption { home = mkOption {
type = lib.types.unspecified; type = types.attrsOf types.deferredModule;
default = {}; default = {};
}; };
}; };
}; };
config. config.flake = {
flake = {
nixosConfigurations = nixosConfigurations =
mapAttrs mapAttrs
config.builders.nixos config.builders.nixos

View file

@ -1,6 +1,5 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: { }: {
@ -8,10 +7,17 @@
options.common.hercules.enable = lib.mkEnableOption "Enables hercules-ci-agent with my configuration"; options.common.hercules.enable = lib.mkEnableOption "Enables hercules-ci-agent with my configuration";
config = lib.mkIf config.common.hercules.enable { config = let
herculesUser = config.systemd.services.hercules-ci-agent.serviceConfig.User;
in
lib.mkIf config.common.hercules.enable {
age.secrets.hercules-token = { age.secrets.hercules-token = {
file = ../../secrets/hercules-token.age; file = ../../../secrets/hercules-token.age;
owner = config.systemd.services.hercules-ci-agent.serviceConfig.User; owner = herculesUser;
};
age.secrets.hercules-cache = {
file = ../../../secrets/hercules-cache.age;
owner = herculesUser;
}; };
services.hercules-ci-agent = { services.hercules-ci-agent = {
@ -19,7 +25,7 @@
settings = { settings = {
clusterJoinTokenPath = config.age.secrets.hercules-token.path; clusterJoinTokenPath = config.age.secrets.hercules-token.path;
concurrentTasks = lib.mkDefault 4; concurrentTasks = lib.mkDefault 4;
binaryCachesPath = pkgs.writeText "empty-caches.json" "{}"; binaryCachesPath = config.age.secrets.hercules-cache.path;
}; };
}; };
}; };

View file

@ -1,19 +1,6 @@
{perInput}: { {perInput}: {
lib,
config,
...
}: {
_file = ./default.nix;
imports = [ imports = [
(import ../../shared/settei {inherit perInput;})
./sane-defaults.nix ./sane-defaults.nix
(import ./flake-qol.nix {inherit perInput;})
./user.nix
]; ];
options.settei = with lib; {
username = mkOption {
type = types.str;
};
};
} }

View file

@ -1,39 +1,19 @@
# This module is supposed to be a reusable set of options you probably would want to set anyway # For sane-default options shared between NixOS and darwin, see modules/shared/settei/sane-defaults.nix
#
# Other default options which don't necessairly make sense for other people go into hosts/default.nix
{ {
lib,
config, config,
username,
lib,
... ...
} @ args: { } @ args: let
_file = ./sane-defaults.nix; cfg = config.settei.sane-defaults;
in {
options.settei.sane-defaults = with lib; { config = lib.mkIf cfg.enable {
enable = mkEnableOption "Personal sane defaults (but they should make sense for anyone)";
allSshKeys = mkOption {
type = types.attrsOf types.singleLineStr;
default = {};
};
};
config = lib.mkIf config.settei.sane-defaults.enable (let
cfg = config.settei;
inherit (cfg) username;
configName = optionName:
args.configurationName
or (throw "pass configurationName to module arguments or set ${optionName} yourself");
in {
_module.args = {
username = lib.mkDefault username;
};
# https://github.com/NixOS/nixpkgs/issues/254807 # https://github.com/NixOS/nixpkgs/issues/254807
boot.swraid.enable = false; boot.swraid.enable = false;
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
services.openssh.enable = true; services.openssh.enable = true;
services.tailscale.enable = true;
programs.mosh.enable = lib.mkDefault true; programs.mosh.enable = lib.mkDefault true;
users = { users = {
@ -45,41 +25,21 @@
extraGroups = ["wheel"]; extraGroups = ["wheel"];
openssh.authorizedKeys.keys = let openssh.authorizedKeys.keys = let
filteredKeys = let filteredKeys = let
configName' = configName "users.users.${username}.openssh.authorizedKeys"; configName' =
args.configurationName
or (throw "pass configurationName to module arguments or set users.users.${username}.openssh.authorizedKeys yourself");
in in
lib.filterAttrs (name: _: name != configName') cfg.sane-defaults.allSshKeys; lib.filterAttrs (name: _: name != configName') cfg.allSshKeys;
in in
lib.mkDefault (lib.attrValues filteredKeys); lib.mkDefault (lib.attrValues filteredKeys);
}; };
groups.${username} = {}; groups.${username} = {};
}; };
networking.hostName = lib.mkDefault (configName "networking.hostName");
nix = {
settings = {
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
trusted-users = lib.optionals (!config.security.sudo.wheelNeedsPassword) [username];
auto-allocate-uids = true;
extra-substituters = [
"https://hyprland.cachix.org"
"https://cache.garnix.io"
"https://nix-community.cachix.org"
"https://hercules-ci.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0="
];
};
};
# 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
# be able to use sudo with no password # be able to use sudo with no password
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
system.stateVersion = "22.05"; system.stateVersion = "22.05";
}); };
} }

View file

@ -0,0 +1,19 @@
{perInput}: {
lib,
config,
...
}: {
_file = ./default.nix;
imports = [
./sane-defaults.nix
(import ./flake-qol.nix {inherit perInput;})
./user.nix
];
options.settei = with lib; {
username = mkOption {
type = types.str;
};
};
}

View file

@ -43,7 +43,7 @@ in {
nix = { nix = {
registry = lib.mapAttrs (_: flake: {inherit flake;}) cfg.inputs-flakes; registry = lib.mapAttrs (_: flake: {inherit flake;}) cfg.inputs-flakes;
nixPath = map (name: "${name}=flake:${name}") (lib.attrNames cfg.inputs-flakes); nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes;
}; };
}; };
} }

View file

@ -0,0 +1,58 @@
# This module is supposed to be a reusable set of options you probably would want to set anyway
#
# Other default options which don't necessairly make sense for other people go into hosts/default.nix
{
config,
pkgs,
lib,
...
} @ args: {
_file = ./sane-defaults.nix;
options.settei.sane-defaults = with lib; {
enable = mkEnableOption "Personal sane defaults (but they should make sense for anyone)";
allSshKeys = mkOption {
type = types.attrsOf types.singleLineStr;
default = {};
};
};
config = lib.mkIf config.settei.sane-defaults.enable (let
cfg = config.settei;
inherit (cfg) username;
adminNeedsPassword = pkgs.stdenv.isLinux -> config.security.sudo.wheelNeedsPassword;
in {
_module.args = {
username = lib.mkDefault username;
};
services.tailscale.enable = true;
networking.hostName = lib.mkDefault (
args.configurationName
or (throw "pass configurationName to module arguments or set networking.hostName yourself")
);
nix = {
settings = {
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
trusted-users = lib.optionals (!adminNeedsPassword) [username];
auto-allocate-uids = true;
extra-substituters = [
"https://hyprland.cachix.org"
"https://cache.garnix.io"
"https://nix-community.cachix.org"
"https://hercules-ci.cachix.org"
"https://nrabulinski.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0="
"nrabulinski.cachix.org-1:Q5FD7+1c68uH74CQK66UWNzxhanZW8xcg1LFXxGK8ic="
];
};
};
});
}

View file

@ -36,7 +36,7 @@ in {
home = { home = {
inherit username; inherit username;
homeDirectory = config.users.users.${username}.home; homeDirectory = config.users.users.${username}.home;
stateVersion = config.system.stateVersion; stateVersion = "22.05";
}; };
programs.home-manager.enable = true; programs.home-manager.enable = true;

View file

@ -1,10 +1,10 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 84j9mw jmpsgact3iy0+A1ggWzK98D1e7R/44F9TgzFSg6BIWA -> ssh-ed25519 84j9mw bG9/dNwxbn7mVFKLraVw594U+CUVNXmDX56xODpn8m8
K6S7UNkJNh859EgPdMTpYol4vaSD0nfjsu6SMk9F5Vo wMuzPr8LdQEdeyF4LCKepSgRU1oWl2znplE/8T+AMVw
-> ssh-ed25519 GKhvwg YGAiny4ZXIqplrdFqETxB4chp9IqJt5fHb+NK4Bvan0 -> ssh-ed25519 GKhvwg gZ4nVDAdjyhXyoDsIr+LBnLaF94zJLe9hoDN8jRY2Sw
0rgp0zJiGX5t4x/FKoLDJWMJW1hPsfVNMd4bPmv6Xdo cdz0BUiD1YwnN7FWJcqzYYU83HzDYWlQgc+qPPMUtcE
-> }Z-grease dI \ a^Wyct @c5 -> `#k-grease A3Jo
H3cGSMZsNUPMewieU4NK6zr4IlLt+hivE3FnRBrNzll7WGBd942TAFQ8YRa9sIbJ IPGUbK+Mg0+gFt44tyFi
b9mvv1dqYmoS7MBVAGJvLgaX --- 6g1g/jyT0Yg+lgfmdUpZzUN5ryWGWIKYABUVw6crzfA
--- C9QLdKcJPuN/raiGvmopHeYM2tnURzDMzV8DRAmffR0 oe¼EÑ^=Ù*JnTjÕ˜oq\nT.TáeÍ
`0œDå±þ`Voœß/ü§Ä೯‰T~{({Ô:¨××hx­“šj^þBnÆ'TÓ0[€UÐg=_DDÿUþ!¼·-­¶õ5B ZŒÄ:<3A>s³}PF¥æÑfàh Y:¸y,bźµ¿Ú]±"“Þ¾SÌFЉôp)´ÚµÛœžJH.J¿Œg¤EŠíÏr¦¿¶ÿÃOL

View file

@ -0,0 +1,9 @@
age-encryption.org/v1
-> ssh-ed25519 ioPMHA GErPiwFO6TluW+/QapeT0BhWH2yVd54UfCsi5s8STm8
/rOO0+oXHGnJ54PdgPSJ/UWeZm1Ibtptnz+tv6zhTLA
-> ssh-ed25519 GKhvwg MtNidti8d7qz3NERKPdoU0UtNj/SZp2htzXYB3NUMXM
WKdKJtjfsWFgoO09wpw87JdOaGNqDpC9MRs7Fumfn/g
-> 'JP4o}-grease Thf
jq5xoH6w3eDeGBGf1jKPCxEl
--- sI/u3P4XIpQOMPXhtCy4XqRo+FSi5IdUDNxw0S88gWc
@ï;ÖÎ|U:B{ý…x3»§û!9A2Û€S<E282AC>ÖúèNg#Ù͇r68ãS 2

View file

@ -0,0 +1,14 @@
age-encryption.org/v1
-> ssh-ed25519 84j9mw UohYhuFXjwI+Ya6a2nIjFt1FSpp/S1fss8+ZffKf91M
q8q6+vScXETWtB8YDO84X6D5KTptP4JhNtW4yH8D2dw
-> ssh-ed25519 ioPMHA 0NAryvpJ42YzfO4/cNE6UvRzqEk4rjM4PTInqiSj/Qk
/V72hnrePBIiO0U6817ij91W2G3lHS/yZjLXu9ngMyw
-> ssh-ed25519 GKhvwg Lqt8W9uLyyEqtdQMriomn/D/s4yy/F7qID1N6FbbSVw
vSC+r50g8xVE+bKNJ7QMtZD9uacainZ+KK7U8Lb4B/A
-> kW{-]#L<-grease 7>z.Yr}9 YOwZ f"i}Y;^=
l3YcF04OxddtsUHtQLBW9qotCY+Wghl7y2HsRtEXnwBjRiyzvCjc/RMQ70/f4WW7
xIS9WI00LtKj8rAoNmvOsIDkMzKvuutQmmZYBJEk
--- L1zbOMuts43q3o1ziGlV4VBu3DyKYO6jNVZlJt4CUdg
¿„<EFBFBD>Í”†Ûu¤Ãm\àý:Ý;é›bÍé7ÎaüH 7MÎL!{uWù­˜<C3B1>ZØvô<76>žÝŠL“·ˆçÒH²¾îªV\Õ?ð¯Ÿ*˜,$d¦6S3JŸÒ¤"D‡/eRkmI MúMÚ‡rMI pûS<C3BB>€)xÊk¡+»l¢uuGÓ®‡ïÉ3M<33>­г{ŽN—áÙ<>†Bç[ú“¡i¶`o  ÓÉ¡°[Qÿ1<C3BF>Ærh‡-Å••¢
?èçfƒ;5~³5T"lÉó„,ÁÅ‹œÝ‹?„ ð ¾(ßË[wÍÖX
<nxD†_£sì«t$¿3%#g™Ý_!þ{ —!®²ßœ~8¥û)̘ÛÊOü°µòÐXÛ€žg¶™<C2B6>0¹<)°ùGIód¦ãŠ ïñÎÏf'¿ídÎaC^À¨àô=òEH¡…¦—apnhŽ~³AøŒÉ¶/H'

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -5,6 +5,8 @@ in {
"alert-nrab-lol-pass.age".publicKeys = [keys.system.kazuki keys.other.bootstrap]; "alert-nrab-lol-pass.age".publicKeys = [keys.system.kazuki keys.other.bootstrap];
"vault-cert-env.age".publicKeys = [keys.system.kazuki keys.other.bootstrap]; "vault-cert-env.age".publicKeys = [keys.system.kazuki keys.other.bootstrap];
# "bitwarden-env-file.age".publicKeys = [keys.system.kazuki keys.other.bootstrap]; # "bitwarden-env-file.age".publicKeys = [keys.system.kazuki keys.other.bootstrap];
"hercules-token.age".publicKeys = [keys.system.kazuki keys.other.bootstrap]; "hercules-token.age".publicKeys = [keys.system.kazuki keys.system.legion keys.other.bootstrap];
"kazuki-cachix.age".publicKeys = [keys.system.kazuki keys.other.bootstrap]; "hercules-cache.age".publicKeys = [keys.system.kazuki keys.system.legion keys.other.bootstrap];
"alert-plain-pass.age".publicKeys = [keys.system.legion keys.other.bootstrap];
"legion-niko-pass.age".publicKeys = [keys.system.legion keys.other.bootstrap];
} }

View file

@ -1,9 +1,9 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 84j9mw 13PBQImkhu4ivVTaeHWkpRfidgOFF7FBLD18amn5+Xs -> ssh-ed25519 84j9mw vOJaWCNIGFgf6O0nTt+g1a5y5iKvMlr9nrpF1jTNGmM
ZeZhuWZqI8Poa1ROlaYAXkr6QBM4355lWpYaHAtaTP8 MxiliY7O3k0P47mYrmV6ovZu9+03JCCUvOe8Zu7gi34
-> ssh-ed25519 GKhvwg gSXVzlieRXepW8s4onx4SDd75LVTyr1Rbc2/1LUIGTw -> ssh-ed25519 GKhvwg XSQNhU9xCPQu7iIcshQxncgqp37J8iS1H6FKDaChPTo
AOmJNzvioM7B+114BMBc5xbxfOAbielwizwtNzK2G7k uH8yhnQc184zK72pwwNod110/ehMiT/eWbHN894XThU
-> K/_&?-grease 'jg+M|s Cw&g= -> w>U?#&-grease <dWq wD?o*
yfPl wMaIBnm2VLcz0dW+Hhv6
--- 8idL6hzmOCas0TKD8rvx7qlSGbzLPFxAOdlnSNi5+sY --- b4aPjwryeAsFAeNWUyMT1hI7G3yQinFIfoYfUxHk3s8
Æ=»lÞ…XæÊsÄ$xKÑ2F^¢#ø_ìB ßq"½ZÎü*¢ù®Ôó2`0n|#ÉÑz SÅõ;UÀ@:¿âšRGuv>ʺÿ§€Ù÷é Z½\m†¦¼N( µá|ý.os,!‡£$`#Ïçlˆ¹xè¡ûõO(,°eȼÇGñQi=m„ 6Ö1¦#&îÙ©8dÄŠÛ”¥äC$5T"Q¼¯Ì‹þï

View file

@ -1,11 +1,8 @@
{ {pkgs, ...}: {
pkgs,
lib,
...
}: {
programs.helix = { programs.helix = {
enable = true; enable = true;
settings = { settings = {
theme = "base16_default_dark";
editor = { editor = {
true-color = true; true-color = true;
line-number = "relative"; line-number = "relative";
@ -15,7 +12,6 @@
cursorline = true; cursorline = true;
auto-save = true; auto-save = true;
indent-guides.render = true; indent-guides.render = true;
theme = "base16_default_dark";
}; };
}; };
languages = { languages = {