aboutsummaryrefslogtreecommitdiff
path: root/nix/machines
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-12-08 13:58:02 -0800
committerFranck Cuny <franck@fcuny.net>2024-12-08 15:35:17 -0800
commit52ac07299f2342afe0c309f3b8be3ea05c7549ff (patch)
treebad76e67ba8a1f9301eb87a8c5e66c8a5a260e76 /nix/machines
parentadd targets to create virtual machines (diff)
downloadinfra-52ac07299f2342afe0c309f3b8be3ea05c7549ff.tar.gz
refactor overall configuration
The configuration of the various hosts and home-manager was becoming a bit complex for no valid reasons. Try to simplify this a bit.
Diffstat (limited to 'nix/machines')
-rw-r--r--nix/machines/darwin-shared.nix91
-rw-r--r--nix/machines/hardware/vm-aarch64-utm.nix33
-rw-r--r--nix/machines/macbook-air-m2.nix13
-rw-r--r--nix/machines/macbook-pro-intel.nix8
-rw-r--r--nix/machines/vm-aarch64.nix16
-rw-r--r--nix/machines/vm-shared.nix51
6 files changed, 212 insertions, 0 deletions
diff --git a/nix/machines/darwin-shared.nix b/nix/machines/darwin-shared.nix
new file mode 100644
index 0000000..6c727f8
--- /dev/null
+++ b/nix/machines/darwin-shared.nix
@@ -0,0 +1,91 @@
+{ pkgs, ... }: {
+ nix = {
+ package = pkgs.nixVersions.stable;
+
+ gc = {
+ user = "root";
+ automatic = true;
+ interval = [{
+ Hour = 7;
+ Minute = 0;
+ Weekday = 0;
+ }];
+ options = "--delete-older-than 7d";
+ };
+
+ settings = {
+ trusted-users = [ "@admin" "fcuny" ];
+ experimental-features = [ "nix-command" "flakes" ];
+ };
+ };
+
+ system.defaults = {
+ dock = {
+ autohide = true;
+ orientation = "left";
+ showhidden = false;
+ show-recents = false;
+ mru-spaces = false; # don’t rearrange spaces based on the most recent use
+ };
+ finder.AppleShowAllExtensions = true;
+ screencapture.location = "~/Documents/screenshots";
+ SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true;
+ };
+
+ fonts.packages = with pkgs; [
+ emacs-all-the-icons-fonts
+ google-fonts
+ roboto
+ source-code-pro
+ source-serif-pro
+ source-sans-pro
+ go-font
+ ];
+
+ system.keyboard = {
+ enableKeyMapping = true;
+ remapCapsLockToControl = true;
+ };
+
+ # Touch ID for sudo auth
+ security.pam.enableSudoTouchIdAuth = true;
+
+ services.nix-daemon.enable = true;
+
+ system.defaults.CustomUserPreferences = {
+ "com.apple.desktopservices" = {
+ # Avoid creating .DS_Store files on network or USB volumes
+ DSDontWriteNetworkStores = true;
+ DSDontWriteUSBStores = true;
+ };
+ };
+
+ programs.fish.enable = true;
+ programs.fish.shellInit = ''
+ # Nix
+ if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish'
+ source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish'
+ end
+ # End Nix
+ '';
+
+ # Required for homebrew on aarch64
+ environment.systemPath = [ "/opt/homebrew/bin" "/opt/homebrew/sbin" ];
+
+ homebrew = {
+ enable = true;
+ onActivation.autoUpdate = true;
+ onActivation.upgrade = true;
+
+ casks = [
+ "1password-cli"
+ "docker"
+ "element"
+ "emacs"
+ "iterm2"
+ "transmission"
+ "vlc"
+ "wireshark"
+ ];
+ };
+}
diff --git a/nix/machines/hardware/vm-aarch64-utm.nix b/nix/machines/hardware/vm-aarch64-utm.nix
new file mode 100644
index 0000000..084cc74
--- /dev/null
+++ b/nix/machines/hardware/vm-aarch64-utm.nix
@@ -0,0 +1,33 @@
+# Do not modify this file! It was generated by ‘nixos-generate-config’
+# and may be overwritten by future invocations. Please make changes
+# to /etc/nixos/configuration.nix instead.
+{ lib, modulesPath, ... }: {
+ imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
+
+ boot.initrd.availableKernelModules = [ "xhci_pci" "sr_mod" ];
+ boot.initrd.kernelModules = [ ];
+ boot.kernelModules = [ ];
+ boot.extraModulePackages = [ ];
+
+ fileSystems."/" = {
+ device = "/dev/disk/by-label/nixos";
+ fsType = "ext4";
+ };
+
+ fileSystems."/boot" = {
+ device = "/dev/disk/by-label/boot";
+ fsType = "vfat";
+ options = [ "fmask=0022" "dmask=0022" ];
+ };
+
+ swapDevices = [ ];
+
+ # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
+ # (the default) this is the recommended approach. When using systemd-networkd it's
+ # still possible to use this option, but it's recommended to use it in conjunction
+ # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
+ networking.useDHCP = lib.mkDefault true;
+ # networking.interfaces.enp0s1.useDHCP = lib.mkDefault true;
+
+ nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
+}
diff --git a/nix/machines/macbook-air-m2.nix b/nix/machines/macbook-air-m2.nix
new file mode 100644
index 0000000..9b0265a
--- /dev/null
+++ b/nix/machines/macbook-air-m2.nix
@@ -0,0 +1,13 @@
+{ pkgs, ... }: {
+ imports = [ ./darwin-shared.nix ];
+
+ system.stateVersion = 5;
+
+ networking.hostName = "mba-fcuny";
+
+ programs.fish.enable = true;
+ environment.shells = [ pkgs.fish ];
+
+ # brew packages I only want to get installed on this machine
+ homebrew.casks = [ "zoom" ];
+}
diff --git a/nix/machines/macbook-pro-intel.nix b/nix/machines/macbook-pro-intel.nix
new file mode 100644
index 0000000..07b464e
--- /dev/null
+++ b/nix/machines/macbook-pro-intel.nix
@@ -0,0 +1,8 @@
+{ pkgs, ... }: {
+ imports = [ ./darwin-shared.nix ];
+
+ system.stateVersion = 5;
+
+ programs.fish.enable = true;
+ environment.shells = [ pkgs.fish ];
+}
diff --git a/nix/machines/vm-aarch64.nix b/nix/machines/vm-aarch64.nix
new file mode 100644
index 0000000..8e84ed5
--- /dev/null
+++ b/nix/machines/vm-aarch64.nix
@@ -0,0 +1,16 @@
+{ ... }: {
+ imports = [ ./hardware/vm-aarch64-utm.nix ./vm-shared.nix ];
+
+ # Interface is this on my M1
+ networking.interfaces.enp0s10.useDHCP = true;
+
+ # Qemu
+ services.spice-vdagentd.enable = true;
+
+ # For now, we need this since hardware acceleration does not work.
+ environment.variables.LIBGL_ALWAYS_SOFTWARE = "1";
+
+ # Lots of stuff that uses aarch64 that claims doesn't work, but actually works.
+ nixpkgs.config.allowUnfree = true;
+ nixpkgs.config.allowUnsupportedSystem = true;
+}
diff --git a/nix/machines/vm-shared.nix b/nix/machines/vm-shared.nix
new file mode 100644
index 0000000..04eedf0
--- /dev/null
+++ b/nix/machines/vm-shared.nix
@@ -0,0 +1,51 @@
+{ pkgs, ... }: {
+ boot.kernelPackages = pkgs.linuxPackages_latest;
+
+ nix = {
+ package = pkgs.nixVersions.latest;
+ extraOptions = ''
+ experimental-features = nix-command flakes
+ keep-outputs = true
+ keep-derivations = true
+ '';
+ };
+
+ # Use the systemd-boot EFI boot loader.
+ boot.loader.systemd-boot.enable = true;
+ boot.loader.efi.canTouchEfiVariables = true;
+
+ networking.hostName = "dev";
+
+ time.timeZone = "America/Los_Angeles";
+
+ # Don't require password for sudo
+ security.sudo.wheelNeedsPassword = false;
+
+ # Virtualization settings
+ virtualisation.docker.enable = true;
+
+ # Select internationalisation properties.
+ i18n = { defaultLocale = "en_US.UTF-8"; };
+
+ # Define a user account. Don't forget to set a password with ‘passwd’.
+ users.mutableUsers = false;
+
+ # List packages installed in system profile. To search, run:
+ # $ nix search wget
+ environment.systemPackages = with pkgs; [ curl git ];
+
+ # Enable the OpenSSH daemon.
+ services.openssh.enable = true;
+ services.openssh.settings.PasswordAuthentication = true;
+ services.openssh.settings.PermitRootLogin = "no";
+
+ networking.firewall.enable = false;
+
+ # This value determines the NixOS release from which the default
+ # settings for stateful data, like file locations and database versions
+ # on your system were taken. It‘s perfectly fine and recommended to leave
+ # this value at the release version of the first install of this system.
+ # Before changing this value read the documentation for this option
+ # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
+ system.stateVersion = "23.11"; # Did you read the comment?
+}