From 8cf0abc7150dd35a56f82b8fbf9fa8c529151962 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Mon, 5 May 2025 18:53:09 -0700 Subject: [PATCH 1/6] support multiple users, add chloe's machines --- flake.nix | 42 +++++++++++++++++++++++++++++---- lib/mkSystem.nix | 60 ++++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 37 deletions(-) diff --git a/flake.nix b/flake.nix index d4c75d6..faad74d 100644 --- a/flake.nix +++ b/flake.nix @@ -78,7 +78,7 @@ ]; # ----- USER SETTINGS ----- # - userSettings = rec { + users.nmarks = rec { #enable if you want to use a tiling wm on macos darwinTiling = true; @@ -94,24 +94,56 @@ spawnEditor = "exec" + term + " -e " + editor; timeZone = "America/Los_Angeles"; sexuality = "bisexual"; + }; + users.paper_clover = rec { + #enable if you want to use a tiling wm on macos + darwinTiling = true; - darwinHost = "laptop"; - nixosHost = "desktop"; + username = "clo"; # username + name = "chloe caruso"; # name/identifier + email = "account@paperclover.net"; # email (used for certain configurations) + dotfilesDir = "~/config"; # 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 = "lesbian"; }; mkSystem = import ./lib/mkSystem.nix { - inherit overlays nixpkgs inputs userSettings; + inherit overlays nixpkgs inputs; }; in { + # natalie's desktop computer nixosConfigurations.nixos = mkSystem "nixos" { + userSettings = users.nmarks; + configDir = ./hosts/desktop; system = "x86_64-linux"; extraModules = [ nixos-cosmic.nixosModules.default ]; }; + # natalie's laptop darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { + userSettings = users.nmarks; + configDir = ./hosts/laptop; + system = "aarch64-darwin"; + }; + + # chloe's mac studio "sandwich" + darwinConfigurations.sandwich = mkSystem "sandwich" { + userSettings = users.paper_clover; + configDir = ./hosts/laptop; + system = "aarch64-darwin"; + }; + # chloe's macbook air "paperback" + darwinConfigurations.paperback = mkSystem "paperback" { + userSettings = users.paper_clover; + configDir = ./hosts/laptop; system = "aarch64-darwin"; - darwin = true; }; }; } diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index e3da27f..43fd903 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -4,12 +4,14 @@ nixpkgs, overlays, inputs, - userSettings, }: name: { + userSettings, system, - darwin ? false, + configDir, # base host config extraModules ? [], }: let + darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; + nixindex = if darwin then inputs.nix-index-database.darwinModules.nix-index @@ -25,40 +27,36 @@ then "macos" else "nixos"; - systemSettings = rec { - inherit darwin; - host = - 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; + + # The config files for this system. + hostConfig = configDir + "/configuration.nix"; + homeConfig = configDir + "/home.nix"; + hmModules = if darwin then inputs.home-manager.darwinModules else inputs.home-manager.nixosModules; + + systemSettings = rec { + inherit darwin; + + homeDir = + if darwin + then "/Users/" + userSettings.username + "/" + else "/home/" + userSettings.username + "/"; + }; in - with systemSettings; - systemFunc rec { + systemFunc { inherit system; - #gross and ugly hack do NOT like + # TODO: gross and ugly hack do NOT like specialArgs = { inherit (userSettings) darwinTiling; }; @@ -70,23 +68,21 @@ in # the overlays are available globally. {nixpkgs.overlays = overlays;} - # Enable caching for nix-index so we dont have to rebuild it - - #shared modules + # Shared modules ../modules/shared - #system specific modules + # System specific modules ../modules/${systemModuleDir} - # Link to config.nix + # Link to configuration.nix hostConfig - #Set up nix-index and enable comma for easy one-shot command use - #https://github.com/nix-community/comma + # 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 + # Themes for all programs stylix hmModules.home-manager @@ -99,7 +95,7 @@ in users.${userSettings.username} = homeConfig; }; - users.users.${userSettings.username}.home = homeDir; + users.users.${userSettings.username}.home = systemSettings.homeDir; } # We expose some extra arguments so that our modules can parameterize @@ -114,6 +110,6 @@ in }; } ] - #Add extra modules depending on system + # Add extra modules specified from config ++ extraModules; } From 24d8eeb413b682d7ce51303b789f7c229ae2d9b6 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Mon, 5 May 2025 19:05:37 -0700 Subject: [PATCH 2/6] reorganize "hosts/" into "users/" the plan here is a user owns one or multiple machines: users/ +-- chloe/ | +-- home.nix # apply to all | +-- sandwich/ | | +-- configuration.nix # per machine | | +-- home.nix | +-- paperback/ | ... +-- natalie/ ... --- .DS_Store | Bin 6148 -> 0 bytes flake.nix | 8 ++--- hosts/.DS_Store | Bin 6148 -> 0 bytes hosts/laptop/.DS_Store | Bin 6148 -> 0 bytes .../laptop => users/chloe}/configuration.nix | 0 {hosts/laptop => users/chloe}/home.nix | 0 .../natalie}/desktop/configuration.nix | 0 .../desktop/hardware-configuration.nix | 0 {hosts => users/natalie}/desktop/home.nix | 0 users/natalie/laptop/configuration.nix | 28 +++++++++++++++++ users/natalie/laptop/home.nix | 29 ++++++++++++++++++ 11 files changed, 61 insertions(+), 4 deletions(-) delete mode 100644 .DS_Store delete mode 100644 hosts/.DS_Store delete mode 100644 hosts/laptop/.DS_Store rename {hosts/laptop => users/chloe}/configuration.nix (100%) rename {hosts/laptop => users/chloe}/home.nix (100%) rename {hosts => users/natalie}/desktop/configuration.nix (100%) rename {hosts => users/natalie}/desktop/hardware-configuration.nix (100%) rename {hosts => users/natalie}/desktop/home.nix (100%) create mode 100644 users/natalie/laptop/configuration.nix create mode 100644 users/natalie/laptop/home.nix diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 140a77d1ac095724aa4222b51f02370376473033..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5Z>*NNhm@N3Oz1(E!fs76fYsx7cim+m70)3gE3p0lpabUXMG``#OHBl zcUuVNETS_o`_0bJX7fRIGmJ6rui^n?E@R9FMdWDI2)b)S4U^0PL1B$NTIY)>l~K(y zzte?#Z?id*EN4Y!{~ysJP4c4O|KyEkt9@Wuj@7ZAg1KA=MOdtIKU_ZG>{iM&+Sy@r zm(12v_vlJyMVMr>r7B3`8KgYkCs{1lzFcK-u4)4va2(s2y4}s@d^GBb!P&*OCpP0@ zzb8iH;dblT$0w(kH`AB&HIr|eNRB&4In=Np-}e?7!~iis3=jjvKpg|-2C+MJLGlp; z#K6C10M7>jis%_EHL9Zn2Gs%pw!p0fZ0selMi}%AmKq@f!gVR2F6E}h;JO_A!sK}d zOO3jmanpQo^W6;{AUOpG<9&UoD{-F+dFbF$Q>R z5=?w}DRZ}edp*2s1?V#<3g(q)fPh{334jTnBV85Lae+4Ec?L_3xC;7JIUxNAC_-o; I27Z8nFVR~?i~s-t diff --git a/flake.nix b/flake.nix index faad74d..0bd6ce0 100644 --- a/flake.nix +++ b/flake.nix @@ -120,7 +120,7 @@ # natalie's desktop computer nixosConfigurations.nixos = mkSystem "nixos" { userSettings = users.nmarks; - configDir = ./hosts/desktop; + configDir = ./hosts/natalie/desktop; system = "x86_64-linux"; extraModules = [ nixos-cosmic.nixosModules.default @@ -129,20 +129,20 @@ # natalie's laptop darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { userSettings = users.nmarks; - configDir = ./hosts/laptop; + configDir = ./hosts/natalie/laptop; system = "aarch64-darwin"; }; # chloe's mac studio "sandwich" darwinConfigurations.sandwich = mkSystem "sandwich" { userSettings = users.paper_clover; - configDir = ./hosts/laptop; + configDir = ./hosts/chloe; system = "aarch64-darwin"; }; # chloe's macbook air "paperback" darwinConfigurations.paperback = mkSystem "paperback" { userSettings = users.paper_clover; - configDir = ./hosts/laptop; + configDir = ./hosts/chloe; system = "aarch64-darwin"; }; }; diff --git a/hosts/.DS_Store b/hosts/.DS_Store deleted file mode 100644 index 35fbfdbfc0e1e2dbaad4d81ec972ed669ba56405..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKQA+|r5S~?24+(rI@NuD6AvFu6m&5E2bWsl#cE<@GUAN+$_#nbP*B|Pa^n04w zT_drcgeaMT*>84sW|#eL*|`M((VvBFfI0wFQ3(qUHs1)1lWs`CdI*J{L%}4Nr;{L7 z!A3MY{vreP?aB~?4-?2>{rkNIlQ>GVR_k39ilx1BrQ%d-l?QLE=3eG!v$XF|@2GdJ zR2-~qKe&lT^I`qqLM53WC8McMh{6$u+}}n?sOEh&OTtv=dS<|Js?M<9SS(Jv-KK1x zoGqJj(d)FDvfJw{mrnKY==l6<_!K`U>ctQ#@XTr1x442=G|G^|7a|q6k$>kO{%a@3}MpIFKwJ_F*j(^LFkon9=o!zFBG9yN59nJAY6moG6T%OIs--1 ztyBHK{Q3RAp2R(7fEm~+21IG#4f?nxTU$3aN3~X>KBAIPTyF3)1r1$_F_ubk162$9 YB^ijW#oQozQ20kc)4&Zg@T&}b00eP<5C8xG diff --git a/hosts/laptop/.DS_Store b/hosts/laptop/.DS_Store deleted file mode 100644 index 4be084eeb267c00f5520ddb5bd0a88f0f42b9f06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5Z>*NNhm@N3Oz1(E!fs76fdFH7cim+m717>!I&*gN)Dxvv%Zi|;`2DO zyDbEB7SS1){buK9v-u#q8O9i&tfB#9E@R9FMdWDI2)b)S4U^0PL1B$7EV4zI$gpOa z-|51=w^_`dm}F^X{~zHZiL<=l|KyEktG#Dgj@7Xq{AXGCd62KNNwB=b*|n5OxV3}u zCY~2F_uxXNc@U@br7DP{Ii%d*#%UyriCm>orfPj1a2(s2x!v{pbTsOT!O7XCC)VR( zzb8iH;b!C5heyZfSF@MoHI;9gNRB&4+1Ice-**-n!~iis3=jjvKpg|-2C+MJLGlp; z#K6C10M7>jis%_EHL9Zn2Gs%pw!p0fZ0selMi}%AmKq@f!gVR2F6E}h;JO_A!sK}d zOO3jmanpQo^W<&w!qwAZeWB7B_cYQ-3=jiV2AX>6;{AUKpG<9&UoD{-F+dFbF$Q>R z>Q5)|Qs!>`_Ih~N3eZPT6wE8p00F!5695xDN4hGg;{t8S^9+_6aTWBdazOeKP=wGx I4Ez8CU+ Date: Mon, 5 May 2025 23:56:54 -0700 Subject: [PATCH 3/6] write out chloe config, modularize stuff more --- .gitignore | 2 + flake.nix | 38 +--- lib/mkSystem.nix | 212 ++++++++++-------- modules/home-manager.nix | 81 +++++++ modules/macos/default.nix | 14 +- modules/macos/homebrew.nix | 31 --- modules/macos/mac-app-store.nix | 44 ++++ modules/macos/system.nix | 20 +- modules/macos/tiling/default.nix | 4 - modules/shared/default.nix | 5 +- modules/shared/extras.nix | 51 ----- modules/shared/homeManagerPrograms.nix | 67 ------ modules/shared/user-system-settings.nix | 36 +++ oldflake.nix | 47 ---- readme.md | 40 ++++ switch | 12 + users/chloe/configuration.nix | 34 +-- users/chloe/home.nix | 31 ++- users/chloe/sandwich/configuration.nix | 14 ++ users/chloe/user.nix | 18 ++ users/natalie/configuration.nix | 1 + glance.yml => users/natalie/glance.yml | 0 users/natalie/home.nix | 19 ++ users/natalie/laptop/configuration.nix | 32 +++ users/natalie/laptop/home.nix | 5 +- .../shared => users/natalie}/packages.nix | 0 26 files changed, 488 insertions(+), 370 deletions(-) create mode 100644 modules/home-manager.nix delete mode 100644 modules/macos/homebrew.nix create mode 100644 modules/macos/mac-app-store.nix delete mode 100644 modules/shared/extras.nix delete mode 100644 modules/shared/homeManagerPrograms.nix create mode 100644 modules/shared/user-system-settings.nix delete mode 100644 oldflake.nix create mode 100644 readme.md create mode 100755 switch create mode 100644 users/chloe/sandwich/configuration.nix create mode 100644 users/chloe/user.nix create mode 100644 users/natalie/configuration.nix rename glance.yml => users/natalie/glance.yml (100%) create mode 100644 users/natalie/home.nix rename {modules/shared => users/natalie}/packages.nix (100%) diff --git a/.gitignore b/.gitignore index 301d47e..2901f29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ flake.lock +result +result-* diff --git a/flake.nix b/flake.nix index 0bd6ce0..e463c6c 100644 --- a/flake.nix +++ b/flake.nix @@ -95,32 +95,18 @@ timeZone = "America/Los_Angeles"; sexuality = "bisexual"; }; - users.paper_clover = rec { - #enable if you want to use a tiling wm on macos - darwinTiling = true; - - username = "clo"; # username - name = "chloe caruso"; # name/identifier - email = "account@paperclover.net"; # email (used for certain configurations) - dotfilesDir = "~/config"; # 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 = "lesbian"; - }; - mkSystem = import ./lib/mkSystem.nix { inherit overlays nixpkgs inputs; }; in { + packages.aarch64-darwin.darwin-rebuild = darwin.packages.aarch64-darwin.darwin-rebuild; + 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" { - userSettings = users.nmarks; - configDir = ./hosts/natalie/desktop; + user = "nmarks"; + host = "desktop"; system = "x86_64-linux"; extraModules = [ nixos-cosmic.nixosModules.default @@ -128,21 +114,21 @@ }; # natalie's laptop darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" { - userSettings = users.nmarks; - configDir = ./hosts/natalie/laptop; + user = "nmarks"; + host = "laptop"; system = "aarch64-darwin"; }; # chloe's mac studio "sandwich" darwinConfigurations.sandwich = mkSystem "sandwich" { - userSettings = users.paper_clover; - configDir = ./hosts/chloe; + user = "chloe"; + host = "sandwich"; system = "aarch64-darwin"; }; # chloe's macbook air "paperback" darwinConfigurations.paperback = mkSystem "paperback" { - userSettings = users.paper_clover; - configDir = ./hosts/chloe; + user = "chloe"; + host = "paperback"; system = "aarch64-darwin"; }; }; diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 43fd903..4ea0c07 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -5,111 +5,147 @@ overlays, inputs, }: name: { - userSettings, - system, - configDir, # base host config + user, # ./users/{name} + host ? null, # ./users/{name}/{host} (optional) + system, # arch-os extraModules ? [], }: let + inherit (builtins) pathExists; darwin = nixpkgs.lib.strings.hasSuffix "-darwin" system; - - nixindex = - if darwin - then inputs.nix-index-database.darwinModules.nix-index - else inputs.nix-index-database.nixosModules.nix-index; - - stylix = - if darwin - then inputs.stylix.darwinModules.stylix - else inputs.stylix.nixosModules.stylix; - - systemModuleDir = - if darwin - then "macos" - else "nixos"; - - # NixOS vs nix-darwin functions - systemFunc = + getInputModule = a: b: + inputs.${ + a + }.${ if darwin - then inputs.darwin.lib.darwinSystem - else nixpkgs.lib.nixosSystem; + then "darwinModules" + else "nixosModules" + }.${ + b + }; + # NixOS vs nix-darwin functions + systemFunc = + if darwin + then inputs.darwin.lib.darwinSystem + else nixpkgs.lib.nixosSystem; - # The config files for this system. - hostConfig = configDir + "/configuration.nix"; - homeConfig = configDir + "/home.nix"; + userDir = ../users + "/${user}"; + userConfig = import (userDir + "/user.nix"); + hostDir = userDir + "/${host}"; - hmModules = - if darwin - then inputs.home-manager.darwinModules - else inputs.home-manager.nixosModules; + 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; + }; + 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; + }; systemSettings = rec { inherit darwin; - - homeDir = + homeDir = "/${ if darwin - then "/Users/" + userSettings.username + "/" - else "/home/" + userSettings.username + "/"; - + then "Users" + else "home" + }/${userConfig.username}"; }; in - systemFunc { - inherit system; + systemFunc { + inherit system; - # TODO: 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 + ) - # Shared modules - ../modules/shared + # 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 + ) - # System specific modules - ../modules/${systemModuleDir} + # 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;} - # Link to configuration.nix - hostConfig + # Themes for all programs + (getInputModule "stylix" "stylix") - # 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;} + # 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; + } - # Themes for all 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 = systemSettings.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 specified from config - ++ 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..ffe0cc9 --- /dev/null +++ b/modules/home-manager.nix @@ -0,0 +1,81 @@ +# 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..8748171 100644 --- a/modules/macos/default.nix +++ b/modules/macos/default.nix @@ -1,13 +1,13 @@ { pkgs, lib, - darwinTiling, ... }: { - imports = - [ - ./homebrew.nix - ./system.nix - ] - ++ lib.optionals darwinTiling [./tiling]; + imports = [ + # sort-lines: start + ./mac-app-store.nix + ./system.nix + ./icons.nix + # sort-lines: end + ]; } diff --git a/modules/macos/homebrew.nix b/modules/macos/homebrew.nix deleted file mode 100644 index 7439039..0000000 --- a/modules/macos/homebrew.nix +++ /dev/null @@ -1,31 +0,0 @@ -_: { - # Use homebrew to install casks and Mac App Store apps - homebrew = { - enable = true; - - onActivation = { - autoUpdate = true; - cleanup = "none"; - upgrade = true; - }; - - brews = [ - "imagemagick" - "opam" - ]; - - casks = [ - "battle-net" - "stremio" - "alt-tab" - "legcord" - "zulip" - "zen-browser" - "supertuxkart" - ]; - - masApps = { - "wireguard" = 1451685025; - }; - }; -} 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 9672bad..69036ff 100644 --- a/modules/macos/system.nix +++ b/modules/macos/system.nix @@ -1,21 +1,23 @@ { + config, pkgs, - userSettings, + lib, ... }: { - #Use touchid or watch to activate sudo + # 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; @@ -50,13 +52,13 @@ AppleICUForce24HourTime = true; #Autohide menu bar - _HIHideMenuBar = userSettings.darwinTiling; + #_HIHideMenuBar = config.shared.darwin.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; @@ -76,13 +78,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" = { @@ -92,7 +93,6 @@ }; }; }; - # Bind caps to escape for better normal mode stuff keyboard = { enableKeyMapping = true; diff --git a/modules/macos/tiling/default.nix b/modules/macos/tiling/default.nix index 0e55ef2..da0be91 100644 --- a/modules/macos/tiling/default.nix +++ b/modules/macos/tiling/default.nix @@ -1,6 +1,2 @@ {pkgs, ...}: { - imports = [ - ./aerospace.nix - ./sketchybar.nix - ]; } 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 661b60d..0000000 --- a/modules/shared/extras.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ - 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 - ]; - - # 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..df87334 --- /dev/null +++ b/modules/shared/user-system-settings.nix @@ -0,0 +1,36 @@ +# 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 = false; + base16Scheme = "${pkgs.base16-schemes}/share/themes/${user.theme}.yaml"; + + fonts = { + 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..33f6729 --- /dev/null +++ b/readme.md @@ -0,0 +1,40 @@ +# nix config + +meow. + +## 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 +``` + +Open a new shell and clone the repository: + +``` +# Install git + other command tools. (Used by many programs) +xcode-select --install + +# Clone via HTTPs +git clone https://git.paperclover.net/clo/config.git +# With SSH Authentication +git clone git@git.paperclover.net:clo/config +``` + +Setup `nix-darwin` +``` +# Tell nix-darwin where the flake is at. +sudo mkdir /etc/nix-darwin +sudo ln -s $(realpath flake.nix) /etc/nix-darwin/ + +# Enable configuration. +nix run .#darwin-rebuild switch +``` + +Additionally, it may be helpful to disable the unsigned app popup. +``` +sudo spctl --master-disable +# then, go to System Settings -> Privacy to allow unsigned apps. +``` diff --git a/switch b/switch new file mode 100755 index 0000000..28db103 --- /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 +fi diff --git a/users/chloe/configuration.nix b/users/chloe/configuration.nix index 3208c09..7640739 100644 --- a/users/chloe/configuration.nix +++ b/users/chloe/configuration.nix @@ -1,3 +1,4 @@ +# Configuration applied to all of chloe's machines { pkgs, userSettings, @@ -5,24 +6,23 @@ }: { environment.systemPackages = with pkgs; [ neovim - pinentry_mac - signal-desktop-bin ]; - - # Create /etc/zshrc that loads the nix-darwin environment. - programs = { - gnupg.agent.enable = true; - zsh.enable = true; # default shell on catalina + shared.darwin = { + macAppStoreApps = [ + "adguard" + "magnet" + ]; }; - - # When opening an interactive shell that isnt fish move into fish - programs.zsh = { - interactiveShellInit = '' - if [[ $(${pkgs.procps}/bin/ps -p $PPID -o comm) != "fish" && -z ''${ZSH_EXUCTION_STRING} ]] - then - [[ -o login ]] && LOGIN_OPTION='--login' || LOGIN_OPTION="" - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION - fi - ''; + 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 index f95fe9e..e5a7181 100644 --- a/users/chloe/home.nix +++ b/users/chloe/home.nix @@ -1,29 +1,24 @@ { inputs, - config, pkgs, lib, - userSettings, - systemSettings, ... }: { - imports = [ - inputs.nixvim.homeManagerModules.nixvim - #set up nixvim - # ../../modules/nixvim - ]; - 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;}; - - sessionPath = [ - "$HOME/.emacs.d/bin" + 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/sandwich/configuration.nix b/users/chloe/sandwich/configuration.nix new file mode 100644 index 0000000..5cc2bdc --- /dev/null +++ b/users/chloe/sandwich/configuration.nix @@ -0,0 +1,14 @@ +# Configuration applied to all of chloe's machines +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + ffmpeg + ripgrep + ]; + 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..547a8ac --- /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..9b74787 --- /dev/null +++ b/users/natalie/configuration.nix @@ -0,0 +1 @@ +services.tailscale.enable = true; 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..7a5a8d4 --- /dev/null +++ b/users/natalie/home.nix @@ -0,0 +1,19 @@ +{ + pkgs, + lib, +}: { + # 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 + ]; +} diff --git a/users/natalie/laptop/configuration.nix b/users/natalie/laptop/configuration.nix index 3208c09..10622a8 100644 --- a/users/natalie/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -9,6 +9,12 @@ 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 +31,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 index f95fe9e..e844f5c 100644 --- a/users/natalie/laptop/home.nix +++ b/users/natalie/laptop/home.nix @@ -6,17 +6,16 @@ userSettings, systemSettings, ... -}: { +} @ args: { imports = [ inputs.nixvim.homeManagerModules.nixvim #set up nixvim # ../../modules/nixvim ]; - programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; + programs = import ./home-programs.nix args; home = { inherit (userSettings) username; - # homeDirectory = systemSettings.homeConfig; # shell = pkgs.fish; stateVersion = "23.05"; # Please read the comment before changing. diff --git a/modules/shared/packages.nix b/users/natalie/packages.nix similarity index 100% rename from modules/shared/packages.nix rename to users/natalie/packages.nix From 8bd9e070d076cb96c0c404b4ec3371f2696f7089 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Tue, 6 May 2025 17:20:37 -0700 Subject: [PATCH 4/6] 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"; +} From 9872e50bf6b780eefaf444f7d8ce3581c8a2dab4 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Tue, 6 May 2025 23:31:53 -0700 Subject: [PATCH 5/6] add REAPER to chloe's configs --- users/chloe/paperback/configuration.nix | 5 +++++ users/chloe/sandwich/configuration.nix | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 users/chloe/paperback/configuration.nix 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 index 5cc2bdc..5ef1b72 100644 --- a/users/chloe/sandwich/configuration.nix +++ b/users/chloe/sandwich/configuration.nix @@ -1,8 +1,8 @@ -# Configuration applied to all of chloe's machines {pkgs, ...}: { environment.systemPackages = with pkgs; [ ffmpeg ripgrep + reaper ]; shared.darwin = { macAppStoreApps = [ From 7d4ca2186692c97bde07d7bcf76053035902a4ff Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Wed, 7 May 2025 09:45:02 -0700 Subject: [PATCH 6/6] meowing --- modules/shared/user-system-settings.nix | 4 +-- readme.md | 34 ++++++++++++------------- switch | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/shared/user-system-settings.nix b/modules/shared/user-system-settings.nix index 7c25b12..99ef4f7 100644 --- a/modules/shared/user-system-settings.nix +++ b/modules/shared/user-system-settings.nix @@ -18,10 +18,10 @@ }; stylix = { - enable = false; + enable = user ? "theme"; base16Scheme = "${pkgs.base16-schemes}/share/themes/${user.theme}.yaml"; - fonts = { + fonts = lib.optionalAttrs (user ? "font") { serif = { package = pkgs.nerd-fonts.${user.font}; name = "${user.font} Nerd Font"; diff --git a/readme.md b/readme.md index aa9b1ae..e48f331 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ modules/ # reusable modules +-- macos/ # nix-darwin configurations +-- nixos/ # linux configurations +-- nixvim/ # neovim configurations - +-- shared/ # shared between nixos-rebuild & nixos-rebuild + +-- shared/ # shared between nixos-rebuild & darwin-rebuild +-- home-manager.nix # home program presets users/ +-- chloe/ @@ -36,30 +36,30 @@ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix sh -s -- install ``` -Open a new shell and clone the repository: +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: ``` -# Install git + other command tools. (Used by many programs) -xcode-select --install - # Clone via HTTPs git clone https://git.paperclover.net/clo/config.git # With SSH Authentication git clone git@git.paperclover.net:clo/config ``` -Setup `nix-darwin` -``` -# Tell nix-darwin where the flake is at. -sudo mkdir /etc/nix-darwin -sudo ln -s $(realpath flake.nix) /etc/nix-darwin/ +The location of the cloned repository must match what is in your `user.nix` file. -# Enable configuration. -nix run .#darwin-rebuild switch +Setup `nix-darwin` using the `switch` helper: + +``` +./switch ``` -Additionally, it may be helpful to disable the unsigned app popup. -``` -sudo spctl --master-disable -# then, go to System Settings -> Privacy to allow unsigned apps. -``` diff --git a/switch b/switch index 28db103..bd3388f 100755 --- a/switch +++ b/switch @@ -8,5 +8,5 @@ fi; if command -v nh > /dev/null; then nh $nh_subcommand switch . else - $fallback_command switch + $fallback_command -- switch --flake . fi