Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Darwin (aarch64) #37

Merged
merged 5 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
.PHONY: rb-switch
UNAME := $(shell uname)

rb-switch:
ifeq ($(UNAME), Darwin)
echo "Switching configuration on $(UNAME)"
darwin-rebuild switch --flake .
else
echo "Switching configuration on $(UNAME)"
sudo nixos-rebuild switch --use-remote-sudo --flake .

endif
rb-test:
ifeq ($(UNAME), Linux)
sudo nixos-rebuild test --use-remote-sudo --flake .
else
echo "Unsupported system $(UNAME)"
endif

rb-boot:
ifeq ($(UNAME), Linux)
sudo nixos-rebuild boot --use-remote-sudo --flake .
else
echo "Unsupported system $(UNAME)"
endif

.PHONY: install
install:
ln -T -fs $(PWD)/dotfiles/git/gitconfig ~/.gitconfig
ln -T -fs $(PWD)/dotfiles/autostart/activitywatch.desktop ~/.config/autostart/activitywatch.desktop
ln -fs $(PWD)/dotfiles/git/gitconfig ~/.gitconfig

mac-update-zshrc:
echo 'if test -e /etc/static/zshrc; then . /etc/static/zshrc; fi' | sudo tee -a /etc/zshrc

.PHONY: rb-switch rb-test rb-boot install mac-update-zshrc
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OS dotfiles for NixOS
# OS dotfiles for Nix(OS)

This repository configures all of my digital devices that run ✨ NixOS ✨ !
This repository configures all of my digital devices that run ✨ Nix(OS) ✨ !

## Help

Expand All @@ -21,12 +21,17 @@ looking elsewhere first:

A machine, such as a server or laptop, is called a *host*.

Host configurations live in the [hosts](./hosts) directory. The configuration of a host is comprised of three parts:
Host configurations live in the [hosts](./hosts) directory.

If a host is using NixOS, the configuration of a host is comprised of three
parts:

1. a hardware configuration
2. a system configuration
3. a home configuration

If a host is using MacOS, the configuration is comprised only of a home configuration.

All of these files are imported by [./flake.nix](./flake.nix).

### System services, apps, ...
Expand All @@ -45,3 +50,7 @@ Software and configuration files in user-land live in [home](./home) and is conf
4. Done!

Note that the hostname of the new device must match the name of the host in [./flake.nix](./flake.nix).

### MacOS specifics

For MacOS devices, some caveats apply. To set up my repository for compatibility with MacOS, I followed this excellent blog post: https://xyno.space/post/nix-darwin-introduction.
2 changes: 2 additions & 0 deletions dotfiles/git/gitconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[include]
path = ~/os/dotfiles/git/gituser-default
[include]
path = ~/code/os/dotfiles/git/gituser-default
[includeIf "gitdir:~/code/meraki/**"]
path = ~/os/dotfiles/git/gituser-meraki
[includeIf "gitdir:~/code/modcam/**"]
Expand Down
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager/release-22.11";
darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, unstable, home-manager, ... }:
outputs = { self, nixpkgs, unstable, home-manager, darwin, ... }:
{
nixosConfigurations = {
keeper = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/keeper
home-manager.nixosModules.home-manager
{
nixosConfigurations = { keeper = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./hosts/keeper home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.johanan = { ... }: {
Expand Down Expand Up @@ -84,6 +80,24 @@
];
};
};

darwinConfigurations = {
airm2 = darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
./hosts/airm2
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.johanan = { ... }: {
_module.args.unstable = unstable;
imports = [ ./hosts/airm2/home.nix ];
};
}
];
};
};
};
}

13 changes: 8 additions & 5 deletions home/cli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
let
cfg = config.skogsbrus.cli;
inherit (lib) mkOption mkEnableOption types;
linuxPackages = with pkgs; [
iputils # Not supported on Darwin (22-05-19)
traceroute # Not supported on Darwin (22-05-19)
usbutils # Not supported on Darwin (22-05-19)
iw # Not supported on Darwin (22-05-19)
];
in
{
config = {
Expand All @@ -16,11 +22,8 @@ in
curl
dig
iperf
iw
mtr
openssl
iputils
traceroute
wget

# build tools
Expand All @@ -45,9 +48,9 @@ in
tmux

# misc
usbutils
zsh
];
] ++ (if stdenv.isLinux then linuxPackages else []);


programs.fzf = {
enable = true;
Expand Down
10 changes: 4 additions & 6 deletions home/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ in
config = mkIf cfg.enable {
home.packages = with pkgs; [
jetbrains-mono
docker
podman
qemu
postgresql
zeal
]
] ++ (if stdenv.isLinux then [ zeal ] else [ ])
++ cfg.extraPackages
++ (if cfg.enableAll || cfg.cuda then [ pkgs.cudatoolkit_11 ] else [ ])
++ (if cfg.enableAll || cfg.k8s then [
Expand All @@ -58,12 +58,10 @@ in
] else [ ])
++ (if cfg.enableAll || cfg.cxx then [
pkgs.cmake
pkgs.coz
pkgs.gcc
pkgs.gdb
pkgs.gnumake
pkgs.valgrind
] else [ ])
] else [ ] ++ (if stdenv.isLinux then [ pkgs.coz pkgs.valgrind ] else [ ]))
++ (if cfg.enableAll || cfg.corporate then [
pkgs.go-jira
] else [ ]);
Expand Down
6 changes: 5 additions & 1 deletion home/firefox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
, pkgs
, ...
}:
let
cfg = config.skogsbrus.firefox;
inherit (lib) mkIf;
in
{
options.skogsbrus.firefox = {
enable = lib.mkEnableOption "firefox";
};

config = {
config = mkIf cfg.enable {
programs.firefox = {
enable = true;
profiles.johanan = {
Expand Down
10 changes: 10 additions & 0 deletions hosts/airm2/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ pkgs, ... }:
{
users.users.johanan = {
name = "johanan";
home = "/Users/johanan";
};

services.nix-daemon.enable = true;
programs.zsh.enable = true;
}
25 changes: 25 additions & 0 deletions hosts/airm2/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ config
, lib
, pkgs
, modulesPath
, ...
}:
{
imports = [
../../home
];

skogsbrus = {
dev = {
enable = true;
aws = true;
cxx = true;
k8s = true;
terraform = true;
};
lspServers = {
enable = true;
enableAll = true;
};
};
}
8 changes: 8 additions & 0 deletions sys/wireguard.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ in
"${cfg.subnet}.4/32"
];
}
{
# airm2
publicKey = "h4QkyuAWO7Iq3ZlHOSIjmvFGTuqCLhZSr94HDNl4xyw=";
presharedKeyFile = "/home/johanan/os/secrets/wireguard-psk-airm2.key";
allowedIPs = [
"${cfg.subnet}.5/32"
];
}
] else [ ]) ++ (if !cfg.server then
[{
# Router
Expand Down