dawin/linux

This commit is contained in:
Harivansh Rathi 2026-03-22 14:47:28 -04:00
parent 5cdf8fd873
commit 1e4caa255f
6 changed files with 20 additions and 19 deletions

View file

@ -3,8 +3,8 @@
## Layout
- `flake.nix`: top-level flake and host wiring
- `hosts/hari-macbook-pro/default.nix`: this machine's host config
- `hosts/workstation/default.nix`: standalone Linux Home Manager host config
- `hosts/darwin/default.nix`: macOS nix-darwin host config
- `hosts/linux/default.nix`: standalone Linux Home Manager host config
- `modules/base.nix`: Nix settings and core packages
- `modules/macos.nix`: macOS defaults and host-level settings
- `modules/packages.nix`: system packages and fonts

View file

@ -41,8 +41,9 @@
darwinSystem = "aarch64-darwin";
linuxSystem = "x86_64-linux";
username = "rathi";
darwinHostname = "hari-macbook-pro";
linuxHostname = "workstation";
darwinConfigName = "darwin";
darwinMachineHostname = "hari-macbook-pro";
linuxConfigName = "linux";
darwinPkgs = import nixpkgs {system = darwinSystem;};
linuxPkgs = import nixpkgs {
system = linuxSystem;
@ -52,14 +53,14 @@
formatter.${darwinSystem} = darwinPkgs.alejandra;
formatter.${linuxSystem} = linuxPkgs.alejandra;
darwinConfigurations.${darwinHostname} = nix-darwin.lib.darwinSystem {
darwinConfigurations.${darwinConfigName} = nix-darwin.lib.darwinSystem {
system = darwinSystem;
specialArgs = {
inherit inputs self username;
hostname = darwinHostname;
hostname = darwinMachineHostname;
};
modules = [
./hosts/${darwinHostname}
./hosts/${darwinConfigName}
home-manager.darwinModules.home-manager
nix-homebrew.darwinModules.nix-homebrew
{
@ -69,7 +70,7 @@
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs self username;
hostname = darwinHostname;
hostname = darwinMachineHostname;
};
home-manager.backupFileExtension = "hm-bak";
home-manager.users.${username} = import ./home;
@ -84,14 +85,14 @@
];
};
homeConfigurations.${linuxHostname} = home-manager.lib.homeManagerConfiguration {
homeConfigurations.${linuxConfigName} = home-manager.lib.homeManagerConfiguration {
pkgs = linuxPkgs;
extraSpecialArgs = {
inherit inputs self username;
hostname = linuxHostname;
hostname = linuxConfigName;
};
modules = [
./hosts/${linuxHostname}
./hosts/${linuxConfigName}
];
};
};

View file

@ -47,12 +47,12 @@
}
// lib.optionalAttrs pkgs.stdenv.isDarwin {
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
nrb = "sudo darwin-rebuild switch --flake path:$HOME/Documents/GitHub/nix#hari-macbook-pro"; # nrb - rebuild declarative config
nup = "nix flake update $HOME/Documents/GitHub/nix && sudo darwin-rebuild switch --flake path:$HOME/Documents/GitHub/nix#hari-macbook-pro"; # nup - update flake + rebuild
nrb = "sudo darwin-rebuild switch --flake path:$HOME/Documents/GitHub/nix#darwin"; # nrb - rebuild declarative config
nup = "nix flake update $HOME/Documents/GitHub/nix && sudo darwin-rebuild switch --flake path:$HOME/Documents/GitHub/nix#darwin"; # nup - update flake + rebuild
}
// lib.optionalAttrs pkgs.stdenv.isLinux {
nrb = "nix run github:nix-community/home-manager -- switch --flake path:$HOME/Documents/GitHub/nix#workstation -b hm-bak"; # nrb - rebuild declarative config
nup = "nix flake update $HOME/Documents/GitHub/nix && nix run github:nix-community/home-manager -- switch --flake path:$HOME/Documents/GitHub/nix#workstation -b hm-bak"; # nup - update flake + rebuild
nrb = "nix run github:nix-community/home-manager -- switch --flake path:$HOME/Documents/GitHub/nix#linux -b hm-bak"; # nrb - rebuild declarative config
nup = "nix flake update $HOME/Documents/GitHub/nix && nix run github:nix-community/home-manager -- switch --flake path:$HOME/Documents/GitHub/nix#linux -b hm-bak"; # nup - update flake + rebuild
};
envExtra =

View file

@ -4,17 +4,17 @@ default:
check:
nix --extra-experimental-features 'nix-command flakes' flake check
build config='hari-macbook-pro':
build config='darwin':
#!/usr/bin/env bash
if [[ "{{config}}" == "hari-macbook-pro" ]]; then
if [[ "{{config}}" == "darwin" ]]; then
nix --extra-experimental-features 'nix-command flakes' build path:.#darwinConfigurations.{{config}}.system
else
nix --extra-experimental-features 'nix-command flakes' run github:nix-community/home-manager -- build --flake path:.#{{config}}
fi
switch config='hari-macbook-pro':
switch config='darwin':
#!/usr/bin/env bash
if [[ "{{config}}" == "hari-macbook-pro" ]]; then
if [[ "{{config}}" == "darwin" ]]; then
sudo env PATH="$PATH" nix --extra-experimental-features 'nix-command flakes' run github:LnL7/nix-darwin/master#darwin-rebuild -- switch --flake path:.#{{config}}
else
nix --extra-experimental-features 'nix-command flakes' run github:nix-community/home-manager -- switch --flake path:.#{{config}} -b hm-bak