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 e463c6c68f7689770f5538ed1b048fef030e42ed..2192d5ca6040c467e273dc570ba8e9d2aea95d6d 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 4ea0c07eb68bbbbf1026a12555d976b2f0247e7a..6cdb4b0d9c13ed566cdb07415f27bdb372d34458 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 ffe0cc99e1db66b0daeadaf0abaf4d8f4ce13af3..ae8767d74d6cb5a2b598f576809f6f230885bb9e 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 87481716b130506a754327a4c96ca2ab305c5ea2..57d92a7e9f94f6df392d6c62bbf0a85c53f88701 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 69036ff3d75167813f32391104d6a456ef6df893..620bbe63c9debcb1a8bd2f98e6fcc798ec52a0b3 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 ff99fbec45a91321169b1fb8e2202c2b3a410fd1..4bf28c4b80f78936924249966c5c1be11c5322b9 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 da0be91f7a64cbec5382bc2f71f0f5541941eb7a..2d79dc43996184035214c9de9b569677223f8844 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 0e63acf53efb1983e324bc98cddaae383ede0162..e1121e34063cc5e4d2da909a90ba0b63803cb2be 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 7ae65d74539bd1e2a2d8f97f067a5e598a5f01e8..e8f99dd2749d64deff3aad98eb631d2d5f19cc39 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 df87334033efe3635664211a76553127b6c5c7ac..7c25b124951f70b868ff93a7fb9755e2b9853dcc 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 33f67299b419a4fb1530b962da5b01b040d8cf18..aa9b1ae9f8625bf9a5bd24ae00d39a53118d94e7 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 7640739678cc510a489ec1907f1a7f580189928a..77debafedb18ba6661ae4d20a097e2852043f03c 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 547a8ac4baf8a0450dc98409e7c8dc2a3241854b..376ec6060c73ff8678733f1a5c57360df5f18389 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 9b747870ae9dd37c6f01040242a6bde9dc776792..84680c6bd117b78025f925c513af14b8131a1785 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 dfa4ffb938a9f85b8d8f6c7c6012ea58c250b31c..22c85212df678ed638805419bc5dcbdd55b1f77b 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 af74a4d9ffbc10eb18eb6bba7eed9b8971ddc267..54607fda2269f1ccf4de9343b3a021c7b1d4fd66 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 7a5a8d4e8e6ab8c6d05189568cb48062d3d04fd0..0d8ac9e9ea8d49340d50410088c8112dc851bc28 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 10622a805a9aacc5459b0e36ff314c27ebf46206..3c1d1948e795f5ea7559c80f6bdb0888fcd190a6 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 e844f5c7e252e696427dd9e7598dca41670b8aa3..7aaf69187cb58f5f3071a035ebf028b8a18c9275 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 f54cdc8d2e22524a60d7a56648de7196f81ee18a..0222c7508703ec72804b1b7ad839a3904621f1ce 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 0000000000000000000000000000000000000000..5d87f176330618e7661d8fb3190b9c0beb57518b --- /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"; +} -- 2.54.0