Refactor to support nix darwin

Checkpoint
This commit is contained in:
Nathan McCarty 2022-03-31 01:21:37 -04:00
parent d0ff8d2dd2
commit 11b51032a7
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
10 changed files with 232 additions and 118 deletions

View File

@ -0,0 +1,9 @@
# Linux Specific Core development libraries
{ config, pkgs, unstable, ... }:
{
environment.systemPackages = with pkgs; [
gcc
binutils
clang
];
}

View File

@ -10,11 +10,7 @@
# General development requirements # General development requirements
python3Full python3Full
cmake cmake
gcc
unstable.libvterm-neovim
libtool libtool
binutils
clang
gnumake gnumake
nixpkgs-fmt nixpkgs-fmt
# jq for interacting with JSON # jq for interacting with JSON

View File

@ -6,9 +6,8 @@
rustup rustup
# Install the latest rust analyzer # Install the latest rust analyzer
fenix.rust-analyzer fenix.rust-analyzer
# Sccache and lld for faster builds # Sccache for faster builds
sccache sccache
lld_12
# Misc cargo utilites # Misc cargo utilites
cargo-binutils # Allow invoking the llvm tools included with the toolchain cargo-binutils # Allow invoking the llvm tools included with the toolchain
cargo-edit # Command line Cargo.toml manipulation cargo-edit # Command line Cargo.toml manipulation

25
darwin-modules/base.nix Normal file
View File

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[
pkgs.vim
];
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Create /etc/bashrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}

24
darwin-modules/gpg.nix Normal file
View File

@ -0,0 +1,24 @@
# Configure gpg with yubikey support
{ config, pkgs, ... }:
{
# Setup environment for gpg agent
environment.shellInit = ''
export GPG_TTY="$(tty)"
gpg-connect-agent /bye
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
'';
programs = {
# Enable gpg-agent with ssh support
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
};
# install gnupg and yubikey personalization
environment.systemPackages = with pkgs; [
gnupg
yubikey-personalization
];
}

View File

@ -1,12 +1,33 @@
{ {
"nodes": { "nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1648278671,
"narHash": "sha256-1WrR9ex+rKTjZtODNUZQhkWYUprtfOkjOyo9YWL2NMs=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "4fdbb8168f61d31d3f90bb0d07f48de709c4fe79",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"emacs": { "emacs": {
"locked": { "locked": {
"lastModified": 1648636019, "lastModified": 1648697127,
"narHash": "sha256-+ouEG2bFGttFe9xDgTJ6EQx6MbfZ8Mwvp+K1+CZJNGg=", "narHash": "sha256-Huz+aayKyCCUU1AVZrh5mC6O2BOLlIYFRFBuJ6w7CMc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "emacs-overlay", "repo": "emacs-overlay",
"rev": "af2208c42bca9e11703fd4d3853a56213e88cbb8", "rev": "578eda92635e270c8b01edfd67aed6a3e8bf7d27",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -39,11 +60,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1648366999, "lastModified": 1648677361,
"narHash": "sha256-Sdm0lI2ZBc70EnMMmvfDVY7gIM3M4c2L86EdQ9tKRE4=", "narHash": "sha256-WA7F77XrvIjNaAyW6/D06/xVdbr3TNchHHB+oJbyDio=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "888eac32bd657bfe0d024c8770130d80d1c02cd3", "rev": "9580f6c42af2535dc7890edb681ead090f5105f2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -148,6 +169,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"darwin": "darwin",
"emacs": "emacs", "emacs": "emacs",
"fenix": "fenix", "fenix": "fenix",
"home-manager": "home-manager", "home-manager": "home-manager",

View File

@ -16,18 +16,20 @@
}; };
sops-nix.url = "github:Mic92/sops-nix"; sops-nix.url = "github:Mic92/sops-nix";
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix, home-manager }: outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix, home-manager, darwin }:
let let
coreModules = [ baseModules = [
./modules/common.nix
./modules/ssh.nix
./applications/utils-core.nix ./applications/utils-core.nix
sops-nix.nixosModules.sops ## Setup binary caches and other common nix config
home-manager.nixosModules.home-manager
## Setup binary caches
({ pkgs, ... }: { ({ pkgs, ... }: {
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# First install cachix, so we can discover new ones # First install cachix, so we can discover new ones
environment.systemPackages = [ pkgs.cachix ]; environment.systemPackages = [ pkgs.cachix ];
# Then configure up the nix community cache # Then configure up the nix community cache
@ -38,8 +40,19 @@
binaryCachePublicKeys = [ binaryCachePublicKeys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
]; ];
# Turn on flakes support (from within a flake, lamo)
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
}; };
}) })
];
coreModules = baseModules ++ [
./modules/common.nix
./modules/ssh.nix
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
## Setup sops ## Setup sops
({ pkgs, config, ... }: { ({ pkgs, config, ... }: {
# Add default secrets # Add default secrets
@ -67,6 +80,7 @@
./modules/printing.nix ./modules/printing.nix
./applications/communications.nix ./applications/communications.nix
./applications/devel-core.nix ./applications/devel-core.nix
./applications/devel-core-linux.nix
./applications/devel-rust.nix ./applications/devel-rust.nix
./applications/emacs.nix ./applications/emacs.nix
./applications/image-editing.nix ./applications/image-editing.nix
@ -77,7 +91,8 @@
mozillaOverlay = import "${mozilla}"; mozillaOverlay = import "${mozilla}";
in in
{ {
nixosConfigurations.levitation = nixpkgs.lib.nixosSystem { nixosConfigurations = {
levitation = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { specialArgs = {
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
@ -90,10 +105,11 @@
modules = [ modules = [
./hardware/levitation.nix ./hardware/levitation.nix
./modules/games.nix ./modules/games.nix
./home-linux.nix
] ++ desktopModules; ] ++ desktopModules;
}; };
nixosConfigurations.x86vm = nixpkgs.lib.nixosSystem { x86vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { specialArgs = {
unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
@ -103,7 +119,29 @@
}; };
fenix = fenix.packages.x86_64-linux; fenix = fenix.packages.x86_64-linux;
}; };
modules = desktopModules; modules = [ ./home-linux.nix ] ++ desktopModules;
};
};
darwinConfigurations = {
"Nathans-MacBook-Pro" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = {
unstable = import nixpkgs-unstable {
config = { allowUnfree = true; };
overlays = [ emacs.overlay ];
system = "x86_64-darwin";
};
fenix = fenix.packages.x86_64-darwin;
};
modules = baseModules ++ [
./darwin-modules/base.nix
home-manager.darwinModules.home-manager
./home.nix
./darwin-modules/gpg.nix
./applications/devel-core.nix
./applications/devel-rust.nix
];
};
}; };
}; };
} }

76
home-linux.nix Normal file
View File

@ -0,0 +1,76 @@
{ pkgs, config, unstable, ... }:
{
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
## Linux specific user configuration
users = {
mutableUsers = false;
isNormalUser = true;
users.nathan = {
extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" "plugdev" ];
hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58.";
openssh.authorizedKeys.keys = [
# yubikey ssh key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515"
# Macbook pro key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBfkO7kq37RQMT8UE8zQt/vP4Ub7kizLw6niToJwAIe nathan@Nathans-MacBook-Pro.local"
];
};
};
# enable sudo
security.sudo.enable = true;
home-manager = {
users.nathan = {
# Alacritty configuration
programs.alacritty = {
enable = true;
settings = {
env = {
TERM = "xterm-256color";
ALACRITTY = "1";
};
font = {
normal.family = "FiraCode Nerd Font";
bold.family = "FiraCode Nerd Font";
italic.family = "FiraCode Nerd Font";
bold_italic.family = "FiraCode Nerd Font";
size = 9.0;
};
colors = {
primary = {
background = "0x103c48";
foreground = "0xadbcbc";
};
normal = {
black = "0x184956";
red = "0xfa5750";
green = "0x75b938";
yellow = "0xdbb32d";
blue = "0x4695f7";
magenta = "0xf275be";
cyan = "0x41c7b9";
white = "0x72898f";
};
bright = {
black = "0x2d5b69";
red = "0xff665c";
green = "0x84c747";
yellow = "0xebc13d";
blue = "0x58a3ff";
magenta = "0xff84cd";
cyan = "0x53d6c7";
white = "0xcad8d9";
};
};
};
};
## Multimedia
# Easyeffects for the eq
services.easyeffects.enable = true;
}
}
}

View File

@ -3,30 +3,12 @@
## Some general settings that were in the user configuration ## Some general settings that were in the user configuration
# Set time zone # Set time zone
time.timeZone = "America/New_York"; time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
# enable sudo
security.sudo.enable = true;
## Setup user first ## Setup user first
users = { users = {
mutableUsers = false;
users.nathan = { users.nathan = {
isNormalUser = true;
home = "/home/nathan"; home = "/home/nathan";
description = "Nathan McCarty"; description = "Nathan McCarty";
extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" "plugdev" ]; shell = pkgs.fish;
hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58.";
shell = unstable.fish;
openssh.authorizedKeys.keys = [
# yubikey ssh key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515"
# Macbook pro key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBfkO7kq37RQMT8UE8zQt/vP4Ub7kizLw6niToJwAIe nathan@Nathans-MacBook-Pro.local"
];
}; };
}; };
## Home manager proper ## Home manager proper
@ -39,8 +21,6 @@
# Shell proper # Shell proper
programs.fish = { programs.fish = {
enable = true; enable = true;
# Use latest possible fish
package = unstable.fish;
# Setup our aliases # Setup our aliases
shellAliases = { shellAliases = {
ls = "exa --icons"; ls = "exa --icons";
@ -73,49 +53,6 @@
}; };
}; };
}; };
# Alacritty configuration
programs.alacritty = {
enable = true;
settings = {
env = {
TERM = "xterm-256color";
ALACRITTY = "1";
};
font = {
normal.family = "FiraCode Nerd Font";
bold.family = "FiraCode Nerd Font";
italic.family = "FiraCode Nerd Font";
bold_italic.family = "FiraCode Nerd Font";
size = 9.0;
};
colors = {
primary = {
background = "0x103c48";
foreground = "0xadbcbc";
};
normal = {
black = "0x184956";
red = "0xfa5750";
green = "0x75b938";
yellow = "0xdbb32d";
blue = "0x4695f7";
magenta = "0xf275be";
cyan = "0x41c7b9";
white = "0x72898f";
};
bright = {
black = "0x2d5b69";
red = "0xff665c";
green = "0x84c747";
yellow = "0xebc13d";
blue = "0x58a3ff";
magenta = "0xff84cd";
cyan = "0x53d6c7";
white = "0xcad8d9";
};
};
};
};
# Git configuration # Git configuration
programs.git = { programs.git = {
enable = true; enable = true;
@ -197,16 +134,13 @@
}; };
}; };
}; };
## Multimedia
# Easyeffects for the eq
services.easyeffects.enable = true;
}; };
}; };
## Misc packages that were in user.nix ## Misc packages that were in user.nix
# Install general use packages # Install general use packages
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# Install our shell of choice # Install our shell of choice
unstable.fish fish
# Install rclone # Install rclone
rclone rclone
]; ];

View File

@ -1,14 +1,5 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Turn on flakes support (from within a flake, lamo)
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# Turn on compressed memory swap # Turn on compressed memory swap
zramSwap = { zramSwap = {
enable = true; enable = true;