diff --git a/.gitignore b/.gitignore index 5ad4d89..bd001b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ flake.lock .DS_STORE **/.DS_STORE +result +result-* diff --git a/flake.nix b/flake.nix index 07c39d1..ee9fe40 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"; @@ -69,41 +68,51 @@ inputs.nh.overlays.default ]; - # ----- USER SETTINGS ----- # - userSettings = 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"; - - darwinHost = "laptop"; - nixosHost = "desktop"; - }; - mkSystem = import ./lib/mkSystem.nix { - inherit overlays nixpkgs inputs userSettings; + 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 = "natalie"; + host = "desktop"; system = "x86_64-linux"; extraModules = [ nixos-cosmic.nixosModules.default ]; }; + # natalie's laptop darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { + user = "natalie"; + host = "laptop"; system = "aarch64-darwin"; - darwin = true; }; + + # chloe's mac studio "sandwich" + darwinConfigurations.sandwich = mkSystem "sandwich" { + user = "chloe"; + host = "sandwich"; + system = "aarch64-darwin"; + }; + # chloe's macbook air "paperback" + darwinConfigurations.paperback = mkSystem "paperback" { + user = "chloe"; + 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/hosts/.DS_Store b/hosts/.DS_Store deleted file mode 100644 index 35fbfdb..0000000 Binary files a/hosts/.DS_Store and /dev/null differ diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix deleted file mode 100644 index af74a4d..0000000 --- a/hosts/desktop/home.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ - inputs, - config, - pkgs, - lib, - 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 - # ../../modules/nixvim - ]; - 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 - - #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 - ]; - # programs.mangohud.enable = true; - }; - - programs = shared-programs; - - # xdg.mimeApps.defaultApplications."inode/directory" = "dolphin.desktop"; -} diff --git a/hosts/laptop/.DS_Store b/hosts/laptop/.DS_Store deleted file mode 100644 index 4be084e..0000000 Binary files a/hosts/laptop/.DS_Store and /dev/null differ diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix deleted file mode 100644 index 1165040..0000000 --- a/hosts/laptop/home.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - inputs, - config, - pkgs, - lib, - userSettings, - systemSettings, - ... -}: { - imports = - [ - inputs.nixvim.homeManagerModules.nixvim - #set up nixvim - # ../../modules/nixvim - ] - ++ lib.optionals userSettings.darwinTiling [../../modules/macos/tiling/sketchybar-home.nix]; - - programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; - - home = { - inherit (userSettings) username; - # homeDirectory = systemSettings.homeConfig; - # shell = pkgs.fish; - stateVersion = "23.05"; # Please read the comment before changing. - - packages = pkgs.callPackage ../../modules/shared/packages.nix {inherit systemSettings;}; - - # file = { - # ".config/sketchybar" = { - # source = ../../modules/macos/tiling/sketchybar; - # recursive = true; - # onChange = "${pkgs.sketchybar}/bin/sketchybar --reload"; - # }; - # }; - - sessionPath = [ - "$HOME/.emacs.d/bin" - ]; - }; -} diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index e3da27f..6cdb4b0 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -4,116 +4,149 @@ nixpkgs, overlays, inputs, - userSettings, }: name: { - system, - darwin ? false, + user, # ./users/{name} + host ? null, # ./users/{name}/{host} (optional) + system, # arch-os extraModules ? [], }: let - nixindex = - if darwin - then inputs.nix-index-database.darwinModules.nix-index - else inputs.nix-index-database.nixosModules.nix-index; + inherit (builtins) pathExists; + darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; + getInputModule = a: b: + inputs.${ + a + }.${ + if darwin + then "darwinModules" + else "nixosModules" + }.${ + b + }; - stylix = + # NixOS vs nix-darwin functions + systemFunc = if darwin - then inputs.stylix.darwinModules.stylix - else inputs.stylix.nixosModules.stylix; + then inputs.darwin.lib.darwinSystem + else nixpkgs.lib.nixosSystem; - systemModuleDir = - if darwin - then "macos" - else "nixos"; + userDir = ../users + "/${user}"; + userConfig = import (userDir + "/user.nix"); + hostDir = userDir + "/${host}"; + hostConfigPath = hostDir + "/configuration.nix"; + userConfigPath = userDir + "/configuration.nix"; + hostHomePath = hostDir + "/home.nix"; + userHomePath = userDir + "/home.nix"; + + # Arguments passed to all module files + args = { + inherit inputs; + currentSystem = system; + # Details about the host machine + host = { + 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 + font ? null, # font to use + term, # preferred $TERM + editor, # preferred $EDITOR + browser ? null, # preferred $BROWSER + } @ user: + user) + userConfig; + }; systemSettings = rec { inherit darwin; - host = + homeDir = "/${ if darwin - then userSettings.darwinHost - else userSettings.nixosHost; - - # The config files for this system. - - hostConfig = ../hosts/${host}/configuration.nix; - homeConfig = ../hosts/${host}/home.nix; - - homeDir = - if darwin - then "/Users/" + userSettings.username + "/" - else "/home/" + userSettings.username + "/"; - - # NixOS vs nix-darwin functions - systemFunc = - if darwin - then inputs.darwin.lib.darwinSystem - else nixpkgs.lib.nixosSystem; - - hmModules = - if darwin - then inputs.home-manager.darwinModules - else inputs.home-manager.nixosModules; + then "Users" + else "home" + }/${userConfig.username}"; }; in - with systemSettings; - systemFunc rec { - inherit system; + systemFunc { + inherit system; - #gross and ugly hack do NOT like - specialArgs = { - inherit (userSettings) darwinTiling; - }; + modules = + builtins.filter (f: f != null) + [ + # Apply our overlays. Overlays are keyed by system type so we have + # to go through and apply our system type. We do this first so + # the overlays are available globally. + {nixpkgs.overlays = overlays;} - modules = - [ - # Apply our overlays. Overlays are keyed by system type so we have - # to go through and apply our system type. We do this first so - # the overlays are available globally. - {nixpkgs.overlays = overlays;} + # Modules shared between nix-darwin and NixOS + ../modules/shared + # Modules for the specific OS + ( + if darwin + then ../modules/macos + else ../modules/nixos + ) - # Enable caching for nix-index so we dont have to rebuild it + # The user-wide configuration.nix + ( + if pathExists userConfigPath + then userConfigPath + else null + ) + # The host-wide configuration.nix + ( + if host != null && pathExists hostConfigPath + then hostConfigPath + else null + ) - #shared modules - ../modules/shared + # Set up nix-index and enable comma for easy one-shot command use + # https://github.com/nix-community/comma + (getInputModule "nix-index-database" "nix-index") + {programs.nix-index-database.comma.enable = true;} - #system specific modules - ../modules/${systemModuleDir} + # Themes for all programs + (getInputModule "stylix" "stylix") - # Link to config.nix - hostConfig + # Home manager + (getInputModule "home-manager" "home-manager") + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "hm-backup"; + # Arguments passed to all module files + extraSpecialArgs = + args + // { + mainHomeImports = builtins.filter (f: f != null) [ + ( + if pathExists userHomePath + then userHomePath + else null + ) + ( + if host != null && pathExists hostHomePath + then hostHomePath + else null + ) + ]; + }; + # can't find how to make this an array without the param + users.${userConfig.username} = ../modules/home-manager.nix; + }; + users.users.${userConfig.username}.home = systemSettings.homeDir; + } - #Set up nix-index and enable comma for easy one-shot command use - #https://github.com/nix-community/comma - nixindex - {programs.nix-index-database.comma.enable = true;} - - #style programs - stylix - - hmModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - backupFileExtension = "hm-backup"; - extraSpecialArgs = {inherit inputs userSettings systemSettings;}; - users.${userSettings.username} = homeConfig; - }; - - users.users.${userSettings.username}.home = homeDir; - } - - # We expose some extra arguments so that our modules can parameterize - # better based on these values. - { - config._module.args = { - currentSystem = system; - # currentSystemName = name; - # currentSystemUser = userSettings.username; - - inherit inputs userSettings systemSettings; - }; - } - ] - #Add extra modules depending on system - ++ extraModules; - } + # Arguments passed to all module files + {config._module.args = args;} + ] + # Add extra modules specified from config + ++ extraModules; + } diff --git a/modules/home-manager.nix b/modules/home-manager.nix new file mode 100644 index 0000000..ae8767d --- /dev/null +++ b/modules/home-manager.nix @@ -0,0 +1,82 @@ +# This contains default configurations for set of programs +# and configuration, but does not enable many things on it's own. +{ + pkgs, + lib, + config, + user, + host, + mainHomeImports, + ... +}: let + cfg = config.programs; +in { + imports = mainHomeImports; + programs = { + home-manager.enable = true; + nix-index.enable = true; + + direnv = { + enableZshIntegration = true; + nix-direnv.enable = config.programs.direnv.enable; + }; + + git = { + enable = true; + userName = lib.mkDefault user.name; + userEmail = lib.mkDefault user.email; + ignores = [ + (lib.mkIf host.darwin ".DS_Store") # When using Finder + (lib.mkIf host.darwin "._*") # When using non-APFS drives + # ViM and Neovim + ".*.swp" + ".nvimlog" + ]; + }; + + atuin = { + enableBashIntegration = true; + enableFishIntegration = true; + daemon.enable = cfg.atuin.enable; + }; + bat = { + extraPackages = with pkgs.bat-extras; [batdiff batman batgrep batwatch batpipe prettybat]; + }; + hyfetch = { + settings = { + backend = "fastfetch"; + preset = user.sexuality; + mode = "rgb"; + light_dark = "dark"; + lightness = { + }; + color_align = { + mode = "horizontal"; + }; + }; + }; + fastfetch.enable = cfg.hyfetch.enable; + + fish = { + plugins = [ + { + name = "tide"; + inherit (pkgs.fishPlugins.tide) src; + } + { + name = "!!"; + inherit (pkgs.fishPlugins.bang-bang) src; + } + ]; + shellAliases = + {} + // lib.optionalAttrs (!host.darwin) { + reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; + }; + shellInit = '' + batman --export-env | source + ''; + ##test -r '/Users/${user.username}/.opam/opam-init/init.fish' && source '/Users/${user.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true + }; + }; +} diff --git a/modules/macos/default.nix b/modules/macos/default.nix index 8001529..57d92a7 100644 --- a/modules/macos/default.nix +++ b/modules/macos/default.nix @@ -1,13 +1,20 @@ { pkgs, lib, - darwinTiling, ... }: { - imports = - [ - ./homebrew.nix - ./system.nix - ] - ++ lib.optionals darwinTiling [./tiling]; + imports = [ + # sort-lines: start + ./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/mac-app-store.nix b/modules/macos/mac-app-store.nix new file mode 100644 index 0000000..3b0dc41 --- /dev/null +++ b/modules/macos/mac-app-store.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + pkgs, + ... +}: let + types = lib.types; + + # Mapping of Mac App Store applications. + # Add new entries to this list via the App Store's share button + # https://apps.apple.com/us/app/logic-pro/id634148309?mt=12 + # --------- ID HERE + allMasApps = { + # sort-lines:start + adguard = 1440147259; + final-cut-pro = 424389933; + logic-pro = 634148309; + magnet = 441258766; + motion = 434290957; + wireguard = 1451685025; + # sort-lines:end + }; + + # the resolved configuration from the user + masApps = config.shared.darwin.macAppStoreApps; +in { + options = { + # Installs Mac Applications via name using homebrew. + shared.darwin.macAppStoreApps = lib.mkOption { + type = types.listOf types.str; + default = []; + }; + }; + config = lib.mkIf (builtins.length masApps > 0) { + homebrew.enable = true; + homebrew.masApps = builtins.listToAttrs ( + builtins.map (name: { + inherit name; + value = allMasApps.${name}; + }) + masApps + ); + }; +} diff --git a/modules/macos/system.nix b/modules/macos/system.nix index f0d75af..578dda9 100644 --- a/modules/macos/system.nix +++ b/modules/macos/system.nix @@ -1,21 +1,25 @@ { + config, pkgs, - userSettings, + lib, ... -}: { - #Use touchid or watch to activate sudo +}: let + tiling = config.shared.darwin.tiling.enable; +in { + # Use touchid or watch to activate sudo security.pam.services.sudo_local = { enable = true; reattach = true; touchIdAuth = true; }; - # set some OSX preferences that I always end up hunting down and changing. + + # Set some OSX preferences that I always end up hunting down and changing. system = { # Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog stateVersion = 6; - defaults = { + defaults = lib.mkDefault { # Turn quarantine off LaunchServices = { LSQuarantine = false; @@ -53,14 +57,14 @@ NSDocumentSaveNewDocumentsToCloud = false; AppleICUForce24HourTime = true; - #Autohide menu bar - _HIHideMenuBar = userSettings.darwinTiling; + # Autohide menu bar for tiling window manager + _HIHideMenuBar = tiling; }; # minimal dock dock = { autohide = true; - #instant hide and show - autohide-time-modifier = 0.0; + autohide-time-modifier = 0.0; # make animation instant + autohide-delay = 0.0; # remove delay when touching bottom of screen show-process-indicators = true; expose-group-apps = true; @@ -80,13 +84,12 @@ AppleShowAllExtensions = true; ShowPathbar = true; FXEnableExtensionChangeWarning = false; + # TODO: default to list view and not saving .DS_Store }; - CustomSystemPreferences = { "com.apple.universalaccess" = { closeViewTrackpadGestureZoomEnabled = 1; }; - "com.apple.symbolichotkeys" = { AppleSymbolicHotKeys = { "64" = { @@ -96,7 +99,6 @@ }; }; }; - # Bind caps to escape for better normal mode stuff keyboard = { enableKeyMapping = true; diff --git a/modules/macos/tiling/aerospace.nix b/modules/macos/tiling/aerospace.nix index 83aace4..1405b4d 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 0e55ef2..2d79dc4 100644 --- a/modules/macos/tiling/default.nix +++ b/modules/macos/tiling/default.nix @@ -1,6 +1,16 @@ -{pkgs, ...}: { +{ lib, ... }: let + inherit (lib) types; +in { imports = [ - ./aerospace.nix ./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 9716021..e1121e3 100644 --- a/modules/macos/tiling/sketchybar.nix +++ b/modules/macos/tiling/sketchybar.nix @@ -1,6 +1,150 @@ -{pkgs, ...}: { +{config,pkgs, ...}: { services.sketchybar = { - enable = true; - package = pkgs.sketchybar; + 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. + # For a (much) more advanced configuration example see my dotfiles: + # https://github.com/FelixKratz/dotfiles + + PLUGIN_DIR="$CONFIG_DIR/plugins" + + ##### Bar Appearance ##### + # Configuring the general appearance of the bar. + # These are only some of the options available. For all options see: + # https://felixkratz.github.io/SketchyBar/config/bar + # If you are looking for other colors, see the color picker: + # https://felixkratz.github.io/SketchyBar/config/tricks#color-picker + + sketchybar --bar position=top height=40 blur_radius=30 color=0x04313244 + + # Colours + SURFACE=0xff313244 + + ##### Changing Defaults ##### + # We now change some default values, which are applied to all further items. + # For a full list of all available item properties see: + # https://felixkratz.github.io/SketchyBar/config/items + + default=( + padding_left=5 + padding_right=5 + icon.font="Hack Nerd Font:Bold:17.0" + label.font="Hack Nerd Font:Bold:14.0" + icon.color=0xffcdd6f4 + label.color=0xffcdd6f4 + icon.padding_left=8 + icon.padding_right=4 + label.padding_left=4 + label.padding_right=8 + background.padding_left=2 + background.padding_right=2 + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + background.border_width=1 \ + ) + sketchybar --default "$\{default[@]}" + + sketchybar --add event aerospace_workspace_change + + for sid in $(aerospace list-workspaces --all); do + sketchybar --add item space.$sid left \ + --subscribe space.$sid aerospace_workspace_change \ + --set space.$sid \ + background.border_width=1 \ + background.border_color=0xffb4befe \ + background.corner_radius=5 \ + background.height=20 \ + icon.padding_left=0 \ + icon.padding_right=0 \ + label.padding_right=6 \ + label="$sid" \ + click_script="aerospace workspace $sid" \ + script="$CONFIG_DIR/plugins/aerospace.sh $sid" + done + + ##### Adding Left Items ##### + # We add some regular items to the left side of the bar, where + # only the properties deviating from the current defaults need to be set + + sketchybar --add item chevron left \ + --set chevron icon= label.drawing=off background.drawing=off \ + icon.color=0xfff5e0dc \ + --add item front_app left \ + --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ + label.color=0xff94e2d5 \ + label.padding_left=8 \ + background.border_color=0xff94e2d5 \ + --subscribe front_app front_app_switched + + ##### Adding Right Items ##### + # In the same way as the left items we can add items to the right side. + # Additional position (e.g. center) are available, see: + # https://felixkratz.github.io/SketchyBar/config/items#adding-items-to-sketchybar + + # Some items refresh on a fixed cycle, e.g. the clock runs its script once + # every 10s. Other items respond to events they subscribe to, e.g. the + # volume.sh script is only executed once an actual change in system audio + # volume is registered. More info about the event system can be found here: + # https://felixkratz.github.io/SketchyBar/config/events + + sketchybar --add item clock right \ + --set clock update_freq=10 icon=󰃰 script="$PLUGIN_DIR/clock.sh" \ + icon.color=0xfffab387 \ + label.color=0xffcdd6f4 \ + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + --add item volume right \ + --set volume script="$PLUGIN_DIR/volume.sh" \ + label.color=0xffcdd6f4 \ + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + --subscribe volume volume_change \ + --add item battery right \ + --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ + label.color=0xffcdd6f4 \ + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + --subscribe battery system_woke power_source_change + + sketchybar -m --add item mullvad right \ + --set mullvad icon= \ + icon.color=0xfff38ba8 \ + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + background.border_width=1 \ + background.border_color=0xfff38ba8 \ + label.padding_left=0 \ + label.padding_right=0 \ + icon.padding_left=6 \ + update_freq=5 \ + script="$PLUGIN_DIR/mullvad.sh" + + # Add event + sketchybar -m --add event song_update com.apple.iTunes.playerInfo + + # Add Music Item + sketchybar -m --add item music right \ + --set music script="$PLUGIN_DIR/music.sh" \ + click_script="$PLUGIN_DIR/music_click.sh" \ + label.padding_right=10 \ + label.color=0xffcdd6f4 \ + background.color=$SURFACE \ + background.corner_radius=10 \ + background.height=30 \ + background.border_width=1 \ + background.border_color=0xfff38ba8 \ + drawing=off \ + --subscribe music song_update + + ##### Force all scripts to run the first time (never do this in a script) ##### + sketchybar --update + + ''; }; } 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/default.nix b/modules/shared/default.nix index 383c1a1..e44a841 100644 --- a/modules/shared/default.nix +++ b/modules/shared/default.nix @@ -1,6 +1,9 @@ +# shared is used by nixos-rebuild and darwin-rebuild {pkgs, ...}: { imports = [ - ./extras.nix + # sort-lines:start + ./user-system-settings.nix ./nix.nix + # sort-lines:end ]; } diff --git a/modules/shared/extras.nix b/modules/shared/extras.nix deleted file mode 100644 index d1ba2b5..0000000 --- a/modules/shared/extras.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ - inputs, - pkgs, - userSettings, - ... -}: { - services.tailscale.enable = true; - - networking = { - }; - fonts.packages = with pkgs; [ - nerd-fonts.fira-code - nerd-fonts.iosevka - iosevka - nerd-fonts.symbols-only - nerd-fonts.iosevka - inputs.apple-fonts.packages.${pkgs.system}.sf-pro - ]; - - # Set your time zone. - time.timeZone = userSettings.timeZone; - - home-manager.users.${userSettings.username}.home.sessionVariables = { - EDITOR = userSettings.editor; - VISUAL = userSettings.editor; - TERMINAL = userSettings.term; - BROWSER = userSettings.browser; - }; - - stylix = { - enable = true; - base16Scheme = "${pkgs.base16-schemes}/share/themes/${userSettings.theme}.yaml"; - - fonts = { - serif = { - package = pkgs.nerd-fonts.${userSettings.font}; - name = "${userSettings.font} Nerd Font"; - }; - sansSerif = { - package = pkgs.nerd-fonts.${userSettings.font}; - name = "${userSettings.font} Nerd Font"; - }; - monospace = { - package = pkgs.nerd-fonts.${userSettings.font}; - name = "${userSettings.font} Nerd Font"; - }; - emoji = { - package = pkgs.twemoji-color-font; - name = "Twemoji Color"; - }; - }; - }; -} diff --git a/modules/shared/homeManagerPrograms.nix b/modules/shared/homeManagerPrograms.nix deleted file mode 100644 index 078b1f1..0000000 --- a/modules/shared/homeManagerPrograms.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - pkgs, - lib, - userSettings, - systemSettings, - ... -}: { - nix-index.enable = true; - atuin = { - enable = true; - enableBashIntegration = true; - enableFishIntegration = true; - daemon.enable = true; - }; - - direnv = { - enable = true; - enableZshIntegration = true; - nix-direnv.enable = true; - }; - - bat = { - enable = true; - extraPackages = with pkgs.bat-extras; [batdiff batman batgrep batwatch batpipe prettybat]; - }; - - hyfetch = { - enable = true; - settings = { - backend = "fastfetch"; - preset = userSettings.sexuality; - mode = "rgb"; - light_dark = "dark"; - lightness = { - }; - color_align = { - mode = "horizontal"; - }; - }; - }; - - fish = { - enable = true; - - plugins = [ - { - name = "tide"; - inherit (pkgs.fishPlugins.tide) src; - } - { - name = "!!"; - inherit (pkgs.fishPlugins.bang-bang) src; - } - ]; - shellAliases = - { - } - // lib.optionalAttrs (!systemSettings.darwin) { - reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; - }; - shellInit = '' - batman --export-env | source - ''; - ##test -r '/Users/${userSettings.username}/.opam/opam-init/init.fish' && source '/Users/${userSettings.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true - }; - home-manager.enable = true; -} diff --git a/modules/shared/user-system-settings.nix b/modules/shared/user-system-settings.nix new file mode 100644 index 0000000..99ef4f7 --- /dev/null +++ b/modules/shared/user-system-settings.nix @@ -0,0 +1,43 @@ +# applies user settings for the system +{ + 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; + }; + + stylix = { + enable = user ? "theme"; + base16Scheme = "${pkgs.base16-schemes}/share/themes/${user.theme}.yaml"; + + fonts = lib.optionalAttrs (user ? "font") { + serif = { + package = pkgs.nerd-fonts.${user.font}; + name = "${user.font} Nerd Font"; + }; + sansSerif = { + package = pkgs.nerd-fonts.${user.font}; + name = "${user.font} Nerd Font"; + }; + monospace = { + package = pkgs.nerd-fonts.${user.font}; + name = "${user.font} Nerd Font"; + }; + emoji = { + package = pkgs.twemoji-color-font; + name = "Twemoji Color"; + }; + }; + }; +} diff --git a/oldflake.nix b/oldflake.nix deleted file mode 100644 index e5cf756..0000000 --- a/oldflake.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - description = "My first flake!"; - - inputs = { - nixpkgs.url = "nixpkgs/nixos-23.11"; - home-manager = { - url = "github:nix-community/home-manager/release-23.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=<0.2.0>"; - - # hyprland.url = "github:hyprwm/Hyprland"; - # hyprland-plugins = { - # url = "github:hyprwm/hyprland-plugins"; - # inputs.hyprland.follows = "hyprland"; - # }; - # use the following for unstable: - # nixpkgs.url = "nixpkgs/nixos-unstable"; - - # or any branch you want: - # nixpkgs.url = "nixpkgs/{BRANCH-NAME}" - }; - - outputs = { - self, - home-manager, - nixpkgs, - ... - }: let - system = "x86_64-linux"; - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - in { - nixosConfigurations = { - nmarks = lib.nixosSystem { - inherit system; - modules = [./configuration.nix]; - }; - }; - homeConfigurations = { - nmarks = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [./home.nix]; - }; - }; - }; -} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e48f331 --- /dev/null +++ b/readme.md @@ -0,0 +1,65 @@ +# nix config + +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 & darwin-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): + +``` +curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \ + sh -s -- install +``` + +While this installs, now is a good time to perform manual setup steps: + +- Setup your SSH keys in `~/.ssh` +- Configure the device hostname in System Settings in + - About -> Name + - General -> Sharing -> Local Hostname +- Make sure you're logged into iCloud / Mac App Store +- `xcode-select --install` to make sure Git and other utilities are available. +- Optional: Disable app verification with `sudo spctl --master-disable`, then, go to System Settings -> Privacy to allow unsigned apps. + +Once Nix is installed, open a new shell and clone the repository: + +``` +# Clone via HTTPs +git clone https://git.paperclover.net/clo/config.git +# With SSH Authentication +git clone git@git.paperclover.net:clo/config +``` + +The location of the cloned repository must match what is in your `user.nix` file. + +Setup `nix-darwin` using the `switch` helper: + +``` +./switch +``` + diff --git a/switch b/switch new file mode 100755 index 0000000..bd3388f --- /dev/null +++ b/switch @@ -0,0 +1,12 @@ +#!/bin/sh +nh_subcommand="os" +fallback_command="nixos-rebuild" +if [ "$(uname -o)" ]; then + nh_subcommand="darwin" + fallback_command="nix run .#darwin-rebuild" +fi; +if command -v nh > /dev/null; then + nh $nh_subcommand switch . +else + $fallback_command -- switch --flake . +fi diff --git a/users/chloe/configuration.nix b/users/chloe/configuration.nix new file mode 100644 index 0000000..77debaf --- /dev/null +++ b/users/chloe/configuration.nix @@ -0,0 +1,28 @@ +# Configuration applied to all of chloe's machines +{ 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; + InitialKeyRepeat = 10; + }; + CustomUserPreferences = { + NSGlobalDomain = { + # TODO: how to change system accent color + AppleHighlightColor = "1.000000 0.874510 0.701961 Orange"; + }; + }; + }; +} diff --git a/users/chloe/home.nix b/users/chloe/home.nix new file mode 100644 index 0000000..e5a7181 --- /dev/null +++ b/users/chloe/home.nix @@ -0,0 +1,24 @@ +{ + inputs, + pkgs, + lib, + ... +}: { + home = { + stateVersion = "23.05"; # Please read the comment before changing. + packages = [ + pkgs.neovim + pkgs.nh + pkgs.ffmpeg + ]; + }; + programs = { + # sort-lines:start + hyfetch.enable = true; + zsh.enable = true; + # sort-lines:end + + # use a git-specific email + git.userEmail = "git@paperclover.net"; + }; +} diff --git a/users/chloe/paperback/configuration.nix b/users/chloe/paperback/configuration.nix new file mode 100644 index 0000000..d79cf59 --- /dev/null +++ b/users/chloe/paperback/configuration.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + reaper + ]; +} diff --git a/users/chloe/sandwich/configuration.nix b/users/chloe/sandwich/configuration.nix new file mode 100644 index 0000000..5ef1b72 --- /dev/null +++ b/users/chloe/sandwich/configuration.nix @@ -0,0 +1,14 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + ffmpeg + ripgrep + reaper + ]; + shared.darwin = { + macAppStoreApps = [ + "final-cut-pro" + "logic-pro" + "motion" + ]; + }; +} diff --git a/users/chloe/user.nix b/users/chloe/user.nix new file mode 100644 index 0000000..376ec60 --- /dev/null +++ b/users/chloe/user.nix @@ -0,0 +1,18 @@ +# This definition is used by modules to customize as needed. +{ + username = "clo"; # username + name = "chloe caruso"; + email = "account@paperclover.net"; + timeZone = "America/Los_Angeles"; + + dotfilesDir = "~/config"; # absolute path of the local repo + + # Stylix/Theming + theme = "catppuccin-mocha"; + #font + sexuality = "lesbian"; # hyfetch + + # Default terminal command. NOTE: ghostty is not installed for you + term = "ghostty"; # preferred $TERMINAL + editor = "nvim"; # preferred $EDITOR +} diff --git a/users/natalie/configuration.nix b/users/natalie/configuration.nix new file mode 100644 index 0000000..84680c6 --- /dev/null +++ b/users/natalie/configuration.nix @@ -0,0 +1,17 @@ +# 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/hosts/desktop/configuration.nix b/users/natalie/desktop/configuration.nix similarity index 93% rename from hosts/desktop/configuration.nix rename to users/natalie/desktop/configuration.nix index dfa4ffb..22c8521 100644 --- a/hosts/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/hosts/desktop/hardware-configuration.nix b/users/natalie/desktop/hardware-configuration.nix similarity index 100% rename from hosts/desktop/hardware-configuration.nix rename to users/natalie/desktop/hardware-configuration.nix diff --git a/users/natalie/desktop/home.nix b/users/natalie/desktop/home.nix new file mode 100644 index 0000000..54607fd --- /dev/null +++ b/users/natalie/desktop/home.nix @@ -0,0 +1,62 @@ +{ + inputs, + config, + pkgs, + lib, + userSettings, + systemSettings, + ... +}: { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + #set up nixvim + # ../../modules/nixvim + ]; + home = { + stateVersion = "23.05"; # Please read the comment before changing. + + 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;}) + + #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; + }; + + # xdg.mimeApps.defaultApplications."inode/directory" = "dolphin.desktop"; +} diff --git a/glance.yml b/users/natalie/glance.yml similarity index 100% rename from glance.yml rename to users/natalie/glance.yml diff --git a/users/natalie/home.nix b/users/natalie/home.nix new file mode 100644 index 0000000..0d8ac9e --- /dev/null +++ b/users/natalie/home.nix @@ -0,0 +1,16 @@ +{ + pkgs, + lib, + ... +} @ args: { + programs = { + # sort-lines:start + atuin.enable = true; + bat.enable = true; + hyfetch.enable = true; + direnv.enable = true; + # sort-lines:end + }; + + home.packages = import ./packages.nix args; +} diff --git a/hosts/laptop/configuration.nix b/users/natalie/laptop/configuration.nix similarity index 52% rename from hosts/laptop/configuration.nix rename to users/natalie/laptop/configuration.nix index 3208c09..3c1d194 100644 --- a/hosts/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -1,14 +1,16 @@ -{ - pkgs, - userSettings, - ... -}: { +{pkgs, ...}: { environment.systemPackages = with pkgs; [ neovim pinentry_mac signal-desktop-bin ]; + # Custom configuration modules in "modules" are shared between users, + # and can be configured in this "shared" namespace + shared.darwin = { + macAppStoreApps = ["wireguard"]; + }; + # Create /etc/zshrc that loads the nix-darwin environment. programs = { gnupg.agent.enable = true; @@ -25,4 +27,30 @@ fi ''; }; + + # Use homebrew to install casks + homebrew = { + enable = true; + + onActivation = { + autoUpdate = true; + cleanup = "none"; + upgrade = true; + }; + + brews = [ + "imagemagick" + "opam" + ]; + + casks = [ + "battle-net" + "stremio" + "alt-tab" + "legcord" + "zulip" + "zen-browser" + "supertuxkart" + ]; + }; } diff --git a/users/natalie/laptop/home.nix b/users/natalie/laptop/home.nix new file mode 100644 index 0000000..7aaf691 --- /dev/null +++ b/users/natalie/laptop/home.nix @@ -0,0 +1,23 @@ +{ + inputs, + config, + pkgs, + lib, + user, + host, + ... +} @ args: { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + #set up nixvim + # ../../modules/nixvim + ]; + home = { + stateVersion = "23.05"; # Please read the comment before changing. + # shell = pkgs.fish; + + sessionPath = [ + "$HOME/.emacs.d/bin" + ]; + }; +} diff --git a/modules/shared/packages.nix b/users/natalie/packages.nix similarity index 95% rename from modules/shared/packages.nix rename to users/natalie/packages.nix index f54cdc8..0222c75 100644 --- a/modules/shared/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"; +}