aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/common
diff options
context:
space:
mode:
authorsadbeast <sadbeast@sadbeast.com>2024-05-30 00:47:47 +0000
committersadbeast <sadbeast@sadbeast.com>2024-10-05 16:44:14 -0700
commit09513b5c4e4babfaefdd06c592ef34c0908dc572 (patch)
tree5a9af6ef0407346c223334e295adc8012654f112 /hosts/common
downloadnix-config-09513b5c4e4babfaefdd06c592ef34c0908dc572.tar.gz
nix-config-09513b5c4e4babfaefdd06c592ef34c0908dc572.tar.bz2
oh god what have i doneHEADmain
Diffstat (limited to 'hosts/common')
-rw-r--r--hosts/common/global/default.nix174
-rw-r--r--hosts/common/global/sops.nix17
-rw-r--r--hosts/common/optional/wireless.nix35
-rw-r--r--hosts/common/secrets.yaml50
4 files changed, 276 insertions, 0 deletions
diff --git a/hosts/common/global/default.nix b/hosts/common/global/default.nix
new file mode 100644
index 0000000..3f33d55
--- /dev/null
+++ b/hosts/common/global/default.nix
@@ -0,0 +1,174 @@
+# This holds configuration common across hosts
+{
+ inputs,
+ outputs,
+ lib,
+ config,
+ pkgs,
+ ...
+}: {
+ # You can import other NixOS modules here
+ imports = [
+ inputs.home-manager.nixosModules.home-manager
+ inputs.impermanence.nixosModules.impermanence
+ ./sops.nix
+ ];
+
+ #home-manager.useGlobalPkgs = true;
+ home-manager.backupFileExtension = "backup";
+ home-manager.extraSpecialArgs = {
+ inherit inputs outputs;
+ };
+
+ nixpkgs = {
+ # You can add overlays here
+ overlays = [
+ # Add overlays your own flake exports (from overlays and pkgs dir):
+ outputs.overlays.additions
+ # outputs.overlays.modifications
+
+ outputs.overlays.stable-packages
+
+ # You can also add overlays exported from other flakes:
+ # neovim-nightly-overlay.overlays.default
+
+ # Or define it inline, for example:
+ # (final: prev: {
+ # hi = final.hello.overrideAttrs (oldAttrs: {
+ # patches = [ ./change-hello-to-hi.patch ];
+ # });
+ # })
+ ];
+ config = {
+ allowUnfree = true;
+ };
+ };
+
+ nix = let
+ flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
+ in {
+ settings = {
+ # Enable flakes and new 'nix' command
+ experimental-features = "nix-command flakes ca-derivations";
+ # Opinionated: disable global registry
+ flake-registry = "";
+ # Workaround for https://github.com/NixOS/nix/issues/9574
+ nix-path = config.nix.nixPath;
+ };
+ gc = {
+ automatic = true;
+ dates = "daily";
+ options = "--delete-older-than 7d";
+ };
+ # Opinionated: disable channels
+ channel.enable = false;
+
+ # Opinionated: make flake registry and nix path match flake inputs
+ registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs;
+ nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
+ };
+
+ time.timeZone = "America/Los_Angeles";
+
+ i18n.defaultLocale = "en_US.UTF-8";
+ console = {
+ font = "Lat2-Terminus16";
+ keyMap = "emacs2";
+ };
+
+ programs = {
+ sway.enable = true;
+ zsh.enable = true;
+ git.enable = true;
+
+ fuse.userAllowOther = true;
+ };
+
+ users.mutableUsers = false;
+
+ users.users.sadbeast = {
+ hashedPasswordFile = config.sops.secrets.sadbeast-password.path;
+ isNormalUser = true;
+ openssh.authorizedKeys.keys = [
+ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINGpEusv/bS34Q1JQxZXikdcwnq1vToz2d+HgV+E8NRX"
+ ];
+
+ extraGroups = ["wheel" "audio" "docker"];
+ shell = pkgs.zsh;
+ packages = [pkgs.home-manager];
+ };
+
+ sops.secrets.sadbeast-password = {
+ sopsFile = ../secrets.yaml;
+ neededForUsers = true;
+ };
+
+ home-manager.users.sadbeast = import ../../../home/sadbeast/${config.networking.hostName}.nix;
+
+ # This setups a SSH server. Very important if you're setting up a headless system.
+ # Feel free to remove if you don't need it.
+ services = {
+ avahi = {
+ enable = true;
+ nssmdns4 = true;
+ openFirewall = true;
+ };
+
+ openssh = {
+ enable = true;
+ settings = {
+ # Opinionated: forbid root login through SSH.
+ PermitRootLogin = "no";
+ # Opinionated: use keys only.
+ # Remove if you want to SSH using passwords
+ PasswordAuthentication = false;
+ };
+ };
+
+ pipewire = {
+ enable = true;
+ alsa.enable = true;
+ alsa.support32Bit = true;
+ pulse.enable = true;
+ };
+
+ printing.enable = true;
+ };
+ security = {
+ polkit.enable = true;
+ # rtkit is optional but recommended
+ rtkit.enable = true;
+ sudo.wheelNeedsPassword = false;
+
+ pam.services = {
+ swaylock = {};
+ };
+ };
+
+ # environment.persistence."/persistent" = {
+ # hideMounts = true;
+ # directories = [
+ # "/var/log"
+ # "/var/lib/nixos"
+ # "/var/lib/systemd"
+ # ];
+ # files = [
+ # "/etc/machine-id"
+ # "/var/lib/sops-nix/keys.txt"
+ # ];
+ # };
+
+ # system.activationScripts.persistent-dirs.text = let
+ # mkHomePersist = user:
+ # lib.optionalString user.createHome ''
+ # mkdir -p /persistent/${user.home}
+ # chown ${user.name}:${user.group} /persistent/${user.home}
+ # chmod ${user.homeMode} /persistent/${user.home}
+ # '';
+ # users = lib.attrValues config.users.users;
+ # in
+ # lib.concatLines (map mkHomePersist users);
+
+ # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
+ system.stateVersion = "24.05";
+}
diff --git a/hosts/common/global/sops.nix b/hosts/common/global/sops.nix
new file mode 100644
index 0000000..9d1d42b
--- /dev/null
+++ b/hosts/common/global/sops.nix
@@ -0,0 +1,17 @@
+{
+ inputs,
+ lib,
+ config,
+ ...
+}: {
+ imports = [inputs.sops-nix.nixosModules.sops];
+
+ sops = {
+ age = {
+ #keyFile = "/persistent/var/lib/sops-nix/keys.txt";
+ keyFile = "/var/lib/sops-nix/keys.txt";
+ sshKeyPaths = [];
+ };
+ gnupg.sshKeyPaths = [];
+ };
+}
diff --git a/hosts/common/optional/wireless.nix b/hosts/common/optional/wireless.nix
new file mode 100644
index 0000000..ce66419
--- /dev/null
+++ b/hosts/common/optional/wireless.nix
@@ -0,0 +1,35 @@
+{config, ...}: {
+ # Wireless secrets stored through sops
+ sops.secrets.wireless = {
+ sopsFile = ../secrets.yaml;
+ neededForUsers = true;
+ };
+
+ networking.wireless = {
+ enable = true;
+ fallbackToWPA2 = false;
+
+ # Declarative
+ secretsFile = config.sops.secrets.wireless.path;
+ networks = {
+ "Black Vulture" = {
+ pskRaw = "ext:home_psk";
+ };
+ };
+
+ # Imperative
+ allowAuxiliaryImperativeNetworks = true;
+ userControlled = {
+ enable = true;
+ group = "network";
+ };
+ extraConfig = ''
+ update_config=1
+ '';
+ };
+
+ # Ensure group exists
+ users.groups.network = {};
+
+ systemd.services.wpa_supplicant.preStart = "touch /etc/wpa_supplicant.conf";
+}
diff --git a/hosts/common/secrets.yaml b/hosts/common/secrets.yaml
new file mode 100644
index 0000000..d0dc065
--- /dev/null
+++ b/hosts/common/secrets.yaml
@@ -0,0 +1,50 @@
+sadbeast-password: ENC[AES256_GCM,data:Oy3x2JbsX/iTHSYd//sScEfpK2AcW9mfAD/jHR1zymkZ/hMgrK/pfzWiCiLSrCoV38lcaBsFHdv80Bf7TRhYkUQZ6F6EPtaVYg==,iv:/cEQPob8z5fzsUIo1unv7zT8h2MsdKMTVBxnSMlCgaM=,tag:afhjGiTXdPjiZVpzAKUvwA==,type:str]
+work-password: ENC[AES256_GCM,data:6gcVp0kW+6sHg/9KxqjtnGa6ycfSitlAAAzgc2teE2mmgh9DBfP+0IiTGk0XrHjLZCrGCa/zyrIDKq3jdXE+E42laH7H68SrpA==,iv:LvRc7Uj5MJ3RMxIbp5s2U5qx50RLKe6o8mZSqwbrktk=,tag:ZpIaOfTWtt/6w93O/B2drw==,type:str]
+wireless: ENC[AES256_GCM,data:aeetnjjKGbt0wudRuIY5ruemnxlhm5Iw808G5D9BO1dTYi0EbA7JrXHz3wXh737WsPMOXL0S9NaeRH4w,iv:NIoIJ6CjXWGesoEraRoSH2hmF2JpRvpV8fCpwNi06/c=,tag:/aS84d4H0jEHCBZd/CCOCg==,type:str]
+sops:
+ kms: []
+ gcp_kms: []
+ azure_kv: []
+ hc_vault: []
+ age:
+ - recipient: age16qcn9298rk3eav38442zw2ejhqac6uvdj0m86qf4ggnjgug8efgsp9lwcd
+ enc: |
+ -----BEGIN AGE ENCRYPTED FILE-----
+ YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBndG9RVWpCZXlsanhTbUky
+ N1drL1RlZVpZbElCaDljVWx6ZG9Vc3JsbTBRCk0rclJkUCtzdVF5NDdKTFRsamZR
+ UXpleTFWcU9CWlRyL0JLVVJCNnNzL2MKLS0tIHNISSsvTllQaFZ5dGk2VTJ0Vkxq
+ enh2dmxhcDgyNjlKRDFRZnlWTndYZjgK8aRkrdMx+SaZBnc2HFVdmwGm8K5T19Aa
+ UsoeqXyCPA1rxUFA6eCzy9y9sst/susfkwgRwFucP9W8lE3+kglMNg==
+ -----END AGE ENCRYPTED FILE-----
+ - recipient: age1hls0h26tcls67ukcpt7e0ztua8mwzheaqkuuwl4anv8zstq8regqd7nqv9
+ enc: |
+ -----BEGIN AGE ENCRYPTED FILE-----
+ YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBPa1RucTA0UnVSQkhtdE9P
+ c2wzS01ucWN5M3A2QjRYZ1h4Y00wSjJvUkJjCktGck9JRFVYcGQyQ0plQ1B6dDNU
+ Zit2MmpDRExTU1NwR0pxc0dyaXdJUjAKLS0tIGE5YXFoRW1MU2VyL2N3ZGFmQSti
+ dFAvNEtTYlgzMUJZQjhZK3VvWGNvTWsKzafclExVkycuEnq5lsloVYSpUd+1SfQS
+ rj5xDJV8E37+q7lsizRhKMtjJNv/raeLXicsBwL2vmnY6RoYsPSfCw==
+ -----END AGE ENCRYPTED FILE-----
+ - recipient: age1dg0dxg6nf5rm05py3da3yz8tkg7xtgustuehxwn37cm8mdrf93ysn9n622
+ enc: |
+ -----BEGIN AGE ENCRYPTED FILE-----
+ YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSArVEZZaXQ0TjU1RFVZMnQr
+ MWQzbXEyV25RZmhVRFZlUzdjamNYR2hWcjBZCkRSSWMrSVpVV3pETkJUY1AyZTRZ
+ SVZkZDhnMkhaUUxWYklTdUszVlM2VHMKLS0tIFNrL0crZExQV3p2ZGxScmo1aXlK
+ Y3BLSkFyVkpUalRjSkxHMFpLVTJabTAKW2ydqX5ZulhSyiFCaNW3rMFncNBGllZU
+ v2HET4US1eUzT8suMWzfhjm7GA6D7KD3pJICglhtumk9sihRL3TrQg==
+ -----END AGE ENCRYPTED FILE-----
+ - recipient: age1a6k6lwndk7w5ck3w8vydw72af3q8appm6jyxj7amwp6fmqnylywsy7ay0e
+ enc: |
+ -----BEGIN AGE ENCRYPTED FILE-----
+ YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBUeFlOb093ekpDanBiZEl0
+ TGo4T2w4aHk4Zjl6eUdrS0diQzBWM1ltUDN3ClpVemlBN1YvVmNuZFlGWEVhSktv
+ SHNOZFBzWm5DTzJyNEhiSVRTampjR0UKLS0tIFFVODY0L1h0bThIclgxRnhVZmtk
+ Njl4U3h2UmZUOVhnQ0lqb3NnbUcwME0KfEhBK4MnSGDwQZYztvWKl5k4zRZD+kDT
+ t2yCzytfW3wcWmnqnbtBqFGFiZhtBaN1GhlJhHJY16JClJ/c8dhQ6g==
+ -----END AGE ENCRYPTED FILE-----
+ lastmodified: "2024-09-17T23:15:06Z"
+ mac: ENC[AES256_GCM,data:ojX6Ec9XP2MMnBQUkxlvmJYL+q9RGgwNZbtu7HObbXKXwozk68r//A2BwMFILcuFaSi1y1TOfgs1xdSr8wZPqLsGxLLSkruhmNnjO2fbYPYc33FW4OYoloTFeGZuL7Z1RGXUwDDZ59nqzH8DwKqfAmorJ2opyWS/igmEf1plWHQ=,iv:0+za47Ga2yfPcOlV4a8WniQ4wQma+k0+xqFqWvDXdGQ=,tag:Yoz3TvK7QtqwgZMVLJweoA==,type:str]
+ pgp: []
+ unencrypted_suffix: _unencrypted
+ version: 3.9.0