From 8bd9e070d076cb96c0c404b4ec3371f2696f7089 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Tue, 6 May 2025 17:20:37 -0700 Subject: [PATCH] fix natalie config so it builds successfully --- flake.nix | 35 ++++------ lib/mkSystem.nix | 33 +++++----- modules/home-manager.nix | 3 +- modules/macos/default.nix | 7 ++ modules/macos/system.nix | 8 ++- modules/macos/tiling/aerospace.nix | 4 +- modules/macos/tiling/default.nix | 16 ++++- modules/macos/tiling/sketchybar.nix | 4 +- modules/nixos/default.nix | 8 ++- modules/shared/user-system-settings.nix | 21 ++++-- readme.md | 29 +++++++- users/chloe/configuration.nix | 10 +-- users/chloe/user.nix | 2 +- users/natalie/configuration.nix | 18 ++++- users/natalie/desktop/configuration.nix | 14 ++-- users/natalie/desktop/home.nix | 88 +++++++++++-------------- users/natalie/home.nix | 25 ++++--- users/natalie/laptop/configuration.nix | 6 +- users/natalie/laptop/home.nix | 11 +--- users/natalie/packages.nix | 7 +- users/natalie/user.nix | 13 ++++ 21 files changed, 210 insertions(+), 152 deletions(-) create mode 100644 users/natalie/user.nix diff --git a/flake.nix b/flake.nix index e463c6c..2192d5c 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,6 @@ description = "New Modular flake!"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; - # nixpkgs.url = "github:NixOS/nixpkgs/master"; nixpkgs-stable.url = "nixpkgs/nixos-23.11"; home-manager.url = "github:nix-community/home-manager/master"; @@ -77,35 +76,19 @@ ) ]; - # ----- USER SETTINGS ----- # - users.nmarks = rec { - #enable if you want to use a tiling wm on macos - darwinTiling = true; - - username = "nmarks"; # username - name = "Natalie"; # name/identifier - email = "nmarks413@gmail.com"; # email (used for certain configurations) - dotfilesDir = "~/.dotfiles"; # absolute path of the local repo - theme = "catppuccin-mocha"; #name of theme that stylix will use - browser = "firefox"; # Default browser; must select one from ./user/app/browser/ - term = "ghostty"; # Default terminal command; - font = "iosevka"; # Selected font - editor = "neovim"; # Default editor; - spawnEditor = "exec" + term + " -e " + editor; - timeZone = "America/Los_Angeles"; - sexuality = "bisexual"; - }; mkSystem = import ./lib/mkSystem.nix { inherit overlays nixpkgs inputs; }; - in { + in rec { + # "nix run .#darwin-rebuild" packages.aarch64-darwin.darwin-rebuild = darwin.packages.aarch64-darwin.darwin-rebuild; + # "nix fmt ." formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; formatter.aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.alejandra; # natalie's desktop computer nixosConfigurations.nixos = mkSystem "nixos" { - user = "nmarks"; + user = "natalie"; host = "desktop"; system = "x86_64-linux"; extraModules = [ @@ -114,7 +97,7 @@ }; # natalie's laptop darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { - user = "nmarks"; + user = "natalie"; host = "laptop"; system = "aarch64-darwin"; }; @@ -131,5 +114,13 @@ host = "paperback"; system = "aarch64-darwin"; }; + + # generate checks for "nix flake check --all-systems --no-build" + checks.aarch64-darwin = builtins.listToAttrs (builtins.map (name: let + d = darwinConfigurations.${name}.system; + in { + name = "darwinConfiguration-" + d.name; + value = d; + }) (builtins.attrNames darwinConfigurations)); }; } diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 4ea0c07..6cdb4b0 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -44,24 +44,25 @@ currentSystem = system; # Details about the host machine host = { - inherit darwin; + inherit darwin name; }; user = ({ - # This acts as formal documentation for what is allowed in user.nix - username, # unix username - name, # your display name - email, # for identity in programs such as git - dotfilesDir, # location to `../.` - timeZone ? "America/Los_Angeles", - - # Stylix/Theming - theme ? null, # theme name for stylix - sexuality ? null, # pride flag for hyfetch - - term, # preferred $TERM - editor, # preferred $EDITOR - browser ? null, # preferred $BROWSER - }@user: user) userConfig; + # This acts as formal documentation for what is allowed in user.nix + username, # unix username + name, # your display name + email, # for identity in programs such as git + dotfilesDir, # location to `../.` + timeZone ? "America/Los_Angeles", + # Stylix/Theming + theme ? null, # theme name for stylix + sexuality ? null, # pride flag for hyfetch + font ? null, # font to use + term, # preferred $TERM + editor, # preferred $EDITOR + browser ? null, # preferred $BROWSER + } @ user: + user) + userConfig; }; systemSettings = rec { inherit darwin; diff --git a/modules/home-manager.nix b/modules/home-manager.nix index ffe0cc9..ae8767d 100644 --- a/modules/home-manager.nix +++ b/modules/home-manager.nix @@ -69,7 +69,8 @@ in { } ]; shellAliases = - { } // lib.optionalAttrs (!host.darwin) { + {} + // lib.optionalAttrs (!host.darwin) { reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; }; shellInit = '' diff --git a/modules/macos/default.nix b/modules/macos/default.nix index 8748171..57d92a7 100644 --- a/modules/macos/default.nix +++ b/modules/macos/default.nix @@ -8,6 +8,13 @@ ./mac-app-store.nix ./system.nix ./icons.nix + ./tiling # sort-lines: end ]; + # make 'shared.linux' not an error to define. + options.shared.linux = lib.mkOption { + type = lib.types.anything; + default = {}; + description = "no-op on darwin"; + }; } diff --git a/modules/macos/system.nix b/modules/macos/system.nix index 69036ff..620bbe6 100644 --- a/modules/macos/system.nix +++ b/modules/macos/system.nix @@ -3,7 +3,9 @@ pkgs, lib, ... -}: { +}: let + tiling = config.shared.darwin.tiling.enable; +in { # Use touchid or watch to activate sudo security.pam.services.sudo_local = { enable = true; @@ -51,8 +53,8 @@ NSDocumentSaveNewDocumentsToCloud = false; AppleICUForce24HourTime = true; - #Autohide menu bar - #_HIHideMenuBar = config.shared.darwin.tiling; + # Autohide menu bar for tiling window manager + _HIHideMenuBar = tiling; }; # minimal dock dock = { diff --git a/modules/macos/tiling/aerospace.nix b/modules/macos/tiling/aerospace.nix index ff99fbe..4bf28c4 100644 --- a/modules/macos/tiling/aerospace.nix +++ b/modules/macos/tiling/aerospace.nix @@ -1,6 +1,6 @@ -{pkgs, ...}: { +{config,pkgs, ...}: { services.aerospace = { - enable = true; + enable = config.shared.darwin.tiling.enable; settings = { # Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization enable-normalization-flatten-containers = true; diff --git a/modules/macos/tiling/default.nix b/modules/macos/tiling/default.nix index da0be91..2d79dc4 100644 --- a/modules/macos/tiling/default.nix +++ b/modules/macos/tiling/default.nix @@ -1,2 +1,16 @@ -{pkgs, ...}: { +{ lib, ... }: let + inherit (lib) types; +in { + imports = [ + ./sketchybar.nix + ./aerospace.nix + ]; + options = { + shared.darwin.tiling.enable = lib.mkOption { + type = types.bool; + default = false; + example = true; + description = "Enable tiling window management."; + }; + }; } diff --git a/modules/macos/tiling/sketchybar.nix b/modules/macos/tiling/sketchybar.nix index 0e63acf..e1121e3 100644 --- a/modules/macos/tiling/sketchybar.nix +++ b/modules/macos/tiling/sketchybar.nix @@ -1,6 +1,6 @@ -{pkgs, ...}: { +{config,pkgs, ...}: { services.sketchybar = { - enable = true; + enable = config.shared.darwin.tiling.enable; config = '' # This is a demo config to showcase some of the most important commands. # It is meant to be changed and configured, as it is intentionally kept sparse. diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 7ae65d7..e8f99dd 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,8 +1,14 @@ -{pkgs, ...}: { +{ lib, pkgs, ... }: { imports = [ ./boot.nix ./ld.nix ./nvidia.nix ./services.nix ]; + # make 'shared.darwin' not an error to define. + options.shared.darwin = lib.mkOption { + type = lib.types.anything; + default = {}; + description = "no-op on linux"; + }; } diff --git a/modules/shared/user-system-settings.nix b/modules/shared/user-system-settings.nix index df87334..7c25b12 100644 --- a/modules/shared/user-system-settings.nix +++ b/modules/shared/user-system-settings.nix @@ -1,14 +1,21 @@ # applies user settings for the system -{ pkgs, user, lib, ... }: { +{ + pkgs, + user, + lib, + ... +}: { # Set your time zone. time.timeZone = user.timeZone; - home-manager.users.${user.username}.home.sessionVariables = { - EDITOR = user.editor; - TERMINAL = user.term; - } // lib.optionalAttrs (user ? "browser") { - BROWSER = user.browser; - }; + home-manager.users.${user.username}.home.sessionVariables = + { + EDITOR = user.editor; + TERMINAL = user.term; + } + // lib.optionalAttrs (user ? "browser") { + BROWSER = user.browser; + }; stylix = { enable = false; diff --git a/readme.md b/readme.md index 33f6729..aa9b1ae 100644 --- a/readme.md +++ b/readme.md @@ -1,10 +1,35 @@ # nix config -meow. +this setup allows natalie and chloe to share common configuration between their machines, but also share useful modules between each other. + +``` +lib/ # reusable functions +modules/ # reusable modules + +-- macos/ # nix-darwin configurations + +-- nixos/ # linux configurations + +-- nixvim/ # neovim configurations + +-- shared/ # shared between nixos-rebuild & nixos-rebuild + +-- home-manager.nix # home program presets +users/ + +-- chloe/ + | +-- user.nix # info about her + | +-- configuration.nix # for all hosts + | +-- home.nix # for all hosts + | +-- sandwich/ + | | +-- configuration.nix # per host + | | +-- home.nix + | +-- paperback/ + | ... + +-- natalie/ + +-- user.nix # info about her + ... +``` + +A new machine can be added by adding a new definition in `flake.nix`. Note that the user and host `configuration.nix` and `home.nix` files are ## macOS installation instructions -Install Nix using the upstream nix (Pick "no" then "yes): +Install Nix using the upstream Nix (Pick "no" then "yes): ``` curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \ diff --git a/users/chloe/configuration.nix b/users/chloe/configuration.nix index 7640739..77debaf 100644 --- a/users/chloe/configuration.nix +++ b/users/chloe/configuration.nix @@ -1,18 +1,18 @@ # Configuration applied to all of chloe's machines -{ - pkgs, - userSettings, - ... -}: { +{ pkgs, ... }: { + # packages for all machines environment.systemPackages = with pkgs; [ neovim ]; + # configuration for shared modules. + # all custom options in 'shared' for clarity. shared.darwin = { macAppStoreApps = [ "adguard" "magnet" ]; }; + # system preferences system.defaults = { NSGlobalDomain = { KeyRepeat = 1; diff --git a/users/chloe/user.nix b/users/chloe/user.nix index 547a8ac..376ec60 100644 --- a/users/chloe/user.nix +++ b/users/chloe/user.nix @@ -14,5 +14,5 @@ # Default terminal command. NOTE: ghostty is not installed for you term = "ghostty"; # preferred $TERMINAL - editor = "nvim"; # preferred $EDITOR + editor = "nvim"; # preferred $EDITOR } diff --git a/users/natalie/configuration.nix b/users/natalie/configuration.nix index 9b74787..84680c6 100644 --- a/users/natalie/configuration.nix +++ b/users/natalie/configuration.nix @@ -1 +1,17 @@ -services.tailscale.enable = true; +# Applied to all systems +{pkgs, ...}: { + services.tailscale.enable = true; + fonts.packages = with pkgs; [ + nerd-fonts.fira-code + nerd-fonts.iosevka + iosevka + nerd-fonts.symbols-only + nerd-fonts.iosevka + ]; + + # configuration for shared modules. + # all custom options in 'shared' for clarity. + shared.darwin = { + tiling.enable = true; # use tiling window manager + }; +} diff --git a/users/natalie/desktop/configuration.nix b/users/natalie/desktop/configuration.nix index dfa4ffb..22c8521 100644 --- a/users/natalie/desktop/configuration.nix +++ b/users/natalie/desktop/configuration.nix @@ -1,7 +1,7 @@ { pkgs, - userSettings, - systemSettings, + user, + host, ... }: { imports = [ @@ -16,7 +16,7 @@ enable = true; # Certain features, including CLI integration and system authentication support, # require enabling PolKit integration on some desktop environments (e.g. Plasma). - polkitPolicyOwners = [userSettings.username]; + polkitPolicyOwners = [user.username]; }; noisetorch.enable = true; @@ -75,7 +75,7 @@ libvirtd.enable = true; }; - nix.settings.trusted-users = ["root" userSettings.username]; + nix.settings.trusted-users = ["root" user.username]; systemd = { targets = { sleep.enable = false; @@ -129,10 +129,10 @@ # Define a user account. Don't forget to set a password with ‘passwd’. # users.defaultUserShell = pkgs.fish; - users.users.${userSettings.username} = { + users.users.${user.username} = { shell = pkgs.fish; isNormalUser = true; - description = "Natalie Marks"; + description = user.name; extraGroups = ["networkmanager" "wheel" "docker"]; # openssh.authorizedKeys.keyFiles = ["~/.ssh/id_ed25519.pub"]; packages = with pkgs; [ @@ -153,7 +153,7 @@ }; networking = { - hostName = systemSettings.host; # Define your hostname. + hostName = host.name; # Define your hostname. # wireless.enable = true; # Enables wireless support via wpa_supplicant. networkmanager.enable = true; firewall = { diff --git a/users/natalie/desktop/home.nix b/users/natalie/desktop/home.nix index af74a4d..54607fd 100644 --- a/users/natalie/desktop/home.nix +++ b/users/natalie/desktop/home.nix @@ -6,9 +6,7 @@ userSettings, systemSettings, ... -}: let - shared-programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; -in { +}: { imports = [ inputs.nixvim.homeManagerModules.nixvim #set up nixvim @@ -17,56 +15,48 @@ in { home = { stateVersion = "23.05"; # Please read the comment before changing. - packages = with pkgs; let - shared-packages = import ../../modules/shared/packages.nix {inherit pkgs systemSettings;}; - in - shared-packages - ++ [ - #building macos apps hard :( - ghostty - stremio - julia - qbittorrent + packages = with pkgs; [ + #building macos apps hard :( + ghostty + stremio + julia + qbittorrent - #gaming - bottles - lutris - mangohud - dxvk_2 - steam-run - vulkan-tools - path-of-building - wineWowPackages.stable - winetricks - (prismlauncher.override {gamemodeSupport = true;}) + #gaming + bottles + lutris + mangohud + dxvk_2 + steam-run + vulkan-tools + path-of-building + wineWowPackages.stable + winetricks + (prismlauncher.override {gamemodeSupport = true;}) - #window manager stuff - wofi - xorg.xauth - #linux tools - legcord - pavucontrol - ethtool - grub2 - efibootmgr - distrobox - xdg-desktop-portal-gtk - xclip - kdePackages.dolphin - #broken on macos - calibre - mpv - wireguard-tools - signal-desktop - ] - ++ [ - inputs.zls.packages.x86_64-linux.zls - rust-bin.stable.latest.default - ]; + #window manager stuff + wofi + xorg.xauth + #linux tools + legcord + pavucontrol + ethtool + grub2 + efibootmgr + distrobox + xdg-desktop-portal-gtk + xclip + kdePackages.dolphin + #broken on macos + calibre + mpv + wireguard-tools + signal-desktop + inputs.zls.packages.x86_64-linux.zls + rust-bin.stable.latest.default + ]; # programs.mangohud.enable = true; }; - programs = shared-programs; - # xdg.mimeApps.defaultApplications."inode/directory" = "dolphin.desktop"; } diff --git a/users/natalie/home.nix b/users/natalie/home.nix index 7a5a8d4..0d8ac9e 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -1,19 +1,16 @@ { pkgs, lib, -}: { - # sort-lines:start - atuin.enable = true; - bat.enable = true; - hyfetch.enable = true; - direnv.enable = true; - # sort-lines:end + ... +} @ args: { + programs = { + # sort-lines:start + atuin.enable = true; + bat.enable = true; + hyfetch.enable = true; + direnv.enable = true; + # sort-lines:end + }; - fonts.packages = with pkgs; [ - nerd-fonts.fira-code - nerd-fonts.iosevka - iosevka - nerd-fonts.symbols-only - nerd-fonts.iosevka - ]; + home.packages = import ./packages.nix args; } diff --git a/users/natalie/laptop/configuration.nix b/users/natalie/laptop/configuration.nix index 10622a8..3c1d194 100644 --- a/users/natalie/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -1,8 +1,4 @@ -{ - pkgs, - userSettings, - ... -}: { +{pkgs, ...}: { environment.systemPackages = with pkgs; [ neovim pinentry_mac diff --git a/users/natalie/laptop/home.nix b/users/natalie/laptop/home.nix index e844f5c..7aaf691 100644 --- a/users/natalie/laptop/home.nix +++ b/users/natalie/laptop/home.nix @@ -3,8 +3,8 @@ config, pkgs, lib, - userSettings, - systemSettings, + user, + host, ... } @ args: { imports = [ @@ -12,14 +12,9 @@ #set up nixvim # ../../modules/nixvim ]; - programs = import ./home-programs.nix args; - home = { - inherit (userSettings) username; - # shell = pkgs.fish; stateVersion = "23.05"; # Please read the comment before changing. - - packages = pkgs.callPackage ../../modules/shared/packages.nix {inherit systemSettings;}; + # shell = pkgs.fish; sessionPath = [ "$HOME/.emacs.d/bin" diff --git a/users/natalie/packages.nix b/users/natalie/packages.nix index f54cdc8..0222c75 100644 --- a/users/natalie/packages.nix +++ b/users/natalie/packages.nix @@ -1,8 +1,5 @@ -{ - pkgs, - systemSettings, - ... -}: +# Packages installed with home-manager +{pkgs, ...}: with pkgs; [ #general development just diff --git a/users/natalie/user.nix b/users/natalie/user.nix new file mode 100644 index 0000000..5d87f17 --- /dev/null +++ b/users/natalie/user.nix @@ -0,0 +1,13 @@ +rec { + username = "nmarks"; # username + name = "Natalie"; # name/identifier + email = "nmarks413@gmail.com"; # email (used for certain configurations) + dotfilesDir = "~/.dotfiles"; # absolute path of the local repo + theme = "catppuccin-mocha"; #name of theme that stylix will use + browser = "firefox"; # Default browser; must select one from ./user/app/browser/ + term = "ghostty"; # Default terminal command; + font = "iosevka"; # Selected font + editor = "neovim"; # Default editor; + timeZone = "America/Los_Angeles"; + sexuality = "bisexual"; +}